@donotdev/components 0.2.3 → 0.3.0

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.
Files changed (112) hide show
  1. package/dist/CarouselContent-5W2E2F2I.js +1 -0
  2. package/dist/CarouselContent-EELYAALW.js +1 -0
  3. package/dist/CodeContent-7FWYPAB3.js +2 -0
  4. package/dist/CodeContent-E3HLW6BW.js +2 -0
  5. package/dist/advanced/Carousel/Carousel.d.ts +6 -4
  6. package/dist/advanced/Carousel/Carousel.d.ts.map +1 -1
  7. package/dist/advanced/Carousel/Carousel.js +10 -8
  8. package/dist/advanced/Carousel/CarouselContent.d.ts +35 -3
  9. package/dist/advanced/Carousel/CarouselContent.d.ts.map +1 -1
  10. package/dist/advanced/Carousel/CarouselContent.js +103 -67
  11. package/dist/advanced/Carousel/CarouselSkeleton.d.ts +3 -1
  12. package/dist/advanced/Carousel/CarouselSkeleton.d.ts.map +1 -1
  13. package/dist/advanced/Carousel/CarouselSkeleton.js +2 -2
  14. package/dist/atomic/ActionButton/index.d.ts +1 -1
  15. package/dist/atomic/ActionButton/index.js +1 -1
  16. package/dist/atomic/Alert/index.d.ts +1 -1
  17. package/dist/atomic/Badge/index.d.ts +1 -1
  18. package/dist/atomic/Button/index.d.ts +30 -1
  19. package/dist/atomic/Button/index.d.ts.map +1 -1
  20. package/dist/atomic/Button/index.js +38 -1
  21. package/dist/atomic/Card/index.d.ts +8 -2
  22. package/dist/atomic/Card/index.d.ts.map +1 -1
  23. package/dist/atomic/Card/index.js +19 -3
  24. package/dist/atomic/Collapsible/index.d.ts +7 -1
  25. package/dist/atomic/Collapsible/index.d.ts.map +1 -1
  26. package/dist/atomic/Collapsible/index.js +8 -3
  27. package/dist/atomic/Combobox/index.d.ts +11 -1
  28. package/dist/atomic/Combobox/index.d.ts.map +1 -1
  29. package/dist/atomic/Combobox/index.js +25 -9
  30. package/dist/atomic/DatePicker/index.d.ts +3 -1
  31. package/dist/atomic/DatePicker/index.d.ts.map +1 -1
  32. package/dist/atomic/DatePicker/index.js +2 -2
  33. package/dist/atomic/DateTimePicker/index.d.ts +3 -1
  34. package/dist/atomic/DateTimePicker/index.d.ts.map +1 -1
  35. package/dist/atomic/DateTimePicker/index.js +2 -2
  36. package/dist/atomic/HeroSection/index.d.ts +1 -1
  37. package/dist/atomic/Input/index.d.ts +3 -1
  38. package/dist/atomic/Input/index.d.ts.map +1 -1
  39. package/dist/atomic/Input/index.js +3 -3
  40. package/dist/atomic/Label/FieldInfo.d.ts +18 -0
  41. package/dist/atomic/Label/FieldInfo.d.ts.map +1 -0
  42. package/dist/atomic/Label/FieldInfo.js +34 -0
  43. package/dist/atomic/Label/FloatingLabel.d.ts +6 -1
  44. package/dist/atomic/Label/FloatingLabel.d.ts.map +1 -1
  45. package/dist/atomic/Label/FloatingLabel.js +6 -2
  46. package/dist/atomic/Label/index.d.ts +1 -0
  47. package/dist/atomic/Label/index.d.ts.map +1 -1
  48. package/dist/atomic/Label/index.js +1 -0
  49. package/dist/atomic/PasswordInput/index.d.ts +3 -1
  50. package/dist/atomic/PasswordInput/index.d.ts.map +1 -1
  51. package/dist/atomic/PasswordInput/index.js +2 -2
  52. package/dist/atomic/PinInput/index.d.ts +3 -1
  53. package/dist/atomic/PinInput/index.d.ts.map +1 -1
  54. package/dist/atomic/PinInput/index.js +2 -2
  55. package/dist/atomic/QuantityStepper/index.d.ts +19 -4
  56. package/dist/atomic/QuantityStepper/index.d.ts.map +1 -1
  57. package/dist/atomic/QuantityStepper/index.js +208 -5
  58. package/dist/atomic/QuantityStepper/quantity.d.ts +14 -0
  59. package/dist/atomic/QuantityStepper/quantity.d.ts.map +1 -0
  60. package/dist/atomic/QuantityStepper/quantity.js +35 -0
  61. package/dist/atomic/RangeInput/index.d.ts +3 -1
  62. package/dist/atomic/RangeInput/index.d.ts.map +1 -1
  63. package/dist/atomic/RangeInput/index.js +2 -2
  64. package/dist/atomic/Rating/index.d.ts +1 -1
  65. package/dist/atomic/Select/index.d.ts +3 -1
  66. package/dist/atomic/Select/index.d.ts.map +1 -1
  67. package/dist/atomic/Select/index.js +2 -2
  68. package/dist/atomic/Stepper/index.d.ts +1 -1
  69. package/dist/atomic/SwipeAction/gesture.d.ts +5 -0
  70. package/dist/atomic/SwipeAction/gesture.d.ts.map +1 -0
  71. package/dist/atomic/SwipeAction/gesture.js +10 -0
  72. package/dist/atomic/SwipeAction/index.d.ts +14 -0
  73. package/dist/atomic/SwipeAction/index.d.ts.map +1 -0
  74. package/dist/atomic/SwipeAction/index.js +67 -0
  75. package/dist/atomic/Table/editing.d.ts +3 -1
  76. package/dist/atomic/Table/editing.d.ts.map +1 -1
  77. package/dist/atomic/Table/editing.js +9 -6
  78. package/dist/atomic/Table/index.d.ts +9 -1
  79. package/dist/atomic/Table/index.d.ts.map +1 -1
  80. package/dist/atomic/Table/index.js +64 -48
  81. package/dist/atomic/Tabs/index.d.ts +1 -1
  82. package/dist/atomic/Tag/index.d.ts +3 -1
  83. package/dist/atomic/Tag/index.d.ts.map +1 -1
  84. package/dist/atomic/Tag/index.js +2 -2
  85. package/dist/atomic/Toaster/ToastPrimitive.d.ts +2 -2
  86. package/dist/atomic/Toaster/ToastPrimitive.d.ts.map +1 -1
  87. package/dist/atomic/Toggle/index.d.ts +1 -1
  88. package/dist/atomic/index.d.ts +6 -3
  89. package/dist/atomic/index.d.ts.map +1 -1
  90. package/dist/atomic/index.js +3 -1
  91. package/dist/chunk-SZNEXFUZ.js +3 -0
  92. package/dist/chunk-XK52GUFA.js +3 -0
  93. package/dist/hooks/useIntersectionObserver.d.ts +2 -1
  94. package/dist/hooks/useIntersectionObserver.d.ts.map +1 -1
  95. package/dist/hooks/useIntersectionObserver.js +6 -7
  96. package/dist/index.js +10 -10
  97. package/dist/styles/index.css +277 -45
  98. package/dist/symbol-index.json +1 -1
  99. package/dist/utils/sanitizeDom.browser.d.ts +8 -0
  100. package/dist/utils/sanitizeDom.browser.d.ts.map +1 -0
  101. package/dist/utils/sanitizeDom.browser.js +1 -0
  102. package/dist/utils/sanitizeDom.server.d.ts +9 -0
  103. package/dist/utils/sanitizeDom.server.d.ts.map +1 -0
  104. package/dist/utils/sanitizeDom.server.js +1 -0
  105. package/dist/utils/sanitizeHtml.d.ts.map +1 -1
  106. package/dist/utils/sanitizeHtml.js +7 -6
  107. package/dist/utils/variants.d.ts +1 -1
  108. package/guidelines/API_REFERENCE.md +3 -2
  109. package/guidelines/COMPONENTS.md +9 -4
  110. package/guidelines/QUANTITY_STEPPER.md +78 -0
  111. package/guidelines/SWIPE_ACTION.md +111 -0
  112. package/package.json +8 -2
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/Input/index.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,mBAAmB,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI5C,OAAO,aAAa,CAAC;AAErB,qCAAqC;AACrC,MAAM,WAAW,UAAW,SAAQ,mBAAmB,CAAC,gBAAgB,CAAC;IACvE,gDAAgD;IAChD,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,kCAAkC;IAClC,GAAG,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,QAAA,MAAM,KAAK,GAAI,yGAaZ,UAAU,gCA6EZ,CAAC;AAEF,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/Input/index.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,mBAAmB,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI5C,OAAO,aAAa,CAAC;AAErB,qCAAqC;AACrC,MAAM,WAAW,UAAW,SAAQ,mBAAmB,CAAC,gBAAgB,CAAC;IACvE,gDAAgD;IAChD,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wFAAwF;IACxF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,kCAAkC;IAClC,GAAG,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,QAAA,MAAM,KAAK,GAAI,+GAcZ,UAAU,gCAgFZ,CAAC;AAEF,eAAe,KAAK,CAAC"}
@@ -31,7 +31,7 @@ import './Input.css';
31
31
  * @param {InputProps} props - The props for the input
