@puzzle-ui/ui 0.4.0 → 0.5.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.
Files changed (163) hide show
  1. package/README.md +61 -77
  2. package/dist/components/actions/button/button.css +5 -2
  3. package/dist/components/actions/button-group/button-group.css +16 -17
  4. package/dist/components/data-display/badge/badge.css +15 -2
  5. package/dist/components/data-display/badge/index.cjs +13 -2
  6. package/dist/components/data-display/badge/index.cjs.map +1 -1
  7. package/dist/components/data-display/badge/index.d.cts +7 -2
  8. package/dist/components/data-display/badge/index.d.ts +7 -2
  9. package/dist/components/data-display/badge/index.js +13 -2
  10. package/dist/components/data-display/badge/index.js.map +1 -1
  11. package/dist/components/data-display/rating/index.cjs +84 -0
  12. package/dist/components/data-display/rating/index.cjs.map +1 -0
  13. package/dist/components/data-display/rating/index.d.cts +3 -0
  14. package/dist/components/data-display/rating/index.d.ts +3 -0
  15. package/dist/components/data-display/rating/index.js +84 -0
  16. package/dist/components/data-display/rating/index.js.map +1 -0
  17. package/dist/components/data-display/rating/rating.css +72 -0
  18. package/dist/components/data-display/rating/rating.types.d.cts +15 -0
  19. package/dist/components/data-display/rating/rating.types.d.ts +15 -0
  20. package/dist/components/data-display/rating/rating.utils.cjs +27 -0
  21. package/dist/components/data-display/rating/rating.utils.cjs.map +1 -0
  22. package/dist/components/data-display/rating/rating.utils.js +25 -0
  23. package/dist/components/data-display/rating/rating.utils.js.map +1 -0
  24. package/dist/components/forms/checkbox/checkbox.css +2 -10
  25. package/dist/components/forms/input-group/input-group.d.cts +4 -2
  26. package/dist/components/forms/input-group/input-group.d.ts +4 -2
  27. package/dist/components/forms/radio-group/index.d.cts +2 -1
  28. package/dist/components/forms/radio-group/index.d.ts +2 -1
  29. package/dist/components/forms/stepper/index.d.cts +4 -2
  30. package/dist/components/forms/stepper/index.d.ts +4 -2
  31. package/dist/components/forms/time-picker/index.cjs +108 -0
  32. package/dist/components/forms/time-picker/index.cjs.map +1 -0
  33. package/dist/components/forms/time-picker/index.d.cts +3 -0
  34. package/dist/components/forms/time-picker/index.d.ts +3 -0
  35. package/dist/components/forms/time-picker/index.js +108 -0
  36. package/dist/components/forms/time-picker/index.js.map +1 -0
  37. package/dist/components/forms/time-picker/time-picker.css +166 -0
  38. package/dist/components/forms/time-picker/time-picker.types.d.cts +34 -0
  39. package/dist/components/forms/time-picker/time-picker.types.d.ts +34 -0
  40. package/dist/components/forms/time-picker/time-picker.utils.cjs +25 -0
  41. package/dist/components/forms/time-picker/time-picker.utils.cjs.map +1 -0
  42. package/dist/components/forms/time-picker/time-picker.utils.js +24 -0
  43. package/dist/components/forms/time-picker/time-picker.utils.js.map +1 -0
  44. package/dist/components/forms/token-input/index.cjs +189 -0
  45. package/dist/components/forms/token-input/index.cjs.map +1 -0
  46. package/dist/components/forms/token-input/index.d.cts +3 -0
  47. package/dist/components/forms/token-input/index.d.ts +3 -0
  48. package/dist/components/forms/token-input/index.js +189 -0
  49. package/dist/components/forms/token-input/index.js.map +1 -0
  50. package/dist/components/forms/token-input/token-input.css +145 -0
  51. package/dist/components/forms/token-input/token-input.types.d.cts +48 -0
  52. package/dist/components/forms/token-input/token-input.types.d.ts +48 -0
  53. package/dist/components/forms/token-input/token-input.utils.cjs +30 -0
  54. package/dist/components/forms/token-input/token-input.utils.cjs.map +1 -0
  55. package/dist/components/forms/token-input/token-input.utils.js +24 -0
  56. package/dist/components/forms/token-input/token-input.utils.js.map +1 -0
  57. package/dist/components/layout/aspect-ratio/aspect-ratio.css +14 -0
  58. package/dist/components/layout/aspect-ratio/aspect-ratio.utils.cjs +11 -0
  59. package/dist/components/layout/aspect-ratio/aspect-ratio.utils.cjs.map +1 -0
  60. package/dist/components/layout/aspect-ratio/aspect-ratio.utils.js +11 -0
  61. package/dist/components/layout/aspect-ratio/aspect-ratio.utils.js.map +1 -0
  62. package/dist/components/layout/aspect-ratio/index.cjs +16 -0
  63. package/dist/components/layout/aspect-ratio/index.cjs.map +1 -0
  64. package/dist/components/layout/aspect-ratio/index.d.cts +11 -0
  65. package/dist/components/layout/aspect-ratio/index.d.ts +11 -0
  66. package/dist/components/layout/aspect-ratio/index.js +16 -0
  67. package/dist/components/layout/aspect-ratio/index.js.map +1 -0
  68. package/dist/components/layout/container/container.css +1 -0
  69. package/dist/components/layout/page-layout/page-layout.css +1 -0
  70. package/dist/components/layout/scroll-area/index.cjs +27 -0
  71. package/dist/components/layout/scroll-area/index.cjs.map +1 -0
  72. package/dist/components/layout/scroll-area/index.d.cts +15 -0
  73. package/dist/components/layout/scroll-area/index.d.ts +15 -0
  74. package/dist/components/layout/scroll-area/index.js +27 -0
  75. package/dist/components/layout/scroll-area/index.js.map +1 -0
  76. package/dist/components/layout/scroll-area/scroll-area.css +25 -0
  77. package/dist/components/layout/scroll-area/scroll-area.utils.cjs +8 -0
  78. package/dist/components/layout/scroll-area/scroll-area.utils.cjs.map +1 -0
  79. package/dist/components/layout/scroll-area/scroll-area.utils.d.cts +2 -0
  80. package/dist/components/layout/scroll-area/scroll-area.utils.d.ts +2 -0
  81. package/dist/components/layout/scroll-area/scroll-area.utils.js +8 -0
  82. package/dist/components/layout/scroll-area/scroll-area.utils.js.map +1 -0
  83. package/dist/components/layout/section/index.cjs +10 -4
  84. package/dist/components/layout/section/index.cjs.map +1 -1
  85. package/dist/components/layout/section/index.d.cts +1 -1
  86. package/dist/components/layout/section/index.d.ts +1 -1
  87. package/dist/components/layout/section/index.js +11 -5
  88. package/dist/components/layout/section/index.js.map +1 -1
  89. package/dist/components/layout/section/section.css +9 -3
  90. package/dist/components/layout/section/types.d.cts +5 -5
  91. package/dist/components/layout/section/types.d.ts +5 -5
  92. package/dist/components/layout/separator/index.cjs +18 -0
  93. package/dist/components/layout/separator/index.cjs.map +1 -0
  94. package/dist/components/layout/separator/index.d.cts +17 -0
  95. package/dist/components/layout/separator/index.d.ts +17 -0
  96. package/dist/components/layout/separator/index.js +18 -0
  97. package/dist/components/layout/separator/index.js.map +1 -0
  98. package/dist/components/layout/separator/separator.css +15 -0
  99. package/dist/components/layout/separator/separator.utils.cjs +11 -0
  100. package/dist/components/layout/separator/separator.utils.cjs.map +1 -0
  101. package/dist/components/layout/separator/separator.utils.d.cts +2 -0
  102. package/dist/components/layout/separator/separator.utils.d.ts +2 -0
  103. package/dist/components/layout/separator/separator.utils.js +11 -0
  104. package/dist/components/layout/separator/separator.utils.js.map +1 -0
  105. package/dist/components/layout/stack/index.cjs +18 -2
  106. package/dist/components/layout/stack/index.cjs.map +1 -1
  107. package/dist/components/layout/stack/index.d.cts +8 -6
  108. package/dist/components/layout/stack/index.d.ts +8 -6
  109. package/dist/components/layout/stack/index.js +18 -2
  110. package/dist/components/layout/stack/index.js.map +1 -1
  111. package/dist/components/layout/stack/stack.css +118 -138
  112. package/dist/components/navigation/carousel/index.cjs +4 -1
  113. package/dist/components/navigation/carousel/index.cjs.map +1 -1
  114. package/dist/components/navigation/carousel/index.js +4 -1
  115. package/dist/components/navigation/carousel/index.js.map +1 -1
  116. package/dist/components/navigation/tabs/index.d.cts +3 -2
  117. package/dist/components/navigation/tabs/index.d.ts +3 -2
  118. package/dist/components/navigation/tree-view/index.cjs +1 -1
  119. package/dist/components/navigation/tree-view/index.cjs.map +1 -1
  120. package/dist/components/navigation/tree-view/index.d.cts +5 -1
  121. package/dist/components/navigation/tree-view/index.d.ts +5 -1
  122. package/dist/components/navigation/tree-view/index.js +1 -1
  123. package/dist/components/navigation/tree-view/index.js.map +1 -1
  124. package/dist/components/navigation/tree-view/tree-view.css +5 -3
  125. package/dist/components/overlays/context-menu/context-menu.css +151 -0
  126. package/dist/components/overlays/context-menu/context-menu.types.d.cts +69 -0
  127. package/dist/components/overlays/context-menu/context-menu.types.d.ts +69 -0
  128. package/dist/components/overlays/context-menu/context-menu.utils.cjs +46 -0
  129. package/dist/components/overlays/context-menu/context-menu.utils.cjs.map +1 -0
  130. package/dist/components/overlays/context-menu/context-menu.utils.js +40 -0
  131. package/dist/components/overlays/context-menu/context-menu.utils.js.map +1 -0
  132. package/dist/components/overlays/context-menu/index.cjs +830 -0
  133. package/dist/components/overlays/context-menu/index.cjs.map +1 -0
  134. package/dist/components/overlays/context-menu/index.d.cts +42 -0
  135. package/dist/components/overlays/context-menu/index.d.ts +42 -0
  136. package/dist/components/overlays/context-menu/index.js +818 -0
  137. package/dist/components/overlays/context-menu/index.js.map +1 -0
  138. package/dist/components/typography/heading.cjs +6 -2
  139. package/dist/components/typography/heading.cjs.map +1 -1
  140. package/dist/components/typography/heading.d.cts +3 -2
  141. package/dist/components/typography/heading.d.ts +3 -2
  142. package/dist/components/typography/heading.js +6 -2
  143. package/dist/components/typography/heading.js.map +1 -1
  144. package/dist/components/typography/text.cjs +6 -2
  145. package/dist/components/typography/text.cjs.map +1 -1
  146. package/dist/components/typography/text.d.cts +3 -2
  147. package/dist/components/typography/text.d.ts +3 -2
  148. package/dist/components/typography/text.js +6 -2
  149. package/dist/components/typography/text.js.map +1 -1
  150. package/dist/components/utilities/preview/index.cjs +88 -20
  151. package/dist/components/utilities/preview/index.cjs.map +1 -1
  152. package/dist/components/utilities/preview/index.d.cts +6 -2
  153. package/dist/components/utilities/preview/index.d.ts +6 -2
  154. package/dist/components/utilities/preview/index.js +88 -20
  155. package/dist/components/utilities/preview/index.js.map +1 -1
  156. package/dist/components/utilities/preview/preview.css +26 -11
  157. package/dist/components/utilities/transition/index.d.cts +1 -1
  158. package/dist/components/utilities/transition/index.d.ts +1 -1
  159. package/dist/index.cjs +123 -97
  160. package/dist/index.d.cts +15 -2
  161. package/dist/index.d.ts +15 -2
  162. package/dist/index.js +8 -1
  163. package/package.json +11 -6
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/data-display/rating/index.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState, type CSSProperties, type KeyboardEvent } from \"react\";\n\nimport { cn } from \"@puzzle-ui/core\";\nimport { Icon } from \"@puzzle-ui/icons\";\n\nimport type { RatingProps, RatingSize } from \"./rating.types\";\n\nimport {\n getNextRating,\n getRatingStarState,\n normalizeRating,\n} from \"./rating.utils\";\n\nimport \"./rating.css\";\n\nconst ICONS = {\n full: \"ph:star-fill\",\n half: \"ph:star-half-fill\",\n empty: \"ph:star\",\n} as const;\n\nconst SIZE_MAP = {\n sm: 16,\n md: 20,\n lg: 24,\n} as const;\n\nconst Rating = ({\n value,\n defaultValue = 0,\n onValueChange,\n max = 5,\n precision = 0.5,\n size = \"md\",\n readOnly = false,\n disabled = false,\n color = \"var(--puzzle-color-warning, #FABC0A)\",\n emptyColor = \"var(--puzzle-color-border)\",\n className,\n style,\n \"aria-label\": ariaLabel = \"Rating\",\n onKeyDown,\n ...props\n}: RatingProps) => {\n if (!Number.isInteger(max) || max < 1 || max > 10) {\n throw new Error(\"Rating max must be an integer between 1 and 10.\");\n }\n\n const isControlled = value !== undefined;\n\n const [internalValue, setInternalValue] = useState(() =>\n normalizeRating(defaultValue, max, precision),\n );\n\n const currentValue = normalizeRating(\n isControlled ? value : internalValue,\n max,\n precision,\n );\n\n const commitValue = (nextValue: number) => {\n if (disabled || readOnly) {\n return;\n }\n\n const next = normalizeRating(nextValue, max, precision);\n\n if (next === currentValue) {\n return;\n }\n\n if (!isControlled) {\n setInternalValue(next);\n }\n\n onValueChange?.(next);\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(event);\n\n if (event.defaultPrevented || disabled || readOnly) {\n return;\n }\n\n const nextValue = getNextRating(currentValue, event.key, max, precision);\n\n if (nextValue === undefined) {\n return;\n }\n\n event.preventDefault();\n commitValue(nextValue);\n };\n\n const classes = cn(\n \"puzzle-rating\",\n disabled && \"puzzle-rating-disabled\",\n readOnly && \"puzzle-rating-readonly\",\n className,\n );\n\n return (\n <div\n {...props}\n className={classes}\n style={\n {\n ...style,\n \"--puzzle-rating-color\": color,\n \"--puzzle-rating-empty-color\": emptyColor,\n } as CSSProperties\n }\n role={readOnly ? \"img\" : \"slider\"}\n tabIndex={disabled || readOnly ? undefined : 0}\n aria-label={\n readOnly\n ? `${ariaLabel}: ${currentValue} out of ${max} stars`\n : ariaLabel\n }\n aria-valuemin={readOnly ? undefined : 0}\n aria-valuemax={readOnly ? undefined : max}\n aria-valuenow={readOnly ? undefined : currentValue}\n aria-valuetext={\n readOnly ? undefined : `${currentValue} out of ${max} stars`\n }\n aria-disabled={disabled || undefined}\n aria-readonly={readOnly || undefined}\n onKeyDown={handleKeyDown}\n data-size={size}\n data-disabled={disabled || undefined}\n data-readonly={readOnly || undefined}\n >\n {Array.from({ length: max }, (_, index) => {\n const state = getRatingStarState(currentValue, index);\n\n return (\n <span\n key={index}\n className=\"puzzle-rating__star\"\n data-state={state}\n aria-hidden=\"true\"\n onClick={(event) => {\n const rect = event.currentTarget.getBoundingClientRect();\n\n const isHalf =\n precision === 0.5 && event.clientX < rect.left + rect.width / 2;\n\n commitValue(index + (isHalf ? 0.5 : 1));\n }}\n >\n <Icon\n name={ICONS[state]}\n size={SIZE_MAP[size]}\n aria-hidden=\"true\"\n focusable=\"false\"\n />\n </span>\n );\n })}\n </div>\n );\n};\n\nexport { Rating, type RatingProps, type RatingSize };\n"],"mappings":";;;;;;;;AAiBA,MAAM,QAAQ;CACZ,MAAM;CACN,MAAM;CACN,OAAO;AACT;AAEA,MAAM,WAAW;CACf,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,MAAM,UAAU,EACd,OACA,eAAe,GACf,eACA,MAAM,GACN,YAAY,IACZ,OAAO,MACP,WAAW,OACX,WAAW,OACX,QAAQ,wCACR,aAAa,8BACb,WACA,OACA,cAAc,YAAY,UAC1B,WACA,GAAG,YACc;CACjB,IAAI,CAAC,OAAO,UAAU,GAAG,KAAK,MAAM,KAAK,MAAM,IAC7C,MAAM,IAAI,MAAM,iDAAiD;CAGnE,MAAM,eAAe,UAAU,KAAA;CAE/B,MAAM,CAAC,eAAe,oBAAoB,eACxC,gBAAgB,cAAc,KAAK,SAAS,CAC9C;CAEA,MAAM,eAAe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Ac,MAAO,MAAM,UAAU,KAAK,OAAO,KAAK,QAAQ;KAEhE,YAAY,SAAS,SAAS,KAAM,EAAE;IACxC;IAEA,UAAA,oBAAC,MAAD;KACE,MAAM,MAAM;KACZ,MAAM,SAAS;KACf,eAAY;KACZ,WAAU;IACX,CAAA;GACG,GAnBC,KAmBD;EAEV,CAAC;CACE,CAAA;AAET"}
@@ -0,0 +1,72 @@
1
+ .puzzle-rating {
2
+ align-items: center;
3
+ gap: var(--puzzle-space-1, .25rem);
4
+ width: fit-content;
5
+ color: var(--puzzle-rating-color);
6
+ cursor: pointer;
7
+ touch-action: manipulation;
8
+ -webkit-tap-highlight-color: transparent;
9
+ direction: ltr;
10
+ display: inline-flex;
11
+ }
12
+
13
+ .puzzle-rating__star {
14
+ color: var(--puzzle-rating-empty-color);
15
+ user-select: none;
16
+ flex: none;
17
+ justify-content: center;
18
+ align-items: center;
19
+ line-height: 1;
20
+ display: inline-flex;
21
+ }
22
+
23
+ .puzzle-rating__star[data-state="full"], .puzzle-rating__star[data-state="half"] {
24
+ color: var(--puzzle-rating-color);
25
+ }
26
+
27
+ .puzzle-rating__star svg {
28
+ display: block;
29
+ }
30
+
31
+ .puzzle-rating:focus-visible {
32
+ outline: 2px solid var(--puzzle-color-ring);
33
+ outline-offset: 3px;
34
+ border-radius: var(--puzzle-radius-sm, .25rem);
35
+ }
36
+
37
+ .puzzle-rating-disabled {
38
+ cursor: not-allowed;
39
+ opacity: .55;
40
+ }
41
+
42
+ .puzzle-rating-readonly {
43
+ cursor: default;
44
+ }
45
+
46
+ .puzzle-rating[data-size="sm"] {
47
+ gap: var(--puzzle-space-1, .25rem);
48
+ }
49
+
50
+ .puzzle-rating[data-size="lg"] {
51
+ gap: var(--puzzle-space-2, .5rem);
52
+ }
53
+
54
+ @media (forced-colors: active) {
55
+ .puzzle-rating__star {
56
+ color: graytext;
57
+ }
58
+
59
+ .puzzle-rating__star[data-state="full"], .puzzle-rating__star[data-state="half"] {
60
+ color: highlight;
61
+ }
62
+
63
+ .puzzle-rating:focus-visible {
64
+ outline-color: highlight;
65
+ }
66
+ }
67
+
68
+ @media (prefers-reduced-motion: reduce) {
69
+ .puzzle-rating, .puzzle-rating__star {
70
+ transition: none;
71
+ }
72
+ }
@@ -0,0 +1,15 @@
1
+ import { ComponentPropsWithRef } from "react";
2
+ type RatingSize = "sm" | "md" | "lg";
3
+ type RatingProps = Omit<ComponentPropsWithRef<"div">, "children" | "defaultValue" | "role" | "value"> & {
4
+ value?: number;
5
+ defaultValue?: number;
6
+ onValueChange?: (value: number) => void;
7
+ max?: number;
8
+ precision?: 0.5 | 1;
9
+ size?: RatingSize;
10
+ readOnly?: boolean;
11
+ disabled?: boolean;
12
+ color?: string;
13
+ emptyColor?: string;
14
+ };
15
+ export type { RatingProps, RatingSize };
@@ -0,0 +1,15 @@
1
+ import { ComponentPropsWithRef } from "react";
2
+ type RatingSize = "sm" | "md" | "lg";
3
+ type RatingProps = Omit<ComponentPropsWithRef<"div">, "children" | "defaultValue" | "role" | "value"> & {
4
+ value?: number;
5
+ defaultValue?: number;
6
+ onValueChange?: (value: number) => void;
7
+ max?: number;
8
+ precision?: 0.5 | 1;
9
+ size?: RatingSize;
10
+ readOnly?: boolean;
11
+ disabled?: boolean;
12
+ color?: string;
13
+ emptyColor?: string;
14
+ };
15
+ export type { RatingProps, RatingSize };
@@ -0,0 +1,27 @@
1
+ // src/components/data-display/rating/rating.utils.ts
2
+ const normalizeRating = (value, max, precision) => {
3
+ if (!Number.isFinite(value)) return 0;
4
+ return Math.round(Math.min(max, Math.max(0, value)) / precision) * precision;
5
+ };
6
+ const getRatingStarState = (value, index) => {
7
+ const remainder = value - index;
8
+ if (remainder >= 1) return "full";
9
+ if (remainder >= .5) return "half";
10
+ return "empty";
11
+ };
12
+ const getNextRating = (value, key, max, precision) => {
13
+ switch (key) {
14
+ case "ArrowRight":
15
+ case "ArrowUp": return normalizeRating(value + precision, max, precision);
16
+ case "ArrowLeft":
17
+ case "ArrowDown": return normalizeRating(value - precision, max, precision);
18
+ case "Home": return 0;
19
+ case "End": return max;
20
+ default: return;
21
+ }
22
+ };
23
+ exports.getNextRating = getNextRating;
24
+ exports.getRatingStarState = getRatingStarState;
25
+ exports.normalizeRating = normalizeRating;
26
+
27
+ //# sourceMappingURL=rating.utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rating.utils.cjs","names":[],"sources":["../../../../src/components/data-display/rating/rating.utils.ts"],"sourcesContent":["const normalizeRating = (value: number, max: number, precision: 0.5 | 1) => {\n if (!Number.isFinite(value)) {\n return 0;\n }\n\n const clamped = Math.min(max, Math.max(0, value));\n\n return Math.round(clamped / precision) * precision;\n};\n\nconst getRatingStarState = (value: number, index: number) => {\n const remainder = value - index;\n\n if (remainder >= 1) {\n return \"full\" as const;\n }\n\n if (remainder >= 0.5) {\n return \"half\" as const;\n }\n\n return \"empty\" as const;\n};\n\nconst getNextRating = (\n value: number,\n key: string,\n max: number,\n precision: 0.5 | 1,\n) => {\n switch (key) {\n case \"ArrowRight\":\n case \"ArrowUp\":\n return normalizeRating(value + precision, max, precision);\n\n case \"ArrowLeft\":\n case \"ArrowDown\":\n return normalizeRating(value - precision, max, precision);\n\n case \"Home\":\n return 0;\n\n case \"End\":\n return max;\n\n default:\n return undefined;\n }\n};\n\nexport { normalizeRating, getRatingStarState, getNextRating };\n"],"mappings":";AAAA,MAAM,mBAAmB,OAAe,KAAa,cAAuB;CAC1E,IAAI,CAAC,OAAO,SAAS,KAAK,GACxB,OAAO;CAKT,OAAO,KAAK,MAFI,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,KAAK,CAEvB,IAAI,SAAS,IAAI;AAC3C;AAEA,MAAM,sBAAsB,OAAe,UAAkB;CAC3D,MAAM,YAAY,QAAQ;CAE1B,IAAI,aAAa,GACf,OAAO;CAGT,IAAI,aAAa,IACf,OAAO;CAGT,OAAO;AACT;AAEA,MAAM,iBACJ,OACA,KACA,KACA,cACG;CACH,QAAQ,KAAR;EACE,KAAK;EACL,KAAK,WACH,OAAO,gBAAgB,QAAQ,WAAW,KAAK,SAAS;EAE1D,KAAK;EACL,KAAK,aACH,OAAO,gBAAgB,QAAQ,WAAW,KAAK,SAAS;EAE1D,KAAK,QACH,OAAO;EAET,KAAK,OACH,OAAO;EAET,SACE;CACJ;AACF"}
@@ -0,0 +1,25 @@
1
+ // src/components/data-display/rating/rating.utils.ts
2
+ const normalizeRating = (value, max, precision) => {
3
+ if (!Number.isFinite(value)) return 0;
4
+ return Math.round(Math.min(max, Math.max(0, value)) / precision) * precision;
5
+ };
6
+ const getRatingStarState = (value, index) => {
7
+ const remainder = value - index;
8
+ if (remainder >= 1) return "full";
9
+ if (remainder >= .5) return "half";
10
+ return "empty";
11
+ };
12
+ const getNextRating = (value, key, max, precision) => {
13
+ switch (key) {
14
+ case "ArrowRight":
15
+ case "ArrowUp": return normalizeRating(value + precision, max, precision);
16
+ case "ArrowLeft":
17
+ case "ArrowDown": return normalizeRating(value - precision, max, precision);
18
+ case "Home": return 0;
19
+ case "End": return max;
20
+ default: return;
21
+ }
22
+ };
23
+ export { getNextRating, getRatingStarState, normalizeRating };
24
+
25
+ //# sourceMappingURL=rating.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rating.utils.js","names":[],"sources":["../../../../src/components/data-display/rating/rating.utils.ts"],"sourcesContent":["const normalizeRating = (value: number, max: number, precision: 0.5 | 1) => {\n if (!Number.isFinite(value)) {\n return 0;\n }\n\n const clamped = Math.min(max, Math.max(0, value));\n\n return Math.round(clamped / precision) * precision;\n};\n\nconst getRatingStarState = (value: number, index: number) => {\n const remainder = value - index;\n\n if (remainder >= 1) {\n return \"full\" as const;\n }\n\n if (remainder >= 0.5) {\n return \"half\" as const;\n }\n\n return \"empty\" as const;\n};\n\nconst getNextRating = (\n value: number,\n key: string,\n max: number,\n precision: 0.5 | 1,\n) => {\n switch (key) {\n case \"ArrowRight\":\n case \"ArrowUp\":\n return normalizeRating(value + precision, max, precision);\n\n case \"ArrowLeft\":\n case \"ArrowDown\":\n return normalizeRating(value - precision, max, precision);\n\n case \"Home\":\n return 0;\n\n case \"End\":\n return max;\n\n default:\n return undefined;\n }\n};\n\nexport { normalizeRating, getRatingStarState, getNextRating };\n"],"mappings":";AAAA,MAAM,mBAAmB,OAAe,KAAa,cAAuB;CAC1E,IAAI,CAAC,OAAO,SAAS,KAAK,GACxB,OAAO;CAKT,OAAO,KAAK,MAFI,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,KAAK,CAEvB,IAAI,SAAS,IAAI;AAC3C;AAEA,MAAM,sBAAsB,OAAe,UAAkB;CAC3D,MAAM,YAAY,QAAQ;CAE1B,IAAI,aAAa,GACf,OAAO;CAGT,IAAI,aAAa,IACf,OAAO;CAGT,OAAO;AACT;AAEA,MAAM,iBACJ,OACA,KACA,KACA,cACG;CACH,QAAQ,KAAR;EACE,KAAK;EACL,KAAK,WACH,OAAO,gBAAgB,QAAQ,WAAW,KAAK,SAAS;EAE1D,KAAK;EACL,KAAK,aACH,OAAO,gBAAgB,QAAQ,WAAW,KAAK,SAAS;EAE1D,KAAK,QACH,OAAO;EAET,KAAK,OACH,OAAO;EAET,SACE;CACJ;AACF"}
@@ -64,19 +64,11 @@
64
64
 
