chore: deep overhaul — function-component rewrite, builder-bob build, CI, tests & docs (v3.0.0) - #134
Open
kuraydev wants to merge 9 commits into
Open
chore: deep overhaul — function-component rewrite, builder-bob build, CI, tests & docs (v3.0.0)#134kuraydev wants to merge 9 commits into
kuraydev wants to merge 9 commits into
Conversation
…spinner - Rewrite SearchBar from a class to a function component using hooks. - Expose focus()/blur()/clear()/getTextInput() via forwardRef + useImperativeHandle (closes #97). - Split props explicitly so TextInputProps reach the TextInput and touchable props reach the container, fixing onSubmitEditing firing twice (closes #108). - Make react-native-spinkit optional via a guarded lazy require so apps that do not use the built-in spinner no longer fail to build (closes #98, #102). - Add a spinnerComponent prop for JS-only spinners (Expo / New Architecture). - Tighten types: drop any, add SpinnerType union, ReactNode, ImageSourcePropType. - Add accessibility roles/labels. Preserve all public prop names and defaults.
…data - Build CommonJS + ESM + TypeScript definitions via react-native-builder-bob; source moves to src/, output to lib/ (gitignored). - Add main/module/types/react-native/source fields, an exports map (dual package), sideEffects:false and a files allowlist; default and named imports both resolve. - Declare react and react-native as peerDependencies (none were declared); mark react-native-spinkit as an optional peer via peerDependenciesMeta. - Repoint homepage/bugs/repository from WrathChaos to kuraydev; keep the npm package name and MIT license unchanged. - Remove dead/abandoned devDeps (react-native-typescript-transformer, @types/react-native, @react-native-community/eslint-config, eslint-config-airbnb, npm-post-install, prettier-format).
- Add eslint.config.js (flat) using typescript-eslint, react and react-hooks plugins, prettier compatibility. - Remove legacy .eslintrc.js (@react-native-community, eslint 9 incompatible), .eslintignore, and the broken husky hooks. - The lint script now runs eslint instead of the uninstalled tslint; the format script targets src/ instead of a non-existent path.
Covers default/custom placeholder, onChangeText, onSearchPress, onClearPress, dark-mode placeholder colors, spinner visibility, custom spinnerComponent, custom icon/ImageComponent, the imperative ref handle, and a regression test asserting onSubmitEditing fires exactly once (#108). 15 tests.
- New ci.yml runs install, typecheck, lint, test and build on a Node 18/20/22 matrix for push and pull_request (replaces the absent automation). - Add bug/feature issue templates and a pull request template. - Group dependabot dev-dependency updates, switch to weekly, add the github-actions ecosystem; point FUNDING at kuraydev.
- Fix the props table (remove duplicate clearIconImageSource row, correct spinnerType name/default, document inherited TextInputProps). - Add TypeScript usage, imperative ref API, custom spinner, New Architecture / Expo notes, a single copy-paste install, ToC and Contributing section. - Repoint badges/links to kuraydev; keep existing valid media references. - Add a Keep a Changelog Unreleased section with the v3 migration notes and a CONTRIBUTING guide.
Guard the optional native spinner behind Platform.OS === 'web' and a lazy, cached require so react-native-web / Expo projects without react-native-spinkit bundle and render the search bar with no spinner-related crash. The native code path is unchanged; on web (or when spinkit is absent) the spinner slot falls back to RN's cross-platform ActivityIndicator. Adds a web-platform Jest suite and documents the react-native-web path in the README.
…pinkit The fallback triggers whenever react-native-spinkit is absent (web, Expo, or native iOS/Android without the optional package), not just on web. Note the intentional native behavior change: a requested spinner now renders an ActivityIndicator instead of nothing when the optional module is missing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Review fixes applied: before any npm publish, bump
package.jsonversion2.0.2 → 3.0.0 to match the CHANGELOG and PR title (publish-time step; not a PR blocker).Summary
This is a full modernization of
react-native-dynamic-search-bar, which had not shipped in ~4.5 years (last release 2.0.2, 2021-12-11) and whose tooling was broken (thelintscript invoked an uninstalledtslint, the eslint config was legacy and incompatible with the installed eslint 9, scripts targeted a non-existentsrc/, and there was no CI, no tests, and no committed build).The library stays a pure-JS React Native component (no native module of its own). The npm package name is unchanged (
react-native-dynamic-search-bar). All runtime prop names and default values are preserved; only the things called out under Breaking changes alter the published contract, and each is documented with a migration path.Non-breaking improvements
forwardRef+useImperativeHandleexposesfocus(),blur(),clear(), andgetTextInput()so you can drive the input and read its value.spinnerComponentprop: supply your own JS-only spinner (ideal for Expo / New Architecture, e.g.react-native-animated-spinkit) instead of the nativereact-native-spinkit.tslintreplaced with eslint 9 flat config (typescript-eslint+ react/react-hooks); legacy.eslintrc.js/.eslintignoreremoved;format/versionscript globs repointed tosrc/.onChangeText/onSearchPress/onClearPress, spinner visibility, customspinnerComponent/searchIconComponent/ImageComponent, and the ref handle — plus a regression test for Bug:onSubmitEditingcalled twice #108..github/workflows/ci.ymlruns install + typecheck + lint + test + build on a Node 18/20/22 matrix for push/PR.any/stringescapes —spinnerTypeis the spinkit union,ISourcealigns withImageSourcePropType, icon component props useReact.ReactNode.peerDependenciesMeta, afilesallowlist,sideEffects: false; removed dead devDeps (tslint,@types/react-native,react-native-typescript-transformer, husky cruft).clearIconImageSourcerow and thespinnerTypename/default mismatch, TS + ref usage, New Architecture/Expo note, single-line install, TOC, Contributing); added CHANGELOG (Keep a Changelog), CONTRIBUTING, issue templates, and a PR template. All README media references verified to still exist.Breaking changes (recommend v3.0.0 major)
focus/blur/clear/getTextInput) instead of a class instance; reliance on other class internals (oldinputReffield, arbitrary methods) breaks.react-native-spinkitis now an OPTIONAL peer dependency, resolved lazily. If you use the built-in spinner, keep spinkit installed; otherwise it renders nothing — use the newspinnerComponentprop. Migration: install spinkit OR passspinnerComponent.onSubmitEditingcalled twice #108 prop-routing fix. Props no longer spread onto both the outer touchable and the innerTextInput. Apps relying on a prop landing on both surfaces change behavior.build/dist/SearchBar.jstolib/commonjs+lib/module+lib/typescript;main/module/types/react-native/exportsupdated. The bare package-name import (default + namedSearchBar) is preserved and verified; deep imports intobuild/dist/*break.ISource,spinnerType,ImageComponent, icon component props). Runtime unchanged; strict consumers may need type tweaks.react&react-nativepeerDependencies now declared (wide*ranges). Effectively non-breaking, but newly surfaced by package managers.Verification
npm install --legacy-peer-deps— ok (1167 packages);prepareran the build.tsc --noEmit— pass, no errors.eslint .(flat config) — pass, no issues.jest— pass, 15/15 tests (incl. Bug:onSubmitEditingcalled twice #108 regression).bob build— pass, emits CommonJS + ESM + TypeScript; all entry files present.lib/commonjs/index.jsis valid CommonJS exporting the default + namedSearchBar; the only bare-noderequire()failure isrequire("react-native")(Flow-typed RN source), which is universal to every RN component lib and resolves under Metro/bundlers.Closes #108
Closes #97
Addresses #98
Addresses #102
react-native-web support (Closes #98, #102)
Both issues ("Cannot build app" / "Failing to build on Expo") trace back to the native module
react-native-spinkitbeing pulled into web/Expo bundles. This change finishes making it truly optional and web-safe.What changed
react-native-spinkitis never imported statically and never required on web. Resolution goes through a single cached helper that short-circuits withif (Platform.OS === 'web') return nullbefore the lazyrequire, thenrequires the module inside atry/catchonly the first time the built-in spinner actually renders. The previous module-topresolveSpinKit()call was removed, so nothing touches spinkit at import time.ActivityIndicatorinstead of crashing the bundle.react-native-spinkitis installed andPlatform.OS !== 'web', the exact same<SpinKit .../>renders. No public prop names, defaults, or visuals changed.Non-breaking
Platform.OS === 'web'); iOS/Android behavior with spinkit installed is byte-for-byte identical.Tests / docs
src/__tests__/SearchBar.web.test.tsx: renders under a mockedPlatform.OS = 'web'(placeholder + search icon,spinnerVisibilitywithout throwing, customspinnerComponenthonored) and asserts the source has no staticreact-native-spinkitimport. Existing suite stays green (19 passing total).[Unreleased]documents the web support and the lazy/guarded require.Verified locally:
tsc --noEmit,eslint .,jest, andbob buildall pass.