@donotdev/components 0.2.3 → 0.3.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/dist/CarouselContent-5W2E2F2I.js +1 -0
- package/dist/CarouselContent-EELYAALW.js +1 -0
- package/dist/CodeContent-7FWYPAB3.js +2 -0
- package/dist/CodeContent-E3HLW6BW.js +2 -0
- package/dist/advanced/Carousel/Carousel.d.ts +6 -4
- package/dist/advanced/Carousel/Carousel.d.ts.map +1 -1
- package/dist/advanced/Carousel/Carousel.js +10 -8
- package/dist/advanced/Carousel/CarouselContent.d.ts +35 -3
- package/dist/advanced/Carousel/CarouselContent.d.ts.map +1 -1
- package/dist/advanced/Carousel/CarouselContent.js +103 -67
- package/dist/advanced/Carousel/CarouselSkeleton.d.ts +3 -1
- package/dist/advanced/Carousel/CarouselSkeleton.d.ts.map +1 -1
- package/dist/advanced/Carousel/CarouselSkeleton.js +2 -2
- package/dist/advanced/ImageGallery/ImageGallery.d.ts +12 -2
- package/dist/advanced/ImageGallery/ImageGallery.d.ts.map +1 -1
- package/dist/advanced/ImageGallery/ImageGallery.js +3 -3
- package/dist/atomic/ActionButton/index.d.ts +1 -1
- package/dist/atomic/ActionButton/index.js +1 -1
- package/dist/atomic/Alert/index.d.ts +1 -1
- package/dist/atomic/Badge/index.d.ts +1 -1
- package/dist/atomic/Button/index.d.ts +30 -1
- package/dist/atomic/Button/index.d.ts.map +1 -1
- package/dist/atomic/Button/index.js +38 -1
- package/dist/atomic/Card/cover.d.ts +8 -1
- package/dist/atomic/Card/cover.d.ts.map +1 -1
- package/dist/atomic/Card/cover.js +2 -2
- package/dist/atomic/Card/index.d.ts +18 -3
- package/dist/atomic/Card/index.d.ts.map +1 -1
- package/dist/atomic/Card/index.js +20 -3
- package/dist/atomic/Collapsible/index.d.ts +7 -1
- package/dist/atomic/Collapsible/index.d.ts.map +1 -1
- package/dist/atomic/Collapsible/index.js +8 -3
- package/dist/atomic/Combobox/index.d.ts +11 -1
- package/dist/atomic/Combobox/index.d.ts.map +1 -1
- package/dist/atomic/Combobox/index.js +25 -9
- package/dist/atomic/DatePicker/index.d.ts +3 -1
- package/dist/atomic/DatePicker/index.d.ts.map +1 -1
- package/dist/atomic/DatePicker/index.js +2 -2
- package/dist/atomic/DateTimePicker/index.d.ts +3 -1
- package/dist/atomic/DateTimePicker/index.d.ts.map +1 -1
- package/dist/atomic/DateTimePicker/index.js +2 -2
- package/dist/atomic/HeroSection/index.d.ts +1 -1
- package/dist/atomic/Input/index.d.ts +3 -1
- package/dist/atomic/Input/index.d.ts.map +1 -1
- package/dist/atomic/Input/index.js +3 -3
- package/dist/atomic/Label/FieldInfo.d.ts +18 -0
- package/dist/atomic/Label/FieldInfo.d.ts.map +1 -0
- package/dist/atomic/Label/FieldInfo.js +34 -0
- package/dist/atomic/Label/FloatingLabel.d.ts +6 -1
- package/dist/atomic/Label/FloatingLabel.d.ts.map +1 -1
- package/dist/atomic/Label/FloatingLabel.js +6 -2
- package/dist/atomic/Label/index.d.ts +1 -0
- package/dist/atomic/Label/index.d.ts.map +1 -1
- package/dist/atomic/Label/index.js +1 -0
- package/dist/atomic/PasswordInput/index.d.ts +3 -1
- package/dist/atomic/PasswordInput/index.d.ts.map +1 -1
- package/dist/atomic/PasswordInput/index.js +2 -2
- package/dist/atomic/PinInput/index.d.ts +3 -1
- package/dist/atomic/PinInput/index.d.ts.map +1 -1
- package/dist/atomic/PinInput/index.js +2 -2
- package/dist/atomic/QuantityStepper/index.d.ts +19 -4
- package/dist/atomic/QuantityStepper/index.d.ts.map +1 -1
- package/dist/atomic/QuantityStepper/index.js +208 -5
- package/dist/atomic/QuantityStepper/quantity.d.ts +14 -0
- package/dist/atomic/QuantityStepper/quantity.d.ts.map +1 -0
- package/dist/atomic/QuantityStepper/quantity.js +35 -0
- package/dist/atomic/RangeInput/index.d.ts +3 -1
- package/dist/atomic/RangeInput/index.d.ts.map +1 -1
- package/dist/atomic/RangeInput/index.js +2 -2
- package/dist/atomic/Rating/index.d.ts +1 -1
- package/dist/atomic/Select/index.d.ts +3 -1
- package/dist/atomic/Select/index.d.ts.map +1 -1
- package/dist/atomic/Select/index.js +2 -2
- package/dist/atomic/Stepper/index.d.ts +1 -1
- package/dist/atomic/SwipeAction/gesture.d.ts +5 -0
- package/dist/atomic/SwipeAction/gesture.d.ts.map +1 -0
- package/dist/atomic/SwipeAction/gesture.js +10 -0
- package/dist/atomic/SwipeAction/index.d.ts +12 -0
- package/dist/atomic/SwipeAction/index.d.ts.map +1 -0
- package/dist/atomic/SwipeAction/index.js +62 -0
- package/dist/atomic/Table/editing.d.ts +3 -1
- package/dist/atomic/Table/editing.d.ts.map +1 -1
- package/dist/atomic/Table/editing.js +9 -6
- package/dist/atomic/Table/index.d.ts +9 -1
- package/dist/atomic/Table/index.d.ts.map +1 -1
- package/dist/atomic/Table/index.js +64 -48
- package/dist/atomic/Tabs/index.d.ts +1 -1
- package/dist/atomic/Tag/index.d.ts +3 -1
- package/dist/atomic/Tag/index.d.ts.map +1 -1
- package/dist/atomic/Tag/index.js +2 -2
- package/dist/atomic/Toaster/ToastPrimitive.d.ts +2 -2
- package/dist/atomic/Toaster/ToastPrimitive.d.ts.map +1 -1
- package/dist/atomic/Toggle/index.d.ts +1 -1
- package/dist/atomic/index.d.ts +6 -3
- package/dist/atomic/index.d.ts.map +1 -1
- package/dist/atomic/index.js +3 -1
- package/dist/chunk-SZNEXFUZ.js +3 -0
- package/dist/chunk-XK52GUFA.js +3 -0
- package/dist/hooks/useIntersectionObserver.d.ts +2 -1
- package/dist/hooks/useIntersectionObserver.d.ts.map +1 -1
- package/dist/hooks/useIntersectionObserver.js +6 -7
- package/dist/index.js +10 -10
- package/dist/styles/index.css +316 -51
- package/dist/symbol-index.json +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/sanitizeDom.browser.d.ts +8 -0
- package/dist/utils/sanitizeDom.browser.d.ts.map +1 -0
- package/dist/utils/sanitizeDom.browser.js +1 -0
- package/dist/utils/sanitizeDom.server.d.ts +9 -0
- package/dist/utils/sanitizeDom.server.d.ts.map +1 -0
- package/dist/utils/sanitizeDom.server.js +1 -0
- package/dist/utils/sanitizeHtml.d.ts.map +1 -1
- package/dist/utils/sanitizeHtml.js +7 -6
- package/dist/utils/variants.d.ts +1 -1
- package/guidelines/API_REFERENCE.md +3 -2
- package/guidelines/COMPONENTS.md +10 -5
- package/guidelines/QUANTITY_STEPPER.md +78 -0
- package/guidelines/SWIPE_ACTION.md +101 -0
- package/package.json +8 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
// packages/components/src/atomic/QuantityStepper/index.tsx
|
|
4
4
|
/**
|
|
5
5
|
* @fileoverview QuantityStepper component
|
|
@@ -9,15 +9,28 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
9
9
|
* @since 0.1.50
|
|
10
10
|
* @author AMBROISE PARK Consulting
|
|
11
11
|
*/
|
|
12
|
+
import { useEffect, useRef, useState } from 'react';
|
|
12
13
|
import { Minus, Plus } from 'lucide-react';
|
|
13
14
|
import { cn } from '../../utils/helpers';
|
|
14
|
-
import
|
|
15
|
+
import { moveQuantity, normalizeQuantity, quantityRules } from './quantity';
|
|
15
16
|
import './QuantityStepper.css';
|
|
17
|
+
/** Press-and-hold: delay before the first repeat, then the repeat interval (halved after 5 repeats, quartered after 15). */
|
|
18
|
+
const HOLD_DELAY_MS = 400;
|
|
19
|
+
const HOLD_REPEAT_MS = 150;
|
|
20
|
+
/** Restore both visual and accessible state after a commit, cancellation, or parent update. */
|
|
21
|
+
function restoreEditor(input, value) {
|
|
22
|
+
if (!input)
|
|
23
|
+
return;
|
|
24
|
+
input.value = String(value);
|
|
25
|
+
input.setAttribute('aria-valuenow', String(value));
|
|
26
|
+
input.removeAttribute('aria-invalid');
|
|
27
|
+
}
|
|
16
28
|
/**
|
|
17
29
|
* Quantity control in the e-commerce standard form: one outlined field, borderless
|
|
18
30
|
* − / + buttons, the quantity centred with tabular figures. Stateless: the caller owns
|
|
19
|
-
* the value
|
|
20
|
-
*
|
|
31
|
+
* the value. Legacy mode uses direction callbacks; additive onChange mode owns lot
|
|
32
|
+
* normalization and offers an uncontrolled text spinbutton committed on blur/Enter.
|
|
33
|
+
* onChange takes precedence over the legacy direction and value-click callbacks.
|
|
21
34
|
*
|
|
22
35
|
* @component
|
|
23
36
|
* @example
|
|
@@ -32,5 +45,195 @@ import './QuantityStepper.css';
|
|
|
32
45
|
* />
|
|
33
46
|
* ```
|
|
34
47
|
*/
|
|
35
|
-
const QuantityStepper = ({ value, onDecrement, onIncrement, onValueClick,
|
|
48
|
+
const QuantityStepper = ({ value, onDecrement, onIncrement, onValueClick, onChange, min = 1, step = 1, max, allowZero = false, collapseWhenZero = false, vertical = false, disabled = false, fullWidth = false, decrementLabel, incrementLabel, valueLabel, className, onBlur, ...props }) => {
|
|
49
|
+
const inputRef = useRef(null);
|
|
50
|
+
const plusRef = useRef(null);
|
|
51
|
+
const groupRef = useRef(null);
|
|
52
|
+
const [editing, setEditing] = useState(false);
|
|
53
|
+
const collapsed = collapseWhenZero && value === 0;
|
|
54
|
+
const rules = onChange ? quantityRules(min, step, max, allowZero) : undefined;
|
|
55
|
+
if (rules && (!Number.isSafeInteger(value) || value < 0 || (value !== 0 && (value < rules.min || value > rules.max || (value - rules.min) % rules.step !== 0)))) {
|
|
56
|
+
throw new RangeError('QuantityStepper value must be zero or a complete lot within its bounds.');
|
|
57
|
+
}
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
restoreEditor(inputRef.current, value);
|
|
60
|
+
}, [value, min, step, max, allowZero, onChange !== undefined]);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
const group = groupRef.current;
|
|
63
|
+
const active = group?.ownerDocument.activeElement;
|
|
64
|
+
if (collapsed && active && group?.contains(active) && active !== plusRef.current) {
|
|
65
|
+
plusRef.current?.focus();
|
|
66
|
+
}
|
|
67
|
+
}, [collapsed]);
|
|
68
|
+
// Press-and-hold repeat. Editable mode steps a DOM draft and commits once on release
|
|
69
|
+
// (one parent update, not one save per tick); legacy mode calls its callback per tick.
|
|
70
|
+
const hold = useRef(null);
|
|
71
|
+
const suppressClick = useRef(false);
|
|
72
|
+
const legacy = useRef({ onIncrement, onDecrement });
|
|
73
|
+
legacy.current = { onIncrement, onDecrement };
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (disabled && hold.current) {
|
|
76
|
+
clearTimeout(hold.current.timer);
|
|
77
|
+
hold.current = null;
|
|
78
|
+
}
|
|
79
|
+
}, [disabled]);
|
|
80
|
+
useEffect(() => () => {
|
|
81
|
+
if (hold.current)
|
|
82
|
+
clearTimeout(hold.current.timer);
|
|
83
|
+
}, []);
|
|
84
|
+
const change = (next) => {
|
|
85
|
+
restoreEditor(inputRef.current, value);
|
|
86
|
+
if (!disabled && next !== value)
|
|
87
|
+
onChange?.(next);
|
|
88
|
+
};
|
|
89
|
+
const commit = (input) => {
|
|
90
|
+
if (!rules || disabled || collapsed || input.value === String(value))
|
|
91
|
+
return;
|
|
92
|
+
const next = normalizeQuantity(input.value, rules);
|
|
93
|
+
restoreEditor(input, value);
|
|
94
|
+
if (next !== undefined)
|
|
95
|
+
change(next);
|
|
96
|
+
};
|
|
97
|
+
// Cancel pointer focus until click has consumed the draft. Focusing the button
|
|
98
|
+
// afterwards closes a touch keyboard without ever focusing the editor on tap.
|
|
99
|
+
const prepareStep = (event) => {
|
|
100
|
+
if (rules && event.button === 0 && !event.currentTarget.disabled)
|
|
101
|
+
event.preventDefault();
|
|
102
|
+
};
|
|
103
|
+
const draftBase = () => {
|
|
104
|
+
const draft = inputRef.current?.value;
|
|
105
|
+
return !rules || draft === undefined || draft === String(value) ? value : normalizeQuantity(draft, rules) ?? value;
|
|
106
|
+
};
|
|
107
|
+
const stepQuantity = (direction) => {
|
|
108
|
+
if (!rules || disabled)
|
|
109
|
+
return;
|
|
110
|
+
change(moveQuantity(draftBase(), direction, 1, rules));
|
|
111
|
+
};
|
|
112
|
+
const startHold = (direction, event) => {
|
|
113
|
+
prepareStep(event);
|
|
114
|
+
if (event.button !== 0 || event.currentTarget.disabled || disabled)
|
|
115
|
+
return;
|
|
116
|
+
if (hold.current)
|
|
117
|
+
clearTimeout(hold.current.timer);
|
|
118
|
+
suppressClick.current = false;
|
|
119
|
+
const tick = () => {
|
|
120
|
+
const state = hold.current;
|
|
121
|
+
if (!state)
|
|
122
|
+
return;
|
|
123
|
+
if (rules) {
|
|
124
|
+
const next = moveQuantity(state.draft, direction, 1, rules);
|
|
125
|
+
if (next === state.draft)
|
|
126
|
+
return; // bound reached: wait for release
|
|
127
|
+
state.draft = next;
|
|
128
|
+
restoreEditor(inputRef.current, next);
|
|
129
|
+
groupRef.current?.removeAttribute('data-collapsed');
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
const callback = direction === 1 ? legacy.current.onIncrement : legacy.current.onDecrement;
|
|
133
|
+
if (!callback)
|
|
134
|
+
return;
|
|
135
|
+
callback();
|
|
136
|
+
}
|
|
137
|
+
suppressClick.current = true;
|
|
138
|
+
state.ticks += 1;
|
|
139
|
+
state.timer = setTimeout(tick, state.ticks < 5 ? HOLD_REPEAT_MS : state.ticks < 15 ? HOLD_REPEAT_MS / 2 : HOLD_REPEAT_MS / 4);
|
|
140
|
+
};
|
|
141
|
+
hold.current = { timer: setTimeout(tick, HOLD_DELAY_MS), draft: draftBase(), ticks: 0 };
|
|
142
|
+
};
|
|
143
|
+
const endHold = () => {
|
|
144
|
+
const state = hold.current;
|
|
145
|
+
if (!state)
|
|
146
|
+
return;
|
|
147
|
+
clearTimeout(state.timer);
|
|
148
|
+
hold.current = null;
|
|
149
|
+
if (rules && state.ticks > 0)
|
|
150
|
+
change(state.draft);
|
|
151
|
+
};
|
|
152
|
+
const holdHandlers = (direction) => ({
|
|
153
|
+
onPointerDown: (event) => startHold(direction, event),
|
|
154
|
+
onPointerUp: endHold,
|
|
155
|
+
onPointerLeave: endHold,
|
|
156
|
+
onPointerCancel: endHold,
|
|
157
|
+
// Long-press must not open the touch context menu.
|
|
158
|
+
onContextMenu: (event) => event.preventDefault(),
|
|
159
|
+
});
|
|
160
|
+
/** A click after a repeating hold was already applied by the hold. */
|
|
161
|
+
const consumedByHold = () => {
|
|
162
|
+
const consumed = suppressClick.current;
|
|
163
|
+
suppressClick.current = false;
|
|
164
|
+
return consumed;
|
|
165
|
+
};
|
|
166
|
+
const decrement = (_jsx("button", { type: "button", className: "dndev-quantity-stepper-decrement", "aria-label": decrementLabel, "aria-hidden": collapsed || undefined, tabIndex: collapsed ? -1 : undefined, disabled: disabled || (rules ? (!editing || collapsed) && value <= (allowZero ? 0 : min) : !onDecrement), ...holdHandlers(-1), onClick: (event) => {
|
|
167
|
+
if (consumedByHold())
|
|
168
|
+
event.currentTarget.focus();
|
|
169
|
+
else if (rules) {
|
|
170
|
+
stepQuantity(-1);
|
|
171
|
+
event.currentTarget.focus();
|
|
172
|
+
}
|
|
173
|
+
else
|
|
174
|
+
onDecrement?.();
|
|
175
|
+
}, children: _jsx(Minus, { "aria-hidden": "true", focusable: "false" }) }, "minus"));
|
|
176
|
+
const increment = (_jsx("button", { ref: plusRef, type: "button", className: "dndev-quantity-stepper-increment", "aria-label": incrementLabel, disabled: disabled || (rules ? !editing && value >= rules.max : !onIncrement), ...holdHandlers(1), onClick: (event) => {
|
|
177
|
+
if (consumedByHold())
|
|
178
|
+
event.currentTarget.focus();
|
|
179
|
+
else if (rules) {
|
|
180
|
+
stepQuantity(1);
|
|
181
|
+
event.currentTarget.focus();
|
|
182
|
+
}
|
|
183
|
+
else
|
|
184
|
+
onIncrement?.();
|
|
185
|
+
}, children: _jsx(Plus, { "aria-hidden": "true", focusable: "false" }) }, "plus"));
|
|
186
|
+
const quantity = onChange ? (_jsx("input", { ref: inputRef, className: "dndev-quantity-stepper-value", type: "text", inputMode: "numeric", enterKeyHint: "done", autoComplete: "off", spellCheck: false, pattern: "[0-9]*", role: "spinbutton", "aria-label": valueLabel ?? props['aria-label'], "aria-valuemin": allowZero || value === 0 ? 0 : min, "aria-valuemax": rules?.max, "aria-valuenow": value, "aria-hidden": collapsed || undefined, tabIndex: collapsed ? -1 : undefined, disabled: disabled, defaultValue: value, onFocus: (event) => {
|
|
187
|
+
setEditing(true);
|
|
188
|
+
event.currentTarget.select();
|
|
189
|
+
}, onInput: (event) => {
|
|
190
|
+
if (!rules || disabled || collapsed)
|
|
191
|
+
return;
|
|
192
|
+
const input = event.currentTarget;
|
|
193
|
+
const text = input.value.trim();
|
|
194
|
+
const draft = Number(text);
|
|
195
|
+
const numeric = /^\d+$/.test(text) && Number.isSafeInteger(draft);
|
|
196
|
+
if (numeric)
|
|
197
|
+
input.setAttribute('aria-valuenow', String(draft));
|
|
198
|
+
else
|
|
199
|
+
input.removeAttribute('aria-valuenow');
|
|
200
|
+
const valid = numeric && (draft === 0 ? allowZero || value === 0
|
|
201
|
+
: draft >= rules.min && draft <= rules.max && (draft - rules.min) % rules.step === 0);
|
|
202
|
+
if (valid)
|
|
203
|
+
input.removeAttribute('aria-invalid');
|
|
204
|
+
else
|
|
205
|
+
input.setAttribute('aria-invalid', 'true');
|
|
206
|
+
}, onKeyDown: (event) => {
|
|
207
|
+
if (event.nativeEvent.isComposing || event.altKey || event.ctrlKey || event.metaKey || !rules)
|
|
208
|
+
return;
|
|
209
|
+
const input = event.currentTarget;
|
|
210
|
+
if (event.key === 'Escape') {
|
|
211
|
+
event.preventDefault();
|
|
212
|
+
restoreEditor(input, value);
|
|
213
|
+
}
|
|
214
|
+
else if (event.key === 'Enter') {
|
|
215
|
+
event.preventDefault();
|
|
216
|
+
commit(input);
|
|
217
|
+
}
|
|
218
|
+
else if (['ArrowUp', 'ArrowDown', 'PageUp', 'PageDown', 'Home', 'End'].includes(event.key)) {
|
|
219
|
+
event.preventDefault();
|
|
220
|
+
const base = input.value === String(value) ? value : normalizeQuantity(input.value, rules) ?? value;
|
|
221
|
+
const next = event.key === 'Home' ? (allowZero ? 0 : min)
|
|
222
|
+
: event.key === 'End' ? rules.max
|
|
223
|
+
: moveQuantity(base, event.key === 'ArrowDown' || event.key === 'PageDown' ? -1 : 1, event.key.startsWith('Page') ? 10 : 1, rules);
|
|
224
|
+
change(next);
|
|
225
|
+
}
|
|
226
|
+
} }, "quantity")) : onValueClick ? (_jsx("button", { type: "button", className: "dndev-quantity-stepper-value", "aria-label": valueLabel, "aria-hidden": collapsed || undefined, tabIndex: collapsed ? -1 : undefined, disabled: disabled, onClick: onValueClick, children: value }, "quantity")) : (_jsx("output", { className: "dndev-quantity-stepper-value", "aria-live": "polite", "aria-hidden": collapsed || undefined, children: value }, "quantity"));
|
|
227
|
+
return (_jsx("div", { ...props, ref: groupRef, role: "group", onBlur: (event) => {
|
|
228
|
+
// Tabbing to a step button must preserve the draft for its activation.
|
|
229
|
+
// Leaving the group commits it once, including when focus left the input
|
|
230
|
+
// for a button first. Enter/step already reset the DOM to controlled value.
|
|
231
|
+
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
232
|
+
setEditing(false);
|
|
233
|
+
if (inputRef.current)
|
|
234
|
+
commit(inputRef.current);
|
|
235
|
+
}
|
|
236
|
+
onBlur?.(event);
|
|
237
|
+
}, className: cn('dndev-quantity-stepper', className), "data-full-width": fullWidth || undefined, "data-disabled": disabled || undefined, "data-collapsed": collapsed || undefined, "data-vertical": vertical || undefined, children: vertical ? [increment, quantity, decrement] : [decrement, quantity, increment] }));
|
|
238
|
+
};
|
|
36
239
|
export default QuantityStepper;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Integer lot constraints for editable quantities. */
|
|
2
|
+
export interface QuantityRules {
|
|
3
|
+
min: number;
|
|
4
|
+
step: number;
|
|
5
|
+
max: number;
|
|
6
|
+
allowZero: boolean;
|
|
7
|
+
}
|
|
8
|
+
/** Validate configuration and compute the largest complete lot below max. */
|
|
9
|
+
export declare function quantityRules(min?: number, step?: number, max?: number, allowZero?: boolean): QuantityRules;
|
|
10
|
+
/** Parse decimal integers only; align upwards to a lot, then clamp to complete lots. */
|
|
11
|
+
export declare function normalizeQuantity(text: string, rules: QuantityRules): number | undefined;
|
|
12
|
+
/** Move through complete lots, including the optional zero sentinel. */
|
|
13
|
+
export declare function moveQuantity(value: number, direction: -1 | 1, count: number, rules: QuantityRules): number;
|
|
14
|
+
//# sourceMappingURL=quantity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quantity.d.ts","sourceRoot":"","sources":["../../../src/atomic/QuantityStepper/quantity.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,6EAA6E;AAC7E,wBAAgB,aAAa,CAAC,GAAG,SAAI,EAAE,IAAI,SAAI,EAAE,GAAG,SAA0B,EAAE,SAAS,UAAQ,GAAG,aAAa,CAKhH;AAED,wFAAwF;AACxF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAQxF;AAED,wEAAwE;AACxE,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,MAAM,CAQ1G"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Validate configuration and compute the largest complete lot below max. */
|
|
2
|
+
export function quantityRules(min = 1, step = 1, max = Number.MAX_SAFE_INTEGER, allowZero = false) {
|
|
3
|
+
if (!Number.isSafeInteger(min) || min < 1 || !Number.isSafeInteger(step) || step < 1 || !Number.isSafeInteger(max) || max < min) {
|
|
4
|
+
throw new RangeError('QuantityStepper requires positive safe integer min/step and a safe integer max >= min.');
|
|
5
|
+
}
|
|
6
|
+
return { min, step, max: min + Math.floor((max - min) / step) * step, allowZero };
|
|
7
|
+
}
|
|
8
|
+
/** Parse decimal integers only; align upwards to a lot, then clamp to complete lots. */
|
|
9
|
+
export function normalizeQuantity(text, rules) {
|
|
10
|
+
if (!/^\d+$/.test(text.trim()))
|
|
11
|
+
return undefined;
|
|
12
|
+
const value = Number(text.trim());
|
|
13
|
+
if (!Number.isSafeInteger(value))
|
|
14
|
+
return undefined;
|
|
15
|
+
if (value === 0 && rules.allowZero)
|
|
16
|
+
return 0;
|
|
17
|
+
if (value <= rules.min)
|
|
18
|
+
return rules.min;
|
|
19
|
+
if (value >= rules.max)
|
|
20
|
+
return rules.max;
|
|
21
|
+
return Math.min(rules.max, rules.min + Math.ceil((value - rules.min) / rules.step) * rules.step);
|
|
22
|
+
}
|
|
23
|
+
/** Move through complete lots, including the optional zero sentinel. */
|
|
24
|
+
export function moveQuantity(value, direction, count, rules) {
|
|
25
|
+
if (value === 0 && direction === -1)
|
|
26
|
+
return 0;
|
|
27
|
+
if (direction === -1 && value <= rules.min)
|
|
28
|
+
return rules.allowZero ? 0 : rules.min;
|
|
29
|
+
const base = value === 0 ? rules.min : value;
|
|
30
|
+
const distance = Math.min(count, Math.floor(Number.MAX_SAFE_INTEGER / rules.step)) * rules.step;
|
|
31
|
+
if (direction === 1)
|
|
32
|
+
return value === 0 ? rules.min : base + Math.min(distance, rules.max - base);
|
|
33
|
+
const next = base - Math.min(distance, base - rules.min);
|
|
34
|
+
return next === rules.min && count > (base - rules.min) / rules.step && rules.allowZero ? 0 : next;
|
|
35
|
+
}
|
|
@@ -4,6 +4,8 @@ import './RangeInput.css';
|
|
|
4
4
|
export interface RangeInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'value'> {
|
|
5
5
|
/** Label for the range (single FloatingLabel wrapping both inputs) */
|
|
6
6
|
label?: string;
|
|
7
|
+
/** Help text: an (i) after the label shows it on hover, focus or tap. Needs `label`. */
|
|
8
|
+
info?: string;
|
|
7
9
|
/** Placeholder for min input */
|
|
8
10
|
minPlaceholder?: string;
|
|
9
11
|
/** Placeholder for max input */
|
|
@@ -41,6 +43,6 @@ export interface RangeInputProps extends Omit<InputHTMLAttributes<HTMLInputEleme
|
|
|
41
43
|
* />
|
|
42
44
|
* ```
|
|
43
45
|
*/
|
|
44
|
-
export declare function RangeInput({ type, label, minPlaceholder, maxPlaceholder, minValue, maxValue, actualMin, actualMax, min, max, onChange, onClear, ...props }: RangeInputProps): import("react").JSX.Element;
|
|
46
|
+
export declare function RangeInput({ type, label, info, minPlaceholder, maxPlaceholder, minValue, maxValue, actualMin, actualMax, min, max, onChange, onClear, ...props }: RangeInputProps): import("react").JSX.Element;
|
|
45
47
|
export default RangeInput;
|
|
46
48
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/RangeInput/index.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAMjD,OAAO,kBAAkB,CAAC;AAE1B,gFAAgF;AAChF,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAC3C,mBAAmB,CAAC,gBAAgB,CAAC,EACrC,UAAU,GAAG,OAAO,CACrB;IACC,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gCAAgC;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wBAAwB;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wBAAwB;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,8DAA8D;IAC9D,SAAS,CAAC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AAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,wDAAwD;IACxD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,UAAU,CAAC,EACzB,IAAe,EACf,KAAK,EACL,IAAI,EACJ,cAAsB,EACtB,cAAsB,EACtB,QAAa,EACb,QAAa,EACb,SAAS,EACT,SAAS,EACT,GAAG,EACH,GAAG,EACH,QAAQ,EACR,OAAO,EACP,GAAG,KAAK,EACT,EAAE,eAAe,+BA+EjB;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -33,7 +33,7 @@ import './RangeInput.css';
|
|
|
33
33
|
* />
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
|
-
export function RangeInput({ type = 'number', label, minPlaceholder = 'Min', maxPlaceholder = 'Max', minValue = '', maxValue = '', actualMin, actualMax, min, max, onChange, onClear, ...props }) {
|
|
36
|
+
export function RangeInput({ type = 'number', label, info, minPlaceholder = 'Min', maxPlaceholder = 'Max', minValue = '', maxValue = '', actualMin, actualMax, min, max, onChange, onClear, ...props }) {
|
|
37
37
|
const handleMinFocus = (e) => {
|
|
38
38
|
e.target.select();
|
|
39
39
|
if (!minValue &&
|
|
@@ -55,7 +55,7 @@ export function RangeInput({ type = 'number', label, minPlaceholder = 'Min', max
|
|
|
55
55
|
const hasValue = !!(minValue || maxValue);
|
|
56
56
|
const inputs = (_jsxs(_Fragment, { children: [_jsx(Input, { type: type, placeholder: minPlaceholder, value: minValue, min: min, max: max, bare: true, onFocus: handleMinFocus, onChange: (e) => onChange(e.target.value, maxValue), ...props }), _jsx(Text, { level: "small", variant: "muted", className: "dndev-range-input-separator", children: "\u2013" }), _jsx(Input, { type: type, placeholder: maxPlaceholder, value: maxValue, min: min, max: max, bare: true, onFocus: handleMaxFocus, onChange: (e) => onChange(minValue, e.target.value), ...props }), _jsx("button", { type: "button", className: "dndev-inline-action-btn dndev-range-input-clear", onClick: onClear, disabled: !hasValue, "aria-label": "Clear", children: _jsx(X, {}) })] }));
|
|
57
57
|
if (label) {
|
|
58
|
-
return (_jsx(FloatingLabel, { label: label, children: _jsx("div", { className: "dndev-range-input", children: inputs }) }));
|
|
58
|
+
return (_jsx(FloatingLabel, { label: label, info: info, children: _jsx("div", { className: "dndev-range-input", children: inputs }) }));
|
|
59
59
|
}
|
|
60
60
|
return _jsx("div", { className: "dndev-range-input", children: inputs });
|
|
61
61
|
}
|
|
@@ -12,7 +12,7 @@ import type { HTMLAttributes } from 'react';
|
|
|
12
12
|
import { CONTROL_VARIANT, type ControlVariant } from '../../utils/constants';
|
|
13
13
|
import './Rating.css';
|
|
14
14
|
declare const ratingVariants: (props?: ({
|
|
15
|
-
variant?: "default" | "muted" | "
|
|
15
|
+
variant?: "default" | "muted" | "primary" | "secondary" | "accent" | "success" | "warning" | "destructive" | null | undefined;
|
|
16
16
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
17
17
|
/** Props for the Rating component -- star-based rating input/display. */
|
|
18
18
|
export interface RatingProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'>, VariantProps<typeof ratingVariants> {
|
|
@@ -35,6 +35,8 @@ export interface SelectProps extends Omit<ComponentProps<typeof SelectPrimitive>
|
|
|
35
35
|
isLoading?: boolean;
|
|
36
36
|
/** Label for floating label - automatically floats when both label and placeholder are provided */
|
|
37
37
|
label?: string;
|
|
38
|
+
/** Help text: an (i) after the label shows it on hover, focus or tap. Needs `label`. */
|
|
39
|
+
info?: string;
|
|
38
40
|
/** Whether the field is required - shows asterisk indicator */
|
|
39
41
|
required?: boolean;
|
|
40
42
|
}
|
|
@@ -58,6 +60,6 @@ export interface SelectProps extends Omit<ComponentProps<typeof SelectPrimitive>
|
|
|
58
60
|
* @param {SelectProps} props - The props for the select
|
|
59
61
|
* @returns {JSX.Element} The rendered select
|
|
60
62
|
*/
|
|
61
|
-
declare const Select: ({ value, onValueChange, placeholder, options, trigger, disabled, isLoading, defaultValue, label, required, ...props }: SelectProps) => import("react").JSX.Element;
|
|
63
|
+
declare const Select: ({ value, onValueChange, placeholder, options, trigger, disabled, isLoading, defaultValue, label, info, required, ...props }: SelectProps) => import("react").JSX.Element;
|
|
62
64
|
export default Select;
|
|
63
65
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/Select/index.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAKvD,OAAO,EACL,eAAe,EAOhB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,cAAc,CAAC;AAEtB,4FAA4F;AAC5F,eAAO,MAAM,kBAAkB,EAAG,WAAoB,CAAC;AAEvD,iGAAiG;AACjG,eAAO,MAAM,sBAAsB,EAAG,eAAwB,CAAC;AAE/D,8CAA8C;AAC9C,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB;AAED,sCAAsC;AACtC,MAAM,WAAW,WAAY,SAAQ,IAAI,CACvC,cAAc,CAAC,OAAO,eAAe,CAAC,EACtC,UAAU,CACX;IACC,qBAAqB;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,uBAAuB;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uBAAuB;IACvB,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,6BAA6B;IAC7B,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,qCAAqC;IACrC,QAAQ,CAAC,EAAE,OAAO,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C,EAAE,OAAO,CAAC;IACnB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mGAAmG;IACnG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wFAAwF;IACxF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,QAAA,MAAM,MAAM,GAAI,6HAab,WAAW,gCAwHb,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -40,11 +40,11 @@ export const SELECT_SEPARATOR_VALUE = '__separator__';
|
|
|
40
40
|
* @param {SelectProps} props - The props for the select
|
|
41
41
|
* @returns {JSX.Element} The rendered select
|
|
42
42
|
*/
|
|
43
|
-
const Select = ({ value, onValueChange, placeholder = 'Select an option...', options = [], trigger, disabled, isLoading, defaultValue, label, required, ...props }) => {
|
|
43
|
+
const Select = ({ value, onValueChange, placeholder = 'Select an option...', options = [], trigger, disabled, isLoading, defaultValue, label, info, required, ...props }) => {
|
|
44
44
|
const id = useId();
|
|
45
45
|
const hasLabel = !!label;
|
|
46
46
|
const triggerElement = (_jsxs(SelectTriggerPrimitive, { id: id, className: "dndev-input dndev-select-trigger", disabled: disabled, "data-bare": hasLabel || undefined, children: [isLoading ? (_jsxs("div", { className: "dndev-select-loading-container", children: [_jsx("div", { className: "dndev-animate-spin dndev-select-loading-spinner" }), _jsx("span", { children: "Loading..." })] })) : (_jsx(SelectValuePrimitive, { placeholder: placeholder })), _jsx(SelectRadix.Icon, { asChild: true, children: _jsx(ChevronDown, {}) })] }));
|
|
47
|
-
const customTrigger = trigger ? (_jsx(SelectTriggerPrimitive, { asChild: true, disabled: disabled, className: "dndev-input dndev-select-trigger", children: trigger })) : hasLabel ? (_jsx(FloatingLabel, { htmlFor: id, label: label, disabled: disabled, required: required, children: triggerElement })) : (triggerElement);
|
|
47
|
+
const customTrigger = trigger ? (_jsx(SelectTriggerPrimitive, { asChild: true, disabled: disabled, className: "dndev-input dndev-select-trigger", children: trigger })) : hasLabel ? (_jsx(FloatingLabel, { htmlFor: id, label: label, info: info, disabled: disabled, required: required, children: triggerElement })) : (triggerElement);
|
|
48
48
|
return (_jsxs(SelectPrimitive, { value: value, onValueChange: onValueChange, defaultValue: defaultValue, disabled: disabled, ...props, children: [customTrigger, _jsx(SelectRadix.Portal, { children: _jsx(SelectContentPrimitive, { className: "dndev-floating dndev-menu-content dndev-z-tooltip dndev-select-content", position: "popper", side: "bottom", sideOffset: 4, align: "start", "data-glow": "blank", children: _jsx(SelectRadix.Viewport, { children: _jsx(ScrollArea, { className: "dndev-menu-scroll-area", end: true, children: options.map((option) => {
|
|
49
49
|
if (option.value === SELECT_LABEL_VALUE) {
|
|
50
50
|
return (_jsx(SelectLabelPrimitive, { className: "dndev-menu-label", children: option.label }, option.label));
|
|
@@ -21,7 +21,7 @@ export interface StepperStep {
|
|
|
21
21
|
content: ReactNode;
|
|
22
22
|
}
|
|
23
23
|
declare const stepperVariants: (props?: ({
|
|
24
|
-
variant?: "
|
|
24
|
+
variant?: "muted" | "primary" | "secondary" | "accent" | "default" | "success" | "warning" | "destructive" | null | undefined;
|
|
25
25
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
26
26
|
/** Union of available Stepper variant values. */
|
|
27
27
|
export type StepperVariant = VariantProps<typeof stepperVariants>['variant'];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Clamp physical movement to the trailing action, respecting inline direction. */
|
|
2
|
+
export declare function swipeProgress(deltaX: number, rtl: boolean, width: number, opened: boolean): number;
|
|
3
|
+
/** Require deliberate horizontal movement before taking over a pointer. */
|
|
4
|
+
export declare function swipeAxis(deltaX: number, deltaY: number): 'pending' | 'horizontal' | 'vertical';
|
|
5
|
+
//# sourceMappingURL=gesture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gesture.d.ts","sourceRoot":"","sources":["../../../src/atomic/SwipeAction/gesture.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,CAElG;AAED,2EAA2E;AAC3E,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,YAAY,GAAG,UAAU,CAG/F"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Clamp physical movement to the trailing action, respecting inline direction. */
|
|
2
|
+
export function swipeProgress(deltaX, rtl, width, opened) {
|
|
3
|
+
return Math.min(width, Math.max(0, (opened ? width : 0) + deltaX * (rtl ? 1 : -1)));
|
|
4
|
+
}
|
|
5
|
+
/** Require deliberate horizontal movement before taking over a pointer. */
|
|
6
|
+
export function swipeAxis(deltaX, deltaY) {
|
|
7
|
+
if (Math.max(Math.abs(deltaX), Math.abs(deltaY)) < 8)
|
|
8
|
+
return 'pending';
|
|
9
|
+
return Math.abs(deltaX) > Math.abs(deltaY) ? 'horizontal' : 'vertical';
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import './SwipeAction.css';
|
|
3
|
+
/** A trailing destructive action revealed by a touch swipe. */
|
|
4
|
+
export interface SwipeActionProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onAction'> {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
onAction: () => void;
|
|
7
|
+
actionLabel: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** Native scrolling only reveals; destruction requires explicit button activation. */
|
|
11
|
+
export default function SwipeAction({ children, onAction, actionLabel, disabled, className, onKeyDown, ...props }: SwipeActionProps): import("react").JSX.Element;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/SwipeAction/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvD,OAAO,mBAAmB,CAAC;AAE3B,+DAA+D;AAC/D,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC;IACxF,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,sFAAsF;AACtF,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAgB,EACjD,SAAS,EAAE,SAAS,EAAE,GAAG,KAAK,EAC/B,EAAE,gBAAgB,+BAuFlB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Trash2 } from 'lucide-react';
|
|
4
|
+
import { useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { cn } from '../../utils/helpers';
|
|
6
|
+
import './SwipeAction.css';
|
|
7
|
+
/** Native scrolling only reveals; destruction requires explicit button activation. */
|
|
8
|
+
export default function SwipeAction({ children, onAction, actionLabel, disabled = false, className, onKeyDown, ...props }) {
|
|
9
|
+
const [open, setOpen] = useState(false);
|
|
10
|
+
const viewport = useRef(null);
|
|
11
|
+
const revealed = open && !disabled;
|
|
12
|
+
function reveal(next) {
|
|
13
|
+
const element = viewport.current;
|
|
14
|
+
if (!element)
|
|
15
|
+
return;
|
|
16
|
+
// Instant programmatic scrolling, independent of motion preferences and native snap animations.
|
|
17
|
+
element.scrollLeft = next
|
|
18
|
+
? (getComputedStyle(element).direction === 'rtl' ? -1 : 1) * (element.scrollWidth - element.clientWidth)
|
|
19
|
+
: 0;
|
|
20
|
+
setOpen(next);
|
|
21
|
+
}
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const element = viewport.current;
|
|
24
|
+
if (!element)
|
|
25
|
+
return;
|
|
26
|
+
// Trackpads/wheels are not a touch swipe, including on hybrid computers.
|
|
27
|
+
// Vertical wheel scrolling and browser zoom remain native.
|
|
28
|
+
const excludeWheel = (event) => {
|
|
29
|
+
if (!event.ctrlKey && (event.deltaX !== 0 || event.shiftKey) && event.cancelable)
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
};
|
|
32
|
+
element.addEventListener('wheel', excludeWheel, { passive: false });
|
|
33
|
+
return () => element.removeEventListener('wheel', excludeWheel);
|
|
34
|
+
}, []);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (disabled)
|
|
37
|
+
reveal(false);
|
|
38
|
+
}, [disabled]);
|
|
39
|
+
return (_jsx("div", { ...props, className: cn('dndev-swipe-action', className), "data-open": revealed ? '' : undefined, "data-disabled": disabled ? '' : undefined, onKeyDown: (event) => {
|
|
40
|
+
onKeyDown?.(event);
|
|
41
|
+
if (!event.defaultPrevented && event.key === 'Escape') {
|
|
42
|
+
const element = viewport.current;
|
|
43
|
+
if (revealed || (element && element.scrollLeft !== 0)) {
|
|
44
|
+
event.preventDefault();
|
|
45
|
+
reveal(false);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}, children: _jsxs("div", { ref: viewport, className: "dndev-swipe-action-viewport", onPointerDown: (event) => {
|
|
49
|
+
// Native mouse selection must not turn into a drag-to-reveal. Pen
|
|
50
|
+
// panning is excluded too; actual touch still works on hybrid devices.
|
|
51
|
+
event.currentTarget.toggleAttribute('data-input-blocked', event.pointerType !== 'touch');
|
|
52
|
+
}, onScroll: (event) => {
|
|
53
|
+
const element = event.currentTarget;
|
|
54
|
+
const end = element.scrollWidth - element.clientWidth;
|
|
55
|
+
setOpen(!disabled && end > 0 && Math.abs(element.scrollLeft) >= end - 1);
|
|
56
|
+
}, children: [_jsx("div", { className: "dndev-swipe-action-content", onFocusCapture: () => reveal(false), children: children }), _jsxs("button", { type: "button", className: "dndev-swipe-action-delete", "aria-hidden": !revealed, inert: !revealed, tabIndex: revealed ? 0 : -1, disabled: disabled || !revealed, onClick: () => {
|
|
57
|
+
if (!revealed || disabled)
|
|
58
|
+
return;
|
|
59
|
+
reveal(false);
|
|
60
|
+
onAction();
|
|
61
|
+
}, children: [_jsx(Trash2, { "aria-hidden": "true", focusable: "false" }), _jsx("span", { children: actionLabel })] })] }) }));
|
|
62
|
+
}
|
|
@@ -96,6 +96,8 @@ export interface EditCellProps extends EditCellHandlers {
|
|
|
96
96
|
position: CellPosition;
|
|
97
97
|
/** Accessible name, e.g. the column title. */
|
|
98
98
|
label: string;
|
|
99
|
+
/** Message of a rule the value breaks (`DataTable` `cellErrors`): marks it invalid. */
|
|
100
|
+
error?: string;
|
|
99
101
|
}
|
|
100
102
|
/**
|
|
101
103
|
* In-place cell editor. Uncontrolled: the DOM holds the text while typing; the
|
|
@@ -103,7 +105,7 @@ export interface EditCellProps extends EditCellHandlers {
|
|
|
103
105
|
* next row, ArrowUp previous row, Tab native, Esc restores the stored value,
|
|
104
106
|
* Ctrl/Cmd+Z undoes the last stored change once nothing is being typed.
|
|
105
107
|
*/
|
|
106
|
-
export declare function EditCell({ edit, value, position, label, commit, focusCell, pasteGrid, undo, }: EditCellProps): ReactElement;
|
|
108
|
+
export declare function EditCell({ edit, value, position, label, error, commit, focusCell, pasteGrid, undo, }: EditCellProps): ReactElement;
|
|
107
109
|
/** Focuses the editor at `position` inside `container`, if it exists. */
|
|
108
110
|
export declare function focusEditor(container: RefObject<HTMLElement | null>, position: CellPosition): void;
|
|
109
111
|
//# sourceMappingURL=editing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editing.d.ts","sourceRoot":"","sources":["../../../src/atomic/Table/editing.tsx"],"names":[],"mappings":"A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E,GAAG,IAAI,CAIlE;AAED,iDAAiD;AACjD,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAED,gDAAgD;AAChD,MAAM,WAAW,gBAAgB;IAC/B,gCAAgC;IAChC,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACjC,iFAAiF;IACjF,SAAS,EAAE,CAAC,QAAQ,EAAE,YAAY,KAAK,IAAI,CAAC;IAC5C,+CAA+C;IAC/C,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,IAAI,CAAC;IACtC,2DAA2D;IAC3D,IAAI,EAAE,MAAM,OAAO,CAAC;CACrB;AAED,iCAAiC;AACjC,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD,IAAI,EAAE,aAAa,CAAC;IACpB,wCAAwC;IACxC,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,YAAY,CAAC;IACvB,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,uFAAuF;IACvF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,KAAK,EACL,KAAK,EACL,MAAM,EACN,SAAS,EACT,SAAS,EACT,IAAI,GACL,EAAE,aAAa,GAAG,YAAY,CA2G9B;AAED,yEAAyE;AACzE,wBAAgB,WAAW,CACzB,SAAS,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EACxC,QAAQ,EAAE,YAAY,GACrB,IAAI,CAMN"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
// packages/components/src/atomic/Table/editing.tsx
|
|
3
3
|
/**
|
|
4
4
|
* @fileoverview DataTable cell editing
|
|
@@ -9,7 +9,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
9
9
|
* @since 0.2.3
|
|
10
10
|
* @author AMBROISE PARK Consulting
|
|
11
11
|
*/
|
|
12
|
-
import { useEffect, useRef } from 'react';
|
|
12
|
+
import { useEffect, useId, useRef } from 'react';
|
|
13
13
|
/** Defaults of {@link DataTableEditLabels}. */
|
|
14
14
|
export const DEFAULT_EDIT_LABELS = {
|
|
15
15
|
selected: '{{count}} selected',
|
|
@@ -97,10 +97,11 @@ export function parseClipboardGrid(text) {
|
|
|
97
97
|
* next row, ArrowUp previous row, Tab native, Esc restores the stored value,
|
|
98
98
|
* Ctrl/Cmd+Z undoes the last stored change once nothing is being typed.
|
|
99
99
|
*/
|
|
100
|
-
export function EditCell({ edit, value, position, label, commit, focusCell, pasteGrid, undo, }) {
|
|
100
|
+
export function EditCell({ edit, value, position, label, error, commit, focusCell, pasteGrid, undo, }) {
|
|
101
101
|
const ref = useRef(null);
|
|
102
|
+
const errorId = useId();
|
|
102
103
|
const stored = cellText(value);
|
|
103
|
-
const invalid = !isCellValueValid(value, edit);
|
|
104
|
+
const invalid = !isCellValueValid(value, edit) || !!error;
|
|
104
105
|
// Paste, bulk apply and undo change the stored value from outside: sync the DOM
|
|
105
106
|
useEffect(() => {
|
|
106
107
|
if (ref.current && ref.current.value !== stored) {
|
|
@@ -150,16 +151,18 @@ export function EditCell({ edit, value, position, label, commit, focusCell, past
|
|
|
150
151
|
className: 'dndev-table-cell-editor',
|
|
151
152
|
'aria-label': label,
|
|
152
153
|
'aria-invalid': invalid || undefined,
|
|
154
|
+
'aria-describedby': error ? errorId : undefined,
|
|
153
155
|
'data-edit-row': position.row,
|
|
154
156
|
'data-edit-col': position.col,
|
|
155
157
|
onKeyDown,
|
|
156
158
|
onPaste,
|
|
157
159
|
};
|
|
160
|
+
const message = error ? (_jsx("span", { id: errorId, className: "dndev-table-cell-error", children: error })) : null;
|
|
158
161
|
if (edit.type === 'select') {
|
|
159
162
|
const known = edit.options?.some((o) => o.value === stored);
|
|
160
|
-
return (_jsxs("select", { ref: ref, ...common, defaultValue: stored, onChange: (e) => store(e.target.value), children: [_jsx("option", { value: "" }), !known && stored !== '' && _jsx("option", { value: stored, children: stored }), edit.options?.map((o) => (_jsx("option", { value: o.value, children: o.label }, o.value)))] }));
|
|
163
|
+
return (_jsxs(_Fragment, { children: [_jsxs("select", { ref: ref, ...common, defaultValue: stored, onChange: (e) => store(e.target.value), children: [_jsx("option", { value: "" }), !known && stored !== '' && _jsx("option", { value: stored, children: stored }), edit.options?.map((o) => (_jsx("option", { value: o.value, children: o.label }, o.value)))] }), message] }));
|
|
161
164
|
}
|
|
162
|
-
return (_jsx("input", { ref: ref, ...common, type: "text", inputMode: edit.type === 'number' ? 'decimal' : undefined, defaultValue: stored, onBlur: (e) => store(e.target.value) }));
|
|
165
|
+
return (_jsxs(_Fragment, { children: [_jsx("input", { ref: ref, ...common, type: "text", inputMode: edit.type === 'number' ? 'decimal' : undefined, defaultValue: stored, onBlur: (e) => store(e.target.value) }), message] }));
|
|
163
166
|
}
|
|
164
167
|
/** Focuses the editor at `position` inside `container`, if it exists. */
|
|
165
168
|
export function focusEditor(container, position) {
|
|
@@ -159,6 +159,14 @@ export interface DataTableProps<T = unknown> {
|
|
|
159
159
|
onRowOpen?: (row: T) => void;
|
|
160
160
|
/** Accessible label of the open cell (translated by the consumer). Required with `getRowHref` / `onRowOpen`. */
|
|
161
161
|
openLabel?: string;
|
|
162
|
+
/**
|
|
163
|
+
* Invalid cells: `cellErrors[rowId][columnKey]` = message (translated by the
|
|
164
|
+
* consumer), e.g. the rules a pending value breaks. Marked like a value that
|
|
165
|
+
* does not parse (`data-invalid`), editors get `aria-invalid` and the message
|
|
166
|
+
* (shown under the value, linked with `aria-describedby`). Requires `getRowId`.
|
|
167
|
+
* @since 0.2.5
|
|
168
|
+
*/
|
|
169
|
+
cellErrors?: Record<string, Record<string, string>>;
|
|
162
170
|
}
|
|
163
171
|
/**
|
|
164
172
|
* Basic Table wrapper component.
|
|
@@ -220,7 +228,7 @@ declare function TableCaption({ className, ...props }: HTMLAttributes<HTMLTableC
|
|
|
220
228
|
* @param {DataTableProps} props - The props for the data table
|
|
221
229
|
* @returns {ReactNode} The rendered data table
|
|
222
230
|
*/
|
|
223
|
-
declare const DataTable: <T = unknown>({ data, columns, sortable, selectable, searchable, pagination, currentPage: currentPageProp, pageSize: pageSizeProp, total: totalProp, onPageChange, onPageSizeChange, showingLabel, paginationPreviousLabel, paginationNextLabel, paginationItemsPerPagePlaceholder, loading, gridLines, onSort, onSelect, onSearch, onRowClick, className, exportable, exportFilename, onExport, exportLabel, editable, getRowId, pendingChanges, onPendingChange, editLabels, getRowHref, onRowOpen, openLabel, }: DataTableProps<T>) => ReactNode;
|
|
231
|
+
declare const DataTable: <T = unknown>({ data, columns, sortable, selectable, searchable, pagination, currentPage: currentPageProp, pageSize: pageSizeProp, total: totalProp, onPageChange, onPageSizeChange, showingLabel, paginationPreviousLabel, paginationNextLabel, paginationItemsPerPagePlaceholder, loading, gridLines, onSort, onSelect, onSearch, onRowClick, className, exportable, exportFilename, onExport, exportLabel, editable, getRowId, pendingChanges, onPendingChange, editLabels, getRowHref, onRowOpen, openLabel, cellErrors, }: DataTableProps<T>) => ReactNode;
|
|
224
232
|
export default Table;
|
|
225
233
|
export { TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption, DataTable, };
|
|
226
234
|
//# sourceMappingURL=index.d.ts.map
|