gooee 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/Checkbox/Checkbox.tsx +8 -4
- package/src/components/DropdownMenu/DropdownMenu.tsx +1 -1
- package/src/components/DropdownMenu/DropdownMenu.vue +1 -1
- package/src/components/SearchInput/SearchInput.tsx +7 -2
- package/src/components/Select/Select.tsx +1 -1
- package/src/components/Select/Select.vue +1 -1
- package/src/components/Slider/Slider.tsx +7 -2
package/package.json
CHANGED
|
@@ -47,6 +47,8 @@ export function Checkbox({
|
|
|
47
47
|
const errorId = `${inputId}-error`
|
|
48
48
|
const describedBy = [description ? `${inputId}-desc` : null, error ? errorId : null, describedByProp].filter(Boolean).join(' ')
|
|
49
49
|
const [checked, setChecked] = useControllable(checkedProp, defaultChecked, onCheckedChange)
|
|
50
|
+
// A form library's onChange, such as react-hook-form's register, runs after the box updates instead of replacing it.
|
|
51
|
+
const { onChange, ...inputRest } = rest as typeof rest & Pick<ComponentPropsWithRef<'input'>, 'onChange'>
|
|
50
52
|
const inner = useRef<HTMLInputElement>(null)
|
|
51
53
|
// Like a native checkbox, a click clears the mixed look until the prop sets it again.
|
|
52
54
|
const [mixed, setMixed] = useState(indeterminate)
|
|
@@ -89,16 +91,18 @@ export function Checkbox({
|
|
|
89
91
|
aria-invalid={error ? true : undefined}
|
|
90
92
|
aria-describedby={describedBy || undefined}
|
|
91
93
|
onChange={(e) => {
|
|
92
|
-
if (
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
if (mixed) {
|
|
95
|
+
setMixed(false)
|
|
96
|
+
setChecked(true)
|
|
97
|
+
} else setChecked(e.target.checked)
|
|
98
|
+
onChange?.(e)
|
|
95
99
|
}}
|
|
96
100
|
onPointerDown={onPointerDown}
|
|
97
101
|
onKeyDown={(e) => {
|
|
98
102
|
cup.current!.key()
|
|
99
103
|
onKeyDown?.(e)
|
|
100
104
|
}}
|
|
101
|
-
{...
|
|
105
|
+
{...inputRest}
|
|
102
106
|
/>
|
|
103
107
|
<span ref={boxRef} data-slot="checkbox-box" className={styles.box} data-state={state} aria-hidden="true">
|
|
104
108
|
<span className={styles.fill} data-pour-fill />
|
|
@@ -153,7 +153,7 @@ export function DropdownMenu({ trigger, items, label, align = 'start' }: Dropdow
|
|
|
153
153
|
className={styles.item}
|
|
154
154
|
data-disabled={item.disabled || undefined}
|
|
155
155
|
data-destructive={item.destructive || undefined}
|
|
156
|
-
style={{ ['--i' as string]: n }}
|
|
156
|
+
style={{ ['--i' as string]: Math.min(n, 12) }}
|
|
157
157
|
onPointerMove={(e) => !item.disabled && e.currentTarget.focus()}
|
|
158
158
|
onClick={() => {
|
|
159
159
|
if (item.disabled) return
|
|
@@ -167,7 +167,7 @@ const labelledBy = () => triggerId
|
|
|
167
167
|
:class="styles.item"
|
|
168
168
|
:data-disabled="item.disabled || undefined"
|
|
169
169
|
:data-destructive="item.destructive || undefined"
|
|
170
|
-
:style="{ '--i': stagger[i] }"
|
|
170
|
+
:style="{ '--i': Math.min(stagger[i], 12) }"
|
|
171
171
|
@pointermove="(e: PointerEvent) => !item.disabled && (e.currentTarget as HTMLElement).focus()"
|
|
172
172
|
@click="select(item)"
|
|
173
173
|
@keydown="itemKey"
|
|
@@ -40,9 +40,11 @@ export function SearchInput({
|
|
|
40
40
|
className,
|
|
41
41
|
ref,
|
|
42
42
|
onKeyDown,
|
|
43
|
-
...
|
|
43
|
+
...props
|
|
44
44
|
}: SearchInputProps) {
|
|
45
45
|
const [value, setValue] = useControllable(valueProp, defaultValue, onValueChange)
|
|
46
|
+
// A form library's onChange runs after the field's own instead of being dropped.
|
|
47
|
+
const { onChange, ...rest } = props as typeof props & Pick<InputProps, 'onChange'>
|
|
46
48
|
const inputRef = useRef<HTMLInputElement>(null)
|
|
47
49
|
|
|
48
50
|
useEffect(() => {
|
|
@@ -61,7 +63,10 @@ export function SearchInput({
|
|
|
61
63
|
value={value}
|
|
62
64
|
leading={<SearchIcon />}
|
|
63
65
|
aria-keyshortcuts={shortcut}
|
|
64
|
-
onChange={(e) =>
|
|
66
|
+
onChange={(e) => {
|
|
67
|
+
setValue(e.target.value)
|
|
68
|
+
onChange?.(e)
|
|
69
|
+
}}
|
|
65
70
|
onKeyDown={(e) => {
|
|
66
71
|
onKeyDown?.(e)
|
|
67
72
|
// Enter during IME composition picks a word, not a search
|
|
@@ -212,7 +212,7 @@ export function Select({
|
|
|
212
212
|
data-highlighted={i === active || undefined}
|
|
213
213
|
data-selected={o.value === value || undefined}
|
|
214
214
|
data-disabled={o.disabled || undefined}
|
|
215
|
-
style={{ ['--i' as string]: i }}
|
|
215
|
+
style={{ ['--i' as string]: Math.min(i, 12) }}
|
|
216
216
|
onPointerMove={() => enabled(i) && active !== i && setActive(i)}
|
|
217
217
|
onClick={() => choose(i)}
|
|
218
218
|
>
|
|
@@ -225,7 +225,7 @@ const describedBy = computed(
|
|
|
225
225
|
:data-highlighted="i === active || undefined"
|
|
226
226
|
:data-selected="o.value === value || undefined"
|
|
227
227
|
:data-disabled="o.disabled || undefined"
|
|
228
|
-
:style="{ '--i': i }"
|
|
228
|
+
:style="{ '--i': Math.min(i, 12) }"
|
|
229
229
|
@pointermove="enabled(i) && active !== i && (active = i)"
|
|
230
230
|
@click="choose(i)"
|
|
231
231
|
>
|
|
@@ -58,6 +58,8 @@ export function Slider({
|
|
|
58
58
|
const auto = useId()
|
|
59
59
|
const inputId = id ?? auto
|
|
60
60
|
const [value, setValue] = useControllable(valueProp, defaultValue ?? min, onValueChange)
|
|
61
|
+
// A form library's onChange runs after the slider's own instead of replacing it.
|
|
62
|
+
const { onChange, ...inputRest } = rest as typeof rest & Pick<ComponentPropsWithRef<'input'>, 'onChange'>
|
|
61
63
|
// Where the thumb is drawn while it glides to a click or settles on a mark; the value is set already.
|
|
62
64
|
const [shown, setShown] = useState<number | null>(null)
|
|
63
65
|
const latest = useRef({ value, min, max, step, marks })
|
|
@@ -103,7 +105,10 @@ export function Slider({
|
|
|
103
105
|
aria-valuenow={value}
|
|
104
106
|
aria-valuetext={formatValue === String ? undefined : text}
|
|
105
107
|
// Only "input": the browser's "change" on release carries the thumb's mid-glide place, not the value.
|
|
106
|
-
onChange={(e) =>
|
|
108
|
+
onChange={(e) => {
|
|
109
|
+
if (e.nativeEvent.type === 'input') slider.current!.input(e.currentTarget, Number(e.target.value))
|
|
110
|
+
onChange?.(e)
|
|
111
|
+
}}
|
|
107
112
|
onPointerDown={(e: PointerEvent<HTMLInputElement>) => {
|
|
108
113
|
slider.current!.down(e.currentTarget, e.clientX)
|
|
109
114
|
onPointerDown?.(e)
|
|
@@ -133,7 +138,7 @@ export function Slider({
|
|
|
133
138
|
slider.current!.keyUp()
|
|
134
139
|
onKeyUp?.(e)
|
|
135
140
|
}}
|
|
136
|
-
{...
|
|
141
|
+
{...inputRest}
|
|
137
142
|
/>
|
|
138
143
|
{showValue && (
|
|
139
144
|
<span className={styles.bubble} data-slot="slider-bubble" aria-hidden="true">{text}</span>
|