32
32
  * @returns {JSX.Element} The rendered input
33
33
  */
34
- const Input = ({ className, type, icon, iconEnd = false, label, bare, value, onFocus, onBlur, required, id: idProp, ...props }) => {
34
+ const Input = ({ className, type, icon, iconEnd = false, label, info, bare, value, onFocus, onBlur, required, id: idProp, ...props }) => {
35
35
  const generatedId = useId();
36
36
  const id = idProp ?? generatedId;
37
37
  const hasIcon = !!icon;
@@ -44,7 +44,7 @@ const Input = ({ className, type, icon, iconEnd = false, label, bare, value, onF
44
44
  // Explicitly exclude children to prevent void element error (input is a void element)
45
45
  // If we have a label, extract style to pass to FloatingLabel wrapper instead of input
46
46
  const { children: _children, style, ...inputProps } = props;
47
- const inputElement = (_jsx("input", { id: id, type: type, value: value, required: required, autoComplete: "one-time-code", className: inputClasses, "data-bare": isBare || undefined, ...inputProps,
47
+ const inputElement = (_jsx("input", { id: id, type: type, value: value, onFocus: onFocus, onBlur: onBlur, required: required, autoComplete: "one-time-code", className: inputClasses, "data-bare": isBare || undefined, ...inputProps,
48
48
  // Only apply style to input if there's no label (label wrapper gets it)
49
49
  style: hasLabel ? undefined : style }));
50
50
  const needsWrapper = hasIcon || hasLabel;
@@ -55,7 +55,7 @@ const Input = ({ className, type, icon, iconEnd = false, label, bare, value, onF
55
55
  }
56
56
  // With label: use FloatingLabel wrapper (fieldset/legend)
57
57
  if (hasLabel) {
58
- return (_jsx(FloatingLabel, { htmlFor: id, label: label, disabled: props.disabled, required: required, style: style, children: inputWithIcon }));
58
+ return (_jsx(FloatingLabel, { htmlFor: id, label: label, info: info, disabled: props.disabled, required: required, style: style, children: inputWithIcon }));
59
59
  }
60
60
  // Icon only, no label
61
61
  return inputWithIcon;
@@ -0,0 +1,18 @@
1
+ /** Props for {@link FieldInfo}. */
2
+ export interface FieldInfoProps {
3
+ /** Help text: what the field is for, in the reader's words. Also the button's accessible name. */
4
+ text: string;
5
+ }
6
+ /**
7
+ * (i) help button for a field label. Hover or focus shows the text; a tap (or click)
8
+ * pins it open until the button loses focus or Escape is pressed.
9
+ *
10
+ * @component
11
+ * @example
12
+ * ```tsx
13
+ * <FieldInfo text="Address of the page: /routines/oily-skin" />
14
+ * ```
15
+ */
16
+ export declare function FieldInfo({ text }: FieldInfoProps): import("react").JSX.Element;
17
+ export default FieldInfo;
18
+ //# sourceMappingURL=FieldInfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldInfo.d.ts","sourceRoot":"","sources":["../../../src/atomic/Label/FieldInfo.tsx"],"names":[],"mappings":"AAoBA,mCAAmC;AACnC,MAAM,WAAW,cAAc;IAC7B,kGAAkG;IAClG,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,EAAE,IAAI,EAAE,EAAE,cAAc,+BAkBjD;AAED,eAAe,SAAS,CAAC"}
@@ -0,0 +1,34 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ // packages/components/src/atomic/Label/FieldInfo.tsx
4
+ /**
5
+ * @fileoverview FieldInfo component
6
+ * @description (i) button next to a field label: its help text shows on hover and
7
+ * keyboard focus (tooltip), and on tap for touch screens, where hover does not exist.
8
+ *
9
+ * @version 0.1.0
10
+ * @since 0.2.5
11
+ * @author AMBROISE PARK Consulting
12
+ */
13
+ import { useState } from 'react';
14
+ import { Info } from 'lucide-react';
15
+ import Icon from '../Icons/Icon';
16
+ import Tooltip from '../Tooltip';
17
+ /**
18
+ * (i) help button for a field label. Hover or focus shows the text; a tap (or click)
19
+ * pins it open until the button loses focus or Escape is pressed.
20
+ *
21
+ * @component
22
+ * @example
23
+ * ```tsx
24
+ * <FieldInfo text="Address of the page: /routines/oily-skin" />
25
+ * ```
26
+ */
27
+ export function FieldInfo({ text }) {
28
+ const [pinned, setPinned] = useState(false);
29
+ return (_jsx(Tooltip, { content: text, side: "top", forceOpen: pinned || undefined, children: _jsx("button", { type: "button", className: "dndev-field-info", "aria-label": text, onClick: () => setPinned((open) => !open), onBlur: () => setPinned(false), onKeyDown: (event) => {
30
+ if (event.key === 'Escape')
31
+ setPinned(false);
32
+ }, children: _jsx(Icon, { icon: Info, ariaHidden: true }) }) }));
33
+ }
34
+ export default FieldInfo;
@@ -22,6 +22,8 @@ export interface FloatingLabelProps {
22
22
  truncate?: boolean;
23
23
  /** Whether the field is required - shows asterisk indicator */
24
24
  required?: boolean;
25
+ /** Help text: an (i) after the label shows it on hover, focus or tap */
26
+ info?: string;
25
27
  /** Children (the input element) - REQUIRED */
26
28
  children: ReactNode;
27
29
  /** Additional className for the fieldset */
@@ -41,8 +43,11 @@ export interface FloatingLabelProps {
41
43
  * <FloatingLabel label="Email Address" htmlFor="email" required>
42
44
  * <input id="email" type="email" />
43
45
  * </FloatingLabel>
46
+ * <FloatingLabel label="URL" htmlFor="slug" info="Address of the page: /routines/oily-skin">
47
+ * <input id="slug" />
48
+ * </FloatingLabel>
44
49
  * ```
45
50
  */
46
- export declare function FloatingLabel({ htmlFor, label, disabled, truncate, required, children, className, style, }: FloatingLabelProps): import("react").JSX.Element;
51
+ export declare function FloatingLabel({ htmlFor, label, disabled, truncate, required, info, children, className, style, }: FloatingLabelProps): import("react").JSX.Element;
47
52
  export default FloatingLabel;
48
53
  //# sourceMappingURL=FloatingLabel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FloatingLabel.d.ts","sourceRoot":"","sources":["../../../src/atomic/Label/FloatingLabel.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,OAAO,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,yGAAyG;AACzG,MAAM,WAAW,kBAAkB;IACjC,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4BAA4B;IAC5B,KAAK,EAAE,SAAS,CAAC;IACjB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8CAA8C;IAC9C,QAAQ,EAAE,SAAS,CAAC;IACpB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,EAC5B,OAAO,EACP,KAAK,EACL,QAAgB,EAChB,QAAe,EACf,QAAgB,EAChB,QAAQ,EACR,SAAS,EACT,KAAK,GACN,EAAE,kBAAkB,+BAoBpB;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"FloatingLabel.d.ts","sourceRoot":"","sources":["../../../src/atomic/Label/FloatingLabel.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,OAAO,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,yGAAyG;AACzG,MAAM,WAAW,kBAAkB;IACjC,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4BAA4B;IAC5B,KAAK,EAAE,SAAS,CAAC;IACjB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wEAAwE;IACxE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,QAAQ,EAAE,SAAS,CAAC;IACpB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAAC,EAC5B,OAAO,EACP,KAAK,EACL,QAAgB,EAChB,QAAe,EACf,QAAgB,EAChB,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,KAAK,GACN,EAAE,kBAAkB,+BAwBpB;AAED,eAAe,aAAa,CAAC"}
@@ -11,6 +11,7 @@ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
11
11
  * @author AMBROISE PARK Consulting
12
12
  */
13
13
  import './Label.css';
14
+ import { FieldInfo } from './FieldInfo';
14
15
  /**
15
16
  * FloatingLabel - Fieldset/legend wrapper for floating labels
16
17
  *
@@ -23,9 +24,12 @@ import './Label.css';
23
24
  * <FloatingLabel label="Email Address" htmlFor="email" required>
24
25
  * <input id="email" type="email" />
25
26
  * </FloatingLabel>
27
+ * <FloatingLabel label="URL" htmlFor="slug" info="Address of the page: /routines/oily-skin">
28
+ * <input id="slug" />
29
+ * </FloatingLabel>
26
30
  * ```
27
31
  */
28
- export function FloatingLabel({ htmlFor, label, disabled = false, truncate = true, required = false, children, className, style, }) {
29
- return (_jsxs("fieldset", { className: `dndev-floating-fieldset ${className || ''}`, disabled: disabled, "data-disabled": disabled ? 'true' : undefined, style: style, children: [_jsx("legend", { className: "dndev-floating-legend", "data-truncate": truncate ? undefined : 'false', children: _jsxs("label", { htmlFor: htmlFor, children: [label, required && ' *'] }) }), children] }));
32
+ export function FloatingLabel({ htmlFor, label, disabled = false, truncate = true, required = false, info, children, className, style, }) {
33
+ return (_jsxs("fieldset", { className: `dndev-floating-fieldset ${className || ''}`, disabled: disabled, "data-disabled": disabled ? 'true' : undefined, style: style, children: [_jsxs("legend", { className: "dndev-floating-legend", "data-truncate": truncate ? undefined : 'false', "data-info": info ? 'true' : undefined, children: [_jsxs("label", { htmlFor: htmlFor, children: [label, required && ' *'] }), info && _jsx(FieldInfo, { text: info })] }), children] }));
30
34
  }
31
35
  export default FloatingLabel;
@@ -45,4 +45,5 @@ export interface LabelProps extends LabelPrimitiveProps {
45
45
  declare const Label: ({ className, icon: Icon, iconEnd, plain, required, children, ...props }: LabelProps) => import("react").JSX.Element;
46
46
  export default Label;
47
47
  export { FloatingLabel, type FloatingLabelProps };
48
+ export { FieldInfo, type FieldInfoProps } from './FieldInfo';
48
49
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/Label/index.tsx"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAkB,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAG5E,qCAAqC;AACrC,MAAM,WAAW,UAAW,SAAQ,mBAAmB;IACrD,8CAA8C;IAC9C,IAAI,CAAC,EAAE,aAAa,CAAC;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7C;;;O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"}
@@ -20,3 +20,4 @@ const Label = ({ className, icon: Icon, iconEnd = false, plain = false, required
20
20
  };
21
21
  export default Label;
22
22
  export { FloatingLabel };
23
+ export { FieldInfo } from './FieldInfo';
@@ -8,6 +8,8 @@ export interface PasswordInputProps extends Omit<InputHTMLAttributes<HTMLInputEl
8
8
  onVisibilityChange?: (visible: boolean) => void;
9
9
  /** Label for floating label - always shown small at top-left when provided */
10
10
  label?: string;
11
+ /** Help text: an (i) after the label shows it on hover, focus or tap. Needs `label`. */
12
+ info?: string;
11
13
  /** Whether the field is required - shows asterisk indicator */
12
14
  required?: boolean;
13
15
  }
@@ -40,6 +42,6 @@ export interface PasswordInputProps extends Omit<InputHTMLAttributes<HTMLInputEl
40
42
  * @param {PasswordInputProps} props - The props for the password input
41
43
  * @returns {JSX.Element} The rendered password input
42
44
  */
43
- declare const PasswordInput: ({ className, visible: controlledVisible, onVisibilityChange, label, value, onFocus, onBlur, required, id: idProp, ...props }: PasswordInputProps) => import("react").JSX.Element;
45
+ declare const PasswordInput: ({ className, visible: controlledVisible, onVisibilityChange, label, info, value, onFocus, onBlur, required, id: idProp, ...props }: PasswordInputProps) => import("react").JSX.Element;
44
46
  export default PasswordInput;
45
47
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/PasswordInput/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAKjD,OAAO,qBAAqB,CAAC;AAE7B,4EAA4E;AAC5E,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAC9C,mBAAmB,CAAC,gBAAgB,CAAC,EACrC,MAAM,CACP;IACC,gDAAgD;IAChD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uCAAuC;IACvC,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAChD,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,QAAA,MAAM,aAAa,GAAI,8HAWpB,kBAAkB,gCAsEpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/PasswordInput/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAKjD,OAAO,qBAAqB,CAAC;AAE7B,4EAA4E;AAC5E,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAC9C,mBAAmB,CAAC,gBAAgB,CAAC,EACrC,MAAM,CACP;IACC,gDAAgD;IAChD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uCAAuC;IACvC,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAChD,8EAA8E;IAC9E,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,QAAA,MAAM,aAAa,GAAI,oIAYpB,kBAAkB,gCAuEpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -42,7 +42,7 @@ import './PasswordInput.css';
42
42
  * @param {PasswordInputProps} props - The props for the password input
43
43
  * @returns {JSX.Element} The rendered password input
44
44
  */
45
- const PasswordInput = ({ className, visible: controlledVisible, onVisibilityChange, label, value, onFocus, onBlur, required, id: idProp, ...props }) => {
45
+ const PasswordInput = ({ className, visible: controlledVisible, onVisibilityChange, label, info, value, onFocus, onBlur, required, id: idProp, ...props }) => {
46
46
  // A passed id must reach both the input and its label
47
47
  const generatedId = useId();
48
48
  const id = idProp ?? generatedId;
@@ -61,6 +61,6 @@ const PasswordInput = ({ className, visible: controlledVisible, onVisibilityChan
61
61
  if (!hasLabel) {
62
62
  return inputContent;
63
63
  }
64
- return (_jsx(FloatingLabel, { htmlFor: id, label: label, disabled: props.disabled, required: required, children: inputContent }));
64
+ return (_jsx(FloatingLabel, { htmlFor: id, label: label, info: info, disabled: props.disabled, required: required, children: inputContent }));
65
65
  };
66
66
  export default PasswordInput;
@@ -30,6 +30,8 @@ export interface PinInputProps extends Omit<InputHTMLAttributes<HTMLInputElement
30
30
  numericOnly?: boolean;
31
31
  /** Floating label rendered above the group. */
32
32
  label?: string;
33
+ /** Help text: an (i) after the label shows it on hover, focus or tap. Needs `label`. */
34
+ info?: string;
33
35
  /** Whether the field is required - shows asterisk indicator */
34
36
  required?: boolean;
35
37
  /** Auto-focus the first box on mount. */
@@ -87,6 +89,6 @@ export interface PinInputProps extends Omit<InputHTMLAttributes<HTMLInputElement
87
89
  * @param {PinInputProps} props - The props for the PIN input
88
90
  * @returns {JSX.Element} The rendered PIN input
89
91
  */
90
- declare const PinInput: ({ value, onChange, onComplete, length, mask, hideMaskToggle, shake, numericOnly, label, required, autoFocus, disabled, className, digitAriaLabel, revealAriaLabel, "aria-label": ariaLabel, ...rest }: PinInputProps) => import("react").JSX.Element;
92
+ declare const PinInput: ({ value, onChange, onComplete, length, mask, hideMaskToggle, shake, numericOnly, label, info, required, autoFocus, disabled, className, digitAriaLabel, revealAriaLabel, "aria-label": ariaLabel, ...rest }: PinInputProps) => import("react").JSX.Element;
91
93
  export default PinInput;
92
94
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/PinInput/index.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAKjD,OAAO,gBAAgB,CAAC;AAExB,mEAAmE;AACnE,MAAM,WAAW,aAAc,SAAQ,IAAI,CACzC,mBAA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Props} props - The props for the PIN input
55
55
  * @returns {JSX.Element} The rendered PIN input
56
56
  */
57
- const PinInput = ({ value, onChange, onComplete, length = 4, mask = true, hideMaskToggle = false, shake = false, numericOnly = true, label, required, autoFocus, disabled, className, digitAriaLabel, revealAriaLabel, 'aria-label': ariaLabel, ...rest }) => {
57
+ const PinInput = ({ value, onChange, onComplete, length = 4, mask = true, hideMaskToggle = false, shake = false, numericOnly = true, label, info, required, autoFocus, disabled, className, digitAriaLabel, revealAriaLabel, 'aria-label': ariaLabel, ...rest }) => {
58
58
  const id = useId();
59
59
  const refs = useRef([]);
60
60
  const [revealed, setRevealed] = useState(false);
@@ -150,6 +150,6 @@ const PinInput = ({ value, onChange, onComplete, length = 4, mask = true, hideMa
150
150
  : (revealAriaLabel?.show ?? 'Show PIN'), "aria-pressed": revealed, tabIndex: -1, children: revealed ? (_jsx(EyeOff, { className: "dndev-size-md" })) : (_jsx(Eye, { className: "dndev-size-md" })) })) : null] }));
151
151
  if (!label)
152
152
  return group;
153
- return (_jsx(FloatingLabel, { htmlFor: id, label: label, disabled: disabled, required: required, children: group }));
153
+ return (_jsx(FloatingLabel, { htmlFor: id, label: label, info: info, disabled: disabled, required: required, children: group }));
154
154
  };
155
155
  export default PinInput;
@@ -2,8 +2,22 @@ import type { HTMLAttributes } from 'react';
2
2
  import './QuantityStepper.css';
3
3
  /** Props for the QuantityStepper component -- [ − qty + ] quantity control. */
4
4
  export interface QuantityStepperProps extends Omit<HTMLAttributes<HTMLDivElement>, 'role' | 'onChange'> {
5
- /** Quantity shown between the buttons */
5
+ /** Controlled quantity. Zero may be used as the initial, not-yet-added value. */
6
6
  value: number;
7
+ /** Enables native text editing; receives validated quantities on commit, not on each keystroke. Takes precedence over legacy callbacks. */
8
+ onChange?: (value: number) => void;
9
+ /** First positive quantity (safe integer). @default 1 */
10
+ min?: number;
11
+ /** Lot size (positive safe integer); valid quantities are min + k * step. @default 1 */
12
+ step?: number;
13
+ /** Stock limit; rounded down to the last complete lot. */
14
+ max?: number;
15
+ /** Allows committing zero, in addition to positive lots. @default false */
16
+ allowZero?: boolean;
17
+ /** Shows only a large + at zero, reserving the expanded footprint. @default false */
18
+ collapseWhenZero?: boolean;
19
+ /** Stack the controls: plus, quantity, minus (also DOM and tab order). @default false */
20
+ vertical?: boolean;
7
21
  /** Called by −. Omit to disable − (at the minimum). */
8
22
  onDecrement?: () => void;
9
23
  /** Called by +. Omit to disable + (stock or limit reached). */
@@ -31,8 +45,9 @@ export interface QuantityStepperProps extends Omit<HTMLAttributes<HTMLDivElement
31
45
  /**
32
46
  * Quantity control in the e-commerce standard form: one outlined field, borderless
33
47
  * − / + buttons, the quantity centred with tabular figures. Stateless: the caller owns
34
- * the value and the step rules (lots, minimums, stock) and passes `undefined` handlers
35
- * to disable a direction.
48
+ * the value. Legacy mode uses direction callbacks; additive onChange mode owns lot
49
+ * normalization and offers an uncontrolled text spinbutton committed on blur/Enter.
50
+ * onChange takes precedence over the legacy direction and value-click callbacks.
36
51
  *
37
52
  * @component
38
53
  * @example
@@ -47,6 +62,6 @@ export interface QuantityStepperProps extends Omit<HTMLAttributes<HTMLDivElement
47
62
  * />
48
63
  * ```
49
64
  */
50
- declare const QuantityStepper: ({ value, onDecrement, onIncrement, onValueClick, disabled, fullWidth, decrementLabel, incrementLabel, valueLabel, className, ...props }: QuantityStepperProps) => import("react").JSX.Element;
65
+ declare const QuantityStepper: ({ value, onDecrement, onIncrement, onValueClick, onChange, min, step, max, allowZero, collapseWhenZero, vertical, disabled, fullWidth, decrementLabel, incrementLabel, valueLabel, className, onBlur, ...props }: QuantityStepperProps) => import("react").JSX.Element;
51
66
  export default QuantityStepper;
52
67
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/QuantityStepper/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAK5C,OAAO,uBAAuB,CAAC;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G,CAAC,EAAE,MAAM,CAAC;IACb,wFAAwF;IACxF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,2EAA2E;IAC3E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,yFAAyF;IACzF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,qFAAqF;IACrF,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,qDAAqD;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6DAA6D;IAC7D,YAAY,EAAE,MAAM,CAAC;IACrB,2BAA2B;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,2BAA2B;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAUD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,QAAA,MAAM,eAAe,GAAI,kNAoBtB,oBAAoB,gCAiPtB,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
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 Button from '../Button';
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 and the step rules (lots, minimums, stock) and passes `undefined` handlers
20
- * to disable a direction.
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, disabled = false, fullWidth = false, decrementLabel, incrementLabel, valueLabel, className, ...props }) => (_jsxs("div", { role: "group", className: cn('dndev-quantity-stepper', className), "data-full-width": fullWidth || undefined, "data-disabled": disabled || undefined, ...props, children: [_jsx(Button, { variant: "ghost", icon: Minus, display: "compact", "aria-label": decrementLabel, disabled: disabled || !onDecrement, onClick: onDecrement }), onValueClick ? (_jsx("button", { type: "button", className: "dndev-quantity-stepper-value", "aria-label": valueLabel, disabled: disabled, onClick: onValueClick, children: value })) : (_jsx("output", { className: "dndev-quantity-stepper-value", "aria-live": "polite", children: value })), _jsx(Button, { variant: "ghost", icon: Plus, display: "compact", "aria-label": incrementLabel, disabled: disabled || !onIncrement, onClick: onIncrement })] }));
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