-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: code cleanup pass #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bcdee22
refactor(registry): use shared RotationSelect in text and serial
u8array af4e52e
refactor(store): introduce getCurrentObjects helper
u8array 223e507
refactor: drop ObjectRegistry any-cast and name the resize-min magic …
u8array 651dd82
refactor(properties): extract NumberInput primitive
u8array 3720ca4
fix(refactor): restore ObjectRegistry any-cast and the inlined objs ref
u8array 75b84b9
refactor(registry): migrate 1D/2D barcodes to NumberInput primitive
u8array 200add2
refactor(registry): NumberInput rollout in shapes, gs1databar, text/s…
u8array b6b4454
fix(NumberInput): enforce max and drop NaN before it reaches the store
u8array File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { clampMin } from '../../lib/inputParse'; | ||
| import { inputCls, labelCls } from './styles'; | ||
|
|
||
| interface NumberInputProps { | ||
| label: string; | ||
| value: number; | ||
| /** When set, the change handler receives a value clamped to at least `min`, | ||
| * guarding against the empty/0 input collapse that bare Number() invites. */ | ||
| min?: number; | ||
| max?: number; | ||
| onChange: (next: number) => void; | ||
| disabled?: boolean; | ||
| readOnly?: boolean; | ||
| } | ||
|
|
||
| /** | ||
| * Standard label + number input pair used by registry properties panels. | ||
| * Centralises the layout, the labelCls/inputCls coupling, and the | ||
| * empty-or-NaN-to-min sanitisation so individual registries don't repeat | ||
| * the boilerplate. | ||
| */ | ||
| export function NumberInput({ | ||
| label, | ||
| value, | ||
| min, | ||
| max, | ||
| onChange, | ||
| disabled, | ||
| readOnly, | ||
| }: NumberInputProps) { | ||
| return ( | ||
| <div className="flex flex-col gap-1"> | ||
| <label className={labelCls}>{label}</label> | ||
| <input | ||
| type="number" | ||
| className={inputCls} | ||
| value={value} | ||
| min={min} | ||
| max={max} | ||
| disabled={disabled} | ||
| readOnly={readOnly} | ||
| onChange={(e) => { | ||
| const raw = e.target.value; | ||
| let next = min !== undefined ? clampMin(raw, min) : Number(raw); | ||
| // Drop NaN before it corrupts the store. clampMin already returns | ||
| // `min` for unparsable input, so this only matters when `min` is | ||
| // undefined and the user pastes a non-numeric string. | ||
| if (isNaN(next)) return; | ||
| if (max !== undefined && next > max) next = max; | ||
| onChange(next); | ||
| }} | ||
| /> | ||
| </div> | ||
| ); | ||
| } | ||
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.