65
65
  .puzzle-checkbox .puzzle-checkbox__check, .puzzle-checkbox .puzzle-checkbox__mixed {
66
66
  transform-origin: center;
67
- transform: scale(.8);
68
- }
69
-
70
- .puzzle-checkbox--checked .puzzle-checkbox__check {
71
- fill: currentColor;
72
- display: block;
73
- }
74
-
75
- .puzzle-checkbox--checked .puzzle-checkbox__mixed, .puzzle-checkbox--indeterminate .puzzle-checkbox__indicator .puzzle-checkbox__check {
76
67
  display: none;
68
+ transform: scale(.8);
77
69
  }
78
70
 
79
- .puzzle-checkbox--indeterminate .puzzle-checkbox__indicator .puzzle-checkbox__mixed {
71
+ .puzzle-checkbox__control input:checked:not(:indeterminate) + .puzzle-checkbox__indicator .puzzle-checkbox__check, .puzzle-checkbox__control input:indeterminate + .puzzle-checkbox__indicator .puzzle-checkbox__mixed {
80
72
  fill: currentColor;
81
73
  display: block;
82
74
  }
@@ -1,5 +1,7 @@
1
1
  import { InputGroupAddonProps, InputGroupProps } from "./input-group.types.cjs";
2
- declare const InputGroup: (({ className, ...props }: InputGroupProps) => import("react").JSX.Element) & {
3
- Addon: ({ align, className, ...props }: InputGroupAddonProps) => import("react").JSX.Element;
2
+ declare const InputGroupAddon: ({ align, className, ...props }: InputGroupAddonProps) => import("react").JSX.Element;
3
+ declare const InputGroupRoot: ({ className, ...props }: InputGroupProps) => import("react").JSX.Element;
4
+ declare const InputGroup: typeof InputGroupRoot & {
5
+ Addon: typeof InputGroupAddon;
4
6
  };
5
7
  export { InputGroup };
@@ -1,5 +1,7 @@
1
1
  import { InputGroupAddonProps, InputGroupProps } from "./input-group.types.js";
2
- declare const InputGroup: (({ className, ...props }: InputGroupProps) => import("react").JSX.Element) & {
3
- Addon: ({ align, className, ...props }: InputGroupAddonProps) => import("react").JSX.Element;
2
+ declare const InputGroupAddon: ({ align, className, ...props }: InputGroupAddonProps) => import("react").JSX.Element;
3
+ declare const InputGroupRoot: ({ className, ...props }: InputGroupProps) => import("react").JSX.Element;
4
+ declare const InputGroup: typeof InputGroupRoot & {
5
+ Addon: typeof InputGroupAddon;
4
6
  };
5
7
  export { InputGroup };
@@ -1,5 +1,6 @@
1
1
  import { RadioGroupOrientation, RadioGroupProps, RadioGroupSize, RadioProps } from "./radio-group.types.cjs";
2
2
  import { ReactElement } from "react";
3
3
  declare const Radio: ({ value, label, children, description, disabled, className, style, id, ref, onChange, onFocus, onKeyDown, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ...inputProps }: RadioProps) => import("react").JSX.Element;
4
- declare const RadioGroup: ({ value, defaultValue, onValueChange, name, form, label, description, error, invalid, required, disabled, orientation, size, dir, loop, children, id, className, style, role, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-labelledby": ariaLabelledBy, ...rootProps }: RadioGroupProps) => ReactElement;
4
+ declare const RadioGroupRoot: ({ value, defaultValue, onValueChange, name, form, label, description, error, invalid, required, disabled, orientation, size, dir, loop, children, id, className, style, role, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-labelledby": ariaLabelledBy, ...rootProps }: RadioGroupProps) => ReactElement;
5
+ declare const RadioGroup: typeof RadioGroupRoot;
5
6
  export { Radio, RadioGroup, type RadioGroupOrientation, type RadioGroupProps, type RadioGroupSize, type RadioProps };
@@ -1,5 +1,6 @@
1
1
  import { RadioGroupOrientation, RadioGroupProps, RadioGroupSize, RadioProps } from "./radio-group.types.js";
2
2
  import { ReactElement } from "react";
3
3
  declare const Radio: ({ value, label, children, description, disabled, className, style, id, ref, onChange, onFocus, onKeyDown, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ...inputProps }: RadioProps) => import("react").JSX.Element;
4
- declare const RadioGroup: ({ value, defaultValue, onValueChange, name, form, label, description, error, invalid, required, disabled, orientation, size, dir, loop, children, id, className, style, role, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-labelledby": ariaLabelledBy, ...rootProps }: RadioGroupProps) => ReactElement;
4
+ declare const RadioGroupRoot: ({ value, defaultValue, onValueChange, name, form, label, description, error, invalid, required, disabled, orientation, size, dir, loop, children, id, className, style, role, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-labelledby": ariaLabelledBy, ...rootProps }: RadioGroupProps) => ReactElement;
5
+ declare const RadioGroup: typeof RadioGroupRoot;
5
6
  export { Radio, RadioGroup, type RadioGroupOrientation, type RadioGroupProps, type RadioGroupSize, type RadioProps };
@@ -42,7 +42,9 @@ type StepperProps = Omit<ComponentPropsWithoutRef<"ol">, "children"> & {
42
42
  linear?: boolean;
43
43
  children: ReactNode;
44
44
  };
45
- declare const Stepper: (({ activeStep, activeStepId, defaultActiveStep, defaultActiveStepId, onStepChange, onStepIdChange, orientation, clickable, linear, children, className, ...rootProps }: StepperProps) => import("react").JSX.Element) & {
46
- Step: (_props: StepperStepProps) => null;
45
+ declare const StepperStep: (_props: StepperStepProps) => null;
46
+ declare const StepperRoot: ({ activeStep, activeStepId, defaultActiveStep, defaultActiveStepId, onStepChange, onStepIdChange, orientation, clickable, linear, children, className, ...rootProps }: StepperProps) => import("react").JSX.Element;
47
+ declare const Stepper: typeof StepperRoot & {
48
+ Step: typeof StepperStep;
47
49
  };
48
50
  export { Stepper, type StepperOrientation, type StepperProps, type StepperStepProps };
@@ -42,7 +42,9 @@ type StepperProps = Omit<ComponentPropsWithoutRef<"ol">, "children"> & {
42
42
  linear?: boolean;
43
43
  children: ReactNode;
44
44
  };
45
- declare const Stepper: (({ activeStep, activeStepId, defaultActiveStep, defaultActiveStepId, onStepChange, onStepIdChange, orientation, clickable, linear, children, className, ...rootProps }: StepperProps) => import("react").JSX.Element) & {
46
- Step: (_props: StepperStepProps) => null;
45
+ declare const StepperStep: (_props: StepperStepProps) => null;
46
+ declare const StepperRoot: ({ activeStep, activeStepId, defaultActiveStep, defaultActiveStepId, onStepChange, onStepIdChange, orientation, clickable, linear, children, className, ...rootProps }: StepperProps) => import("react").JSX.Element;
47
+ declare const Stepper: typeof StepperRoot & {
48
+ Step: typeof StepperStep;
47
49
  };
48
50
  export { Stepper, type StepperOrientation, type StepperProps, type StepperStepProps };
@@ -0,0 +1,108 @@
1
+ "use client";
2
+ const require_time_picker_utils = require("./time-picker.utils.cjs");
3
+ ;/* empty css */
4
+ let _puzzle_ui_core = require("@puzzle-ui/core");
5
+ let react = require("react");
6
+ let react_jsx_runtime = require("react/jsx-runtime");
7
+ // src/components/forms/time-picker/index.tsx
8
+ const TimePicker = ({ value, defaultValue, onChange, label, description, error, disabled = false, readOnly = false, required = false, name, form, minTime, maxTime, minuteStep = 1, showSeconds = false, secondStep = 1, size = "md", fullWidth = false, rootClassName, className, id, style, onBlur, onFocus, onInvalid, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ...inputProps }) => {
9
+ const baseId = (0, react.useId)();
10
+ const inputId = id ?? `${baseId}-input`;
11
+ const labelId = `${baseId}-label`;
12
+ const descriptionId = `${baseId}-description`;
13
+ const errorId = `${baseId}-error`;
14
+ const isControlled = value !== void 0;
15
+ const selectedValue = require_time_picker_utils.normalizeTime(isControlled ? value : defaultValue, showSeconds);
16
+ const responsiveSize = (0, _puzzle_ui_core.resolveResponsiveValue)(size, "md");
17
+ const responsiveFullWidth = (0, _puzzle_ui_core.resolveResponsiveValue)(fullWidth, false);
18
+ const hasError = error !== void 0 && error !== null && error !== false;
19
+ const isInvalid = hasError || ariaInvalid !== void 0 && ariaInvalid !== false && ariaInvalid !== "false";
20
+ const resolvedAriaInvalid = isInvalid ? true : ariaInvalid;
21
+ const errorContent = error === true ? "Invalid time" : error;
22
+ const resolvedLabelledBy = ariaLabelledBy ?? (label != null ? labelId : void 0);
23
+ const resolvedDescribedBy = [
24
+ ariaDescribedBy,
25
+ description != null ? descriptionId : void 0,
26
+ hasError ? errorId : void 0
27
+ ].filter(Boolean).join(" ") || void 0;
28
+ const isConfigurationInvalid = (0, react.useMemo)(() => {
29
+ const min = require_time_picker_utils.parseTime(minTime);
30
+ const max = require_time_picker_utils.parseTime(maxTime);
31
+ return minTime != null && min === null || maxTime != null && max === null || min !== null && max !== null && min > max || !Number.isInteger(minuteStep) || minuteStep < 1 || minuteStep > 60 || !Number.isInteger(secondStep) || secondStep < 1 || secondStep > 60;
32
+ }, [
33
+ minTime,
34
+ maxTime,
35
+ minuteStep,
36
+ secondStep
37
+ ]);
38
+ const step = showSeconds ? secondStep : minuteStep * 60;
39
+ const handleChange = (event) => {
40
+ const nextValue = require_time_picker_utils.normalizeTime(event.currentTarget.value, showSeconds);
41
+ onChange?.(nextValue);
42
+ };
43
+ const inputValue = selectedValue ?? "";
44
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
45
+ className: (0, _puzzle_ui_core.cn)("puzzle-time-picker", rootClassName),
46
+ "data-disabled": disabled ? "true" : void 0,
47
+ "data-readonly": readOnly ? "true" : void 0,
48
+ "data-invalid": isInvalid ? "true" : void 0,
49
+ "data-size-mobile": responsiveSize.mobile,
50
+ "data-size-tablet": responsiveSize.tablet,
51
+ "data-size-desktop": responsiveSize.desktop,
52
+ "data-full-width-mobile": String(responsiveFullWidth.mobile),
53
+ "data-full-width-tablet": String(responsiveFullWidth.tablet),
54
+ "data-full-width-desktop": String(responsiveFullWidth.desktop),
55
+ children: [
56
+ label != null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
57
+ id: labelId,
58
+ className: "puzzle-time-picker__label",
59
+ htmlFor: inputId,
60
+ children: [label, required && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
61
+ className: "puzzle-time-picker__required",
62
+ "aria-hidden": "true",
63
+ children: "*"
64
+ })]
65
+ }),
66
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
67
+ ...inputProps,
68
+ id: inputId,
69
+ type: "time",
70
+ name,
71
+ form,
72
+ value: isControlled ? inputValue : void 0,
73
+ defaultValue: !isControlled ? inputValue : void 0,
74
+ disabled: disabled || isConfigurationInvalid,
75
+ readOnly,
76
+ required,
77
+ min: minTime,
78
+ max: maxTime,
79
+ step,
80
+ style,
81
+ className: (0, _puzzle_ui_core.cn)("puzzle-time-picker__input", className),
82
+ onChange: handleChange,
83
+ onBlur,
84
+ onFocus,
85
+ onInvalid,
86
+ "aria-label": ariaLabel,
87
+ "aria-labelledby": resolvedLabelledBy,
88
+ "aria-describedby": resolvedDescribedBy,
89
+ "aria-invalid": resolvedAriaInvalid,
90
+ "aria-required": required || void 0
91
+ }),
92
+ description != null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
93
+ id: descriptionId,
94
+ className: "puzzle-time-picker__description",
95
+ children: description
96
+ }),
97
+ hasError && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
98
+ id: errorId,
99
+ className: "puzzle-time-picker__error",
100
+ role: "alert",
101
+ children: errorContent
102
+ })
103
+ ]
104
+ });
105
+ };
106
+ exports.TimePicker = TimePicker;
107
+
108
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["useId","normalizeTime","resolveResponsiveValue","useMemo","parseTime","cn"],"sources":["../../../../src/components/forms/time-picker/index.tsx"],"sourcesContent":["\"use client\";\n\nimport { useId, useMemo, type ChangeEvent } from \"react\";\n\nimport { cn, resolveResponsiveValue } from \"@puzzle-ui/core\";\n\nimport { normalizeTime, parseTime } from \"./time-picker.utils\";\n\nimport type { TimePickerProps } from \"./time-picker.types\";\n\nimport \"./time-picker.css\";\n\nconst TimePicker = ({\n value,\n defaultValue,\n onChange,\n label,\n description,\n error,\n disabled = false,\n readOnly = false,\n required = false,\n name,\n form,\n minTime,\n maxTime,\n minuteStep = 1,\n showSeconds = false,\n secondStep = 1,\n size = \"md\",\n fullWidth = false,\n rootClassName,\n className,\n id,\n style,\n onBlur,\n onFocus,\n onInvalid,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-invalid\": ariaInvalid,\n ...inputProps\n}: TimePickerProps) => {\n const baseId = useId();\n\n const inputId = id ?? `${baseId}-input`;\n const labelId = `${baseId}-label`;\n const descriptionId = `${baseId}-description`;\n const errorId = `${baseId}-error`;\n\n const isControlled = value !== undefined;\n\n const selectedValue = normalizeTime(\n isControlled ? value : defaultValue,\n showSeconds,\n );\n\n const responsiveSize = resolveResponsiveValue(size, \"md\");\n const responsiveFullWidth = resolveResponsiveValue(fullWidth, false);\n\n const hasError = error !== undefined && error !== null && error !== false;\n\n const isAriaInvalid =\n ariaInvalid !== undefined &&\n ariaInvalid !== false &&\n ariaInvalid !== \"false\";\n\n const isInvalid = hasError || isAriaInvalid;\n\n const resolvedAriaInvalid = isInvalid ? true : ariaInvalid;\n\n const errorContent = error === true ? \"Invalid time\" : error;\n\n const resolvedLabelledBy =\n ariaLabelledBy ?? (label != null ? labelId : undefined);\n\n const resolvedDescribedBy =\n [\n ariaDescribedBy,\n description != null ? descriptionId : undefined,\n hasError ? errorId : undefined,\n ]\n .filter(Boolean)\n .join(\" \") || undefined;\n\n const isConfigurationInvalid = useMemo(() => {\n const min = parseTime(minTime);\n const max = parseTime(maxTime);\n\n return (\n (minTime != null && min === null) ||\n (maxTime != null && max === null) ||\n (min !== null && max !== null && min > max) ||\n !Number.isInteger(minuteStep) ||\n minuteStep < 1 ||\n minuteStep > 60 ||\n !Number.isInteger(secondStep) ||\n secondStep < 1 ||\n secondStep > 60\n );\n }, [minTime, maxTime, minuteStep, secondStep]);\n\n const step = showSeconds ? secondStep : minuteStep * 60;\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const nextValue = normalizeTime(event.currentTarget.value, showSeconds);\n\n onChange?.(nextValue);\n };\n\n const inputValue = selectedValue ?? \"\";\n\n return (\n <div\n className={cn(\"puzzle-time-picker\", rootClassName)}\n data-disabled={disabled ? \"true\" : undefined}\n data-readonly={readOnly ? \"true\" : undefined}\n data-invalid={isInvalid ? \"true\" : undefined}\n data-size-mobile={responsiveSize.mobile}\n data-size-tablet={responsiveSize.tablet}\n data-size-desktop={responsiveSize.desktop}\n data-full-width-mobile={String(responsiveFullWidth.mobile)}\n data-full-width-tablet={String(responsiveFullWidth.tablet)}\n data-full-width-desktop={String(responsiveFullWidth.desktop)}\n >\n {label != null && (\n <label\n id={labelId}\n className=\"puzzle-time-picker__label\"\n htmlFor={inputId}\n >\n {label}\n {required && (\n <span className=\"puzzle-time-picker__required\" aria-hidden=\"true\">\n *\n </span>\n )}\n </label>\n )}\n\n <input\n {...inputProps}\n id={inputId}\n type=\"time\"\n name={name}\n form={form}\n value={isControlled ? inputValue : undefined}\n defaultValue={!isControlled ? inputValue : undefined}\n disabled={disabled || isConfigurationInvalid}\n readOnly={readOnly}\n required={required}\n min={minTime}\n max={maxTime}\n step={step}\n style={style}\n className={cn(\"puzzle-time-picker__input\", className)}\n onChange={handleChange}\n onBlur={onBlur}\n onFocus={onFocus}\n onInvalid={onInvalid}\n aria-label={ariaLabel}\n aria-labelledby={resolvedLabelledBy}\n aria-describedby={resolvedDescribedBy}\n aria-invalid={resolvedAriaInvalid}\n aria-required={required || undefined}\n />\n\n {description != null && (\n <div id={descriptionId} className=\"puzzle-time-picker__description\">\n {description}\n </div>\n )}\n\n {hasError && (\n <div id={errorId} className=\"puzzle-time-picker__error\" role=\"alert\">\n {errorContent}\n </div>\n )}\n </div>\n );\n};\n\nexport { TimePicker };\nexport type { TimePickerProps, TimePickerSize } from \"./time-picker.types\";\n"],"mappings":";;;;;;;AAYA,MAAM,cAAc,EAClB,OACA,cACA,UACA,OACA,aACA,OACA,WAAW,OACX,WAAW,OACX,WAAW,OACX,MACA,MACA,SACA,SACA,aAAa,GACb,cAAc,OACd,aAAa,GACb,OAAO,MACP,YAAY,OACZ,eACA,WACA,IACA,OACA,QACA,SACA,WACA,cAAc,WACd,mBAAmB,gBACnB,oBAAoB,iBACpB,gBAAgB,aAChB,GAAG,iBACkB;CACrB,MAAM,UAAA,GAASA,MAAAA,MAAAA,CAAM;CAErB,MAAM,UAAU,MAAM,GAAG,OAAO;CAChC,MAAM,UAAU,GAAG,OAAO;CAC1B,MAAM,gBAAgB,GAAG,OAAO;CAChC,MAAM,UAAU,GAAG,OAAO;CAE1B,MAAM,eAAe,UAAU,KAAA;CAE/B,MAAM,gBAAgBC,0BAAAA,cACpB,eAAe,QAAQ,cACvB,WACF;CAEA,MAAM,kBAAA,GAAiBC,gBAAAA,uBAAAA,CAAuB,MAAM,IAAI;CACxD,MAAM,uBAAA,GAAsBA,gBAAAA,uBAAAA,CAAuB,WAAW,KAAK;CAEnE,MAAM,WAAW,UAAU,KAAA,KAAa,UAAU,QAAQ,UAAU;CAOpE,MAAM,YAAY,YAJhB,gBAAgB,KAAA,KAChB,gBAAgB,SAChB,gBAAgB;CAIlB,MAAM,sBAAsB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AA,CAAC,SAAD;IACE,IAAI;IACJ,WAAU;IACV,SAAS;IAHX,UAAA,CAKG,OACA,YACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;KAAM,WAAU;KAA+B,eAAY;KAAO,UAAA;IAE5D,CAAA,CAEH;;GAGT,iBAAA,GAAA,kBAAA,IAAA,CAAC,SAAD;IACE,GAAI;IACJ,IAAI;IACJ,MAAK;IACC;IACA;IACN,OAAO,eAAe,aAAa,KAAA;IACnC,cAAc,CAAC,eAAe,aAAa,KAAA;IAC3C,UAAU,YAAY;IACZ;IACA;IACV,KAAK;IACL,KAAK;IACC;IACC;IACP,YAAA,GAAWA,gBAAAA,GAAAA,CAAG,6BAA6B,SAAS;IACpD,UAAU;IACF;IACC;IACE;IACX,cAAY;IACZ,mBAAiB;IACjB,oBAAkB;IAClB,gBAAc;IACd,iBAAe,YAAY,KAAA;GAC5B,CAAA;GAEA,eAAe,QACd,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IAAK,IAAI;IAAe,WAAU;IAC/B,UAAA;GACE,CAAA;GAGN,YACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IAAK,IAAI;IAAS,WAAU;IAA4B,MAAK;IAC1D,UAAA;GACE,CAAA;EAEJ;;AAET"}
@@ -0,0 +1,3 @@
1
+ import { TimePickerProps, TimePickerSize } from "./time-picker.types.cjs";
2
+ declare const TimePicker: ({ value, defaultValue, onChange, label, description, error, disabled, readOnly, required, name, form, minTime, maxTime, minuteStep, showSeconds, secondStep, size, fullWidth, rootClassName, className, id, style, onBlur, onFocus, onInvalid, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ...inputProps }: TimePickerProps) => import("react").JSX.Element;
3
+ export { TimePicker, type TimePickerProps, type TimePickerSize };
@@ -0,0 +1,3 @@
1
+ import { TimePickerProps, TimePickerSize } from "./time-picker.types.js";
2
+ declare const TimePicker: ({ value, defaultValue, onChange, label, description, error, disabled, readOnly, required, name, form, minTime, maxTime, minuteStep, showSeconds, secondStep, size, fullWidth, rootClassName, className, id, style, onBlur, onFocus, onInvalid, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ...inputProps }: TimePickerProps) => import("react").JSX.Element;
3
+ export { TimePicker, type TimePickerProps, type TimePickerSize };
@@ -0,0 +1,108 @@
1
+ "use client";
2
+ import { normalizeTime, parseTime } from "./time-picker.utils.js";
3
+ import "./time-picker.css";
4
+ import { cn, resolveResponsiveValue } from "@puzzle-ui/core";
5
+ import { useId, useMemo } from "react";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ // src/components/forms/time-picker/index.tsx
8
+ const TimePicker = ({ value, defaultValue, onChange, label, description, error, disabled = false, readOnly = false, required = false, name, form, minTime, maxTime, minuteStep = 1, showSeconds = false, secondStep = 1, size = "md", fullWidth = false, rootClassName, className, id, style, onBlur, onFocus, onInvalid, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ...inputProps }) => {
9
+ const baseId = useId();
10
+ const inputId = id ?? `${baseId}-input`;
11
+ const labelId = `${baseId}-label`;
12
+ const descriptionId = `${baseId}-description`;
13
+ const errorId = `${baseId}-error`;
14
+ const isControlled = value !== void 0;
15
+ const selectedValue = normalizeTime(isControlled ? value : defaultValue, showSeconds);
16
+ const responsiveSize = resolveResponsiveValue(size, "md");
17
+ const responsiveFullWidth = resolveResponsiveValue(fullWidth, false);
18
+ const hasError = error !== void 0 && error !== null && error !== false;
19
+ const isInvalid = hasError || ariaInvalid !== void 0 && ariaInvalid !== false && ariaInvalid !== "false";
20
+ const resolvedAriaInvalid = isInvalid ? true : ariaInvalid;
21
+ const errorContent = error === true ? "Invalid time" : error;
22
+ const resolvedLabelledBy = ariaLabelledBy ?? (label != null ? labelId : void 0);
23
+ const resolvedDescribedBy = [
24
+ ariaDescribedBy,
25
+ description != null ? descriptionId : void 0,
26
+ hasError ? errorId : void 0
27
+ ].filter(Boolean).join(" ") || void 0;
28
+ const isConfigurationInvalid = useMemo(() => {
29
+ const min = parseTime(minTime);
30
+ const max = parseTime(maxTime);
31
+ return minTime != null && min === null || maxTime != null && max === null || min !== null && max !== null && min > max || !Number.isInteger(minuteStep) || minuteStep < 1 || minuteStep > 60 || !Number.isInteger(secondStep) || secondStep < 1 || secondStep > 60;
32
+ }, [
33
+ minTime,
34
+ maxTime,
35
+ minuteStep,
36
+ secondStep
37
+ ]);
38
+ const step = showSeconds ? secondStep : minuteStep * 60;
39
+ const handleChange = (event) => {
40
+ const nextValue = normalizeTime(event.currentTarget.value, showSeconds);
41
+ onChange?.(nextValue);
42
+ };
43
+ const inputValue = selectedValue ?? "";
44
+ return /* @__PURE__ */ jsxs("div", {
45
+ className: cn("puzzle-time-picker", rootClassName),
46
+ "data-disabled": disabled ? "true" : void 0,
47
+ "data-readonly": readOnly ? "true" : void 0,
48
+ "data-invalid": isInvalid ? "true" : void 0,
49
+ "data-size-mobile": responsiveSize.mobile,
50
+ "data-size-tablet": responsiveSize.tablet,
51
+ "data-size-desktop": responsiveSize.desktop,
52
+ "data-full-width-mobile": String(responsiveFullWidth.mobile),
53
+ "data-full-width-tablet": String(responsiveFullWidth.tablet),
54
+ "data-full-width-desktop": String(responsiveFullWidth.desktop),
55
+ children: [
56
+ label != null && /* @__PURE__ */ jsxs("label", {
57
+ id: labelId,
58
+ className: "puzzle-time-picker__label",
59
+ htmlFor: inputId,
60
+ children: [label, required && /* @__PURE__ */ jsx("span", {
61
+ className: "puzzle-time-picker__required",
62
+ "aria-hidden": "true",
63
+ children: "*"
64
+ })]
65
+ }),
66
+ /* @__PURE__ */ jsx("input", {
67
+ ...inputProps,
68
+ id: inputId,
69
+ type: "time",
70
+ name,
71
+ form,
72
+ value: isControlled ? inputValue : void 0,
73
+ defaultValue: !isControlled ? inputValue : void 0,
74
+ disabled: disabled || isConfigurationInvalid,
75
+ readOnly,
76
+ required,
77
+ min: minTime,
78
+ max: maxTime,
79
+ step,
80
+ style,
81
+ className: cn("puzzle-time-picker__input", className),
82
+ onChange: handleChange,
83
+ onBlur,
84
+ onFocus,
85
+ onInvalid,
86
+ "aria-label": ariaLabel,
87
+ "aria-labelledby": resolvedLabelledBy,
88
+ "aria-describedby": resolvedDescribedBy,
89
+ "aria-invalid": resolvedAriaInvalid,
90
+ "aria-required": required || void 0
91
+ }),
92
+ description != null && /* @__PURE__ */ jsx("div", {
93
+ id: descriptionId,
94
+ className: "puzzle-time-picker__description",
95
+ children: description
96
+ }),
97
+ hasError && /* @__PURE__ */ jsx("div", {
98
+ id: errorId,
99
+ className: "puzzle-time-picker__error",
100
+ role: "alert",
101
+ children: errorContent
102
+ })
103
+ ]
104
+ });
105
+ };
106
+ export { TimePicker };
107
+
108
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/forms/time-picker/index.tsx"],"sourcesContent":["\"use client\";\n\nimport { useId, useMemo, type ChangeEvent } from \"react\";\n\nimport { cn, resolveResponsiveValue } from \"@puzzle-ui/core\";\n\nimport { normalizeTime, parseTime } from \"./time-picker.utils\";\n\nimport type { TimePickerProps } from \"./time-picker.types\";\n\nimport \"./time-picker.css\";\n\nconst TimePicker = ({\n value,\n defaultValue,\n onChange,\n label,\n description,\n error,\n disabled = false,\n readOnly = false,\n required = false,\n name,\n form,\n minTime,\n maxTime,\n minuteStep = 1,\n showSeconds = false,\n secondStep = 1,\n size = \"md\",\n fullWidth = false,\n rootClassName,\n className,\n id,\n style,\n onBlur,\n onFocus,\n onInvalid,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-invalid\": ariaInvalid,\n ...inputProps\n}: TimePickerProps) => {\n const baseId = useId();\n\n const inputId = id ?? `${baseId}-input`;\n const labelId = `${baseId}-label`;\n const descriptionId = `${baseId}-description`;\n const errorId = `${baseId}-error`;\n\n const isControlled = value !== undefined;\n\n const selectedValue = normalizeTime(\n isControlled ? value : defaultValue,\n showSeconds,\n );\n\n const responsiveSize = resolveResponsiveValue(size, \"md\");\n const responsiveFullWidth = resolveResponsiveValue(fullWidth, false);\n\n const hasError = error !== undefined && error !== null && error !== false;\n\n const isAriaInvalid =\n ariaInvalid !== undefined &&\n ariaInvalid !== false &&\n ariaInvalid !== \"false\";\n\n const isInvalid = hasError || isAriaInvalid;\n\n const resolvedAriaInvalid = isInvalid ? true : ariaInvalid;\n\n const errorContent = error === true ? \"Invalid time\" : error;\n\n const resolvedLabelledBy =\n ariaLabelledBy ?? (label != null ? labelId : undefined);\n\n const resolvedDescribedBy =\n [\n ariaDescribedBy,\n description != null ? descriptionId : undefined,\n hasError ? errorId : undefined,\n ]\n .filter(Boolean)\n .join(\" \") || undefined;\n\n const isConfigurationInvalid = useMemo(() => {\n const min = parseTime(minTime);\n const max = parseTime(maxTime);\n\n return (\n (minTime != null && min === null) ||\n (maxTime != null && max === null) ||\n (min !== null && max !== null && min > max) ||\n !Number.isInteger(minuteStep) ||\n minuteStep < 1 ||\n minuteStep > 60 ||\n !Number.isInteger(secondStep) ||\n secondStep < 1 ||\n secondStep > 60\n );\n }, [minTime, maxTime, minuteStep, secondStep]);\n\n const step = showSeconds ? secondStep : minuteStep * 60;\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const nextValue = normalizeTime(event.currentTarget.value, showSeconds);\n\n onChange?.(nextValue);\n };\n\n const inputValue = selectedValue ?? \"\";\n\n return (\n <div\n className={cn(\"puzzle-time-picker\", rootClassName)}\n data-disabled={disabled ? \"true\" : undefined}\n data-readonly={readOnly ? \"true\" : undefined}\n data-invalid={isInvalid ? \"true\" : undefined}\n data-size-mobile={responsiveSize.mobile}\n data-size-tablet={responsiveSize.tablet}\n data-size-desktop={responsiveSize.desktop}\n data-full-width-mobile={String(responsiveFullWidth.mobile)}\n data-full-width-tablet={String(responsiveFullWidth.tablet)}\n data-full-width-desktop={String(responsiveFullWidth.desktop)}\n >\n {label != null && (\n <label\n id={labelId}\n className=\"puzzle-time-picker__label\"\n htmlFor={inputId}\n >\n {label}\n {required && (\n <span className=\"puzzle-time-picker__required\" aria-hidden=\"true\">\n *\n </span>\n )}\n </label>\n )}\n\n <input\n {...inputProps}\n id={inputId}\n type=\"time\"\n name={name}\n form={form}\n value={isControlled ? inputValue : undefined}\n defaultValue={!isControlled ? inputValue : undefined}\n disabled={disabled || isConfigurationInvalid}\n readOnly={readOnly}\n required={required}\n min={minTime}\n max={maxTime}\n step={step}\n style={style}\n className={cn(\"puzzle-time-picker__input\", className)}\n onChange={handleChange}\n onBlur={onBlur}\n onFocus={onFocus}\n onInvalid={onInvalid}\n aria-label={ariaLabel}\n aria-labelledby={resolvedLabelledBy}\n aria-describedby={resolvedDescribedBy}\n aria-invalid={resolvedAriaInvalid}\n aria-required={required || undefined}\n />\n\n {description != null && (\n <div id={descriptionId} className=\"puzzle-time-picker__description\">\n {description}\n </div>\n )}\n\n {hasError && (\n <div id={errorId} className=\"puzzle-time-picker__error\" role=\"alert\">\n {errorContent}\n </div>\n )}\n </div>\n );\n};\n\nexport { TimePicker };\nexport type { TimePickerProps, TimePickerSize } from \"./time-picker.types\";\n"],"mappings":";;;;;;;AAYA,MAAM,cAAc,EAClB,OACA,cACA,UACA,OACA,aACA,OACA,WAAW,OACX,WAAW,OACX,WAAW,OACX,MACA,MACA,SACA,SACA,aAAa,GACb,cAAc,OACd,aAAa,GACb,OAAO,MACP,YAAY,OACZ,eACA,WACA,IACA,OACA,QACA,SACA,WACA,cAAc,WACd,mBAAmB,gBACnB,oBAAoB,iBACpB,gBAAgB,aAChB,GAAG,iBACkB;CACrB,MAAM,SAAS,MAAM;CAErB,MAAM,UAAU,MAAM,GAAG,OAAO;CAChC,MAAM,UAAU,GAAG,OAAO;CAC1B,MAAM,gBAAgB,GAAG,OAAO;CAChC,MAAM,UAAU,GAAG,OA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