@mrpelz/uikit-ish 7.26.2 → 7.29.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 (210) hide show
  1. package/dist/components/accordion/style.css +0 -3
  2. package/dist/components/activity-view/style.css +17 -17
  3. package/dist/components/alert/style.css +12 -10
  4. package/dist/components/avatar/style.css +2 -2
  5. package/dist/components/badge/style.css +1 -1
  6. package/dist/components/button/style.css +12 -12
  7. package/dist/components/card/buttons.d.ts +35 -0
  8. package/dist/components/card/buttons.d.ts.map +1 -0
  9. package/dist/components/card/buttons.js +60 -0
  10. package/dist/components/card/buttons.js.map +1 -0
  11. package/dist/components/card/channels.d.ts +43 -0
  12. package/dist/components/card/channels.d.ts.map +1 -0
  13. package/dist/components/card/channels.js +321 -0
  14. package/dist/components/card/channels.js.map +1 -0
  15. package/dist/components/card/color.d.ts +21 -0
  16. package/dist/components/card/color.d.ts.map +1 -0
  17. package/dist/components/card/color.js +100 -0
  18. package/dist/components/card/color.js.map +1 -0
  19. package/dist/components/card/main.d.ts +67 -39
  20. package/dist/components/card/main.d.ts.map +1 -1
  21. package/dist/components/card/main.js +79 -274
  22. package/dist/components/card/main.js.map +1 -1
  23. package/dist/components/card/parts.css +769 -0
  24. package/dist/components/card/press.d.ts +25 -0
  25. package/dist/components/card/press.d.ts.map +1 -0
  26. package/dist/components/card/press.js +111 -0
  27. package/dist/components/card/press.js.map +1 -0
  28. package/dist/components/card/progress.d.ts +43 -0
  29. package/dist/components/card/progress.d.ts.map +1 -0
  30. package/dist/components/card/progress.js +122 -0
  31. package/dist/components/card/progress.js.map +1 -0
  32. package/dist/components/card/props.d.ts +324 -14
  33. package/dist/components/card/props.d.ts.map +1 -1
  34. package/dist/components/card/root.d.ts +100 -0
  35. package/dist/components/card/root.d.ts.map +1 -0
  36. package/dist/components/card/root.js +388 -0
  37. package/dist/components/card/root.js.map +1 -0
  38. package/dist/components/card/rows.d.ts +19 -0
  39. package/dist/components/card/rows.d.ts.map +1 -0
  40. package/dist/components/card/rows.js +185 -0
  41. package/dist/components/card/rows.js.map +1 -0
  42. package/dist/components/card/segmented.d.ts +61 -0
  43. package/dist/components/card/segmented.d.ts.map +1 -0
  44. package/dist/components/card/segmented.js +289 -0
  45. package/dist/components/card/segmented.js.map +1 -0
  46. package/dist/components/card/shared.d.ts +55 -0
  47. package/dist/components/card/shared.d.ts.map +1 -0
  48. package/dist/components/card/shared.js +80 -0
  49. package/dist/components/card/shared.js.map +1 -0
  50. package/dist/components/card/slider.d.ts +16 -0
  51. package/dist/components/card/slider.d.ts.map +1 -0
  52. package/dist/components/card/slider.js +48 -0
  53. package/dist/components/card/slider.js.map +1 -0
  54. package/dist/components/card/stages.d.ts +18 -0
  55. package/dist/components/card/stages.d.ts.map +1 -0
  56. package/dist/components/card/stages.js +37 -0
  57. package/dist/components/card/stages.js.map +1 -0
  58. package/dist/components/card/style.css +125 -66
  59. package/dist/components/checkbox/style.css +10 -5
  60. package/dist/components/collapsible/style.css +0 -3
  61. package/dist/components/color-picker/color.d.ts +2 -2
  62. package/dist/components/color-picker/color.d.ts.map +1 -1
  63. package/dist/components/color-picker/color.js +7 -7
  64. package/dist/components/color-picker/color.js.map +1 -1
  65. package/dist/components/color-picker/main.d.ts +11 -5
  66. package/dist/components/color-picker/main.d.ts.map +1 -1
  67. package/dist/components/color-picker/main.js +128 -57
  68. package/dist/components/color-picker/main.js.map +1 -1
  69. package/dist/components/color-picker/props.d.ts +216 -6
  70. package/dist/components/color-picker/props.d.ts.map +1 -1
  71. package/dist/components/color-picker/style.css +8 -8
  72. package/dist/components/control-cards/main.d.ts +6 -17
  73. package/dist/components/control-cards/main.d.ts.map +1 -1
  74. package/dist/components/control-cards/main.js +119 -758
  75. package/dist/components/control-cards/main.js.map +1 -1
  76. package/dist/components/control-cards/props.d.ts +79 -250
  77. package/dist/components/control-cards/props.d.ts.map +1 -1
  78. package/dist/components/control-cards/style.css +2 -492
  79. package/dist/components/date-picker/main.d.ts +8 -3
  80. package/dist/components/date-picker/main.d.ts.map +1 -1
  81. package/dist/components/date-picker/main.js +71 -29
  82. package/dist/components/date-picker/main.js.map +1 -1
  83. package/dist/components/date-picker/pager.d.ts.map +1 -1
  84. package/dist/components/date-picker/pager.js +9 -2
  85. package/dist/components/date-picker/pager.js.map +1 -1
  86. package/dist/components/date-picker/props.d.ts +81 -5
  87. package/dist/components/date-picker/props.d.ts.map +1 -1
  88. package/dist/components/date-picker/style.css +24 -16
  89. package/dist/components/edit-menu/style.css +2 -2
  90. package/dist/components/glass/style.css +38 -5
  91. package/dist/components/grid/main.d.ts +1 -1
  92. package/dist/components/grid/main.d.ts.map +1 -1
  93. package/dist/components/grid/main.js +104 -21
  94. package/dist/components/grid/main.js.map +1 -1
  95. package/dist/components/grid/props.d.ts +75 -5
  96. package/dist/components/grid/props.d.ts.map +1 -1
  97. package/dist/components/grid/style.css +68 -38
  98. package/dist/components/header/style.css +12 -6
  99. package/dist/components/index.d.ts +10 -8
  100. package/dist/components/index.d.ts.map +1 -1
  101. package/dist/components/index.js +6 -4
  102. package/dist/components/index.js.map +1 -1
  103. package/dist/components/layout/style.css +0 -3
  104. package/dist/components/list/main.d.ts +5 -3
  105. package/dist/components/list/main.d.ts.map +1 -1
  106. package/dist/components/list/main.js +42 -5
  107. package/dist/components/list/main.js.map +1 -1
  108. package/dist/components/list/props.d.ts +5 -0
  109. package/dist/components/list/props.d.ts.map +1 -1
  110. package/dist/components/list/reorder.d.ts +34 -0
  111. package/dist/components/list/reorder.d.ts.map +1 -1
  112. package/dist/components/list/reorder.js +40 -17
  113. package/dist/components/list/reorder.js.map +1 -1
  114. package/dist/components/list/style.css +135 -72
  115. package/dist/components/menu/style.css +38 -30
  116. package/dist/components/navigation/main.d.ts.map +1 -1
  117. package/dist/components/navigation/main.js +35 -13
  118. package/dist/components/navigation/main.js.map +1 -1
  119. package/dist/components/navigation/style.css +7 -0
  120. package/dist/components/page-control/main.d.ts.map +1 -1
  121. package/dist/components/page-control/main.js +32 -15
  122. package/dist/components/page-control/main.js.map +1 -1
  123. package/dist/components/page-control/props.d.ts +6 -0
  124. package/dist/components/page-control/props.d.ts.map +1 -1
  125. package/dist/components/page-control/style.css +36 -0
  126. package/dist/components/pager/main.d.ts +12 -0
  127. package/dist/components/pager/main.d.ts.map +1 -0
  128. package/dist/components/pager/main.js +368 -0
  129. package/dist/components/pager/main.js.map +1 -0
  130. package/dist/components/pager/props.d.ts +36 -0
  131. package/dist/components/pager/props.d.ts.map +1 -0
  132. package/dist/components/pager/props.js +2 -0
  133. package/dist/components/pager/props.js.map +1 -0
  134. package/dist/components/pager/style.css +42 -0
  135. package/dist/components/progress/main.d.ts.map +1 -1
  136. package/dist/components/progress/main.js +3 -2
  137. package/dist/components/progress/main.js.map +1 -1
  138. package/dist/components/progress/style.css +4 -10
  139. package/dist/components/roll/style.css +2 -2
  140. package/dist/components/segmented/style.css +16 -7
  141. package/dist/components/settings/main.d.ts +35 -1
  142. package/dist/components/settings/main.d.ts.map +1 -1
  143. package/dist/components/settings/main.js +297 -68
  144. package/dist/components/settings/main.js.map +1 -1
  145. package/dist/components/settings/props.d.ts +45 -4
  146. package/dist/components/settings/props.d.ts.map +1 -1
  147. package/dist/components/settings/region.d.ts +3 -0
  148. package/dist/components/settings/region.d.ts.map +1 -0
  149. package/dist/components/settings/region.js +120 -0
  150. package/dist/components/settings/region.js.map +1 -0
  151. package/dist/components/settings/style.css +2 -2
  152. package/dist/components/sheet/snap.d.ts.map +1 -1
  153. package/dist/components/sheet/snap.js +13 -5
  154. package/dist/components/sheet/snap.js.map +1 -1
  155. package/dist/components/sheet/style.css +48 -3
  156. package/dist/components/slider/main.d.ts.map +1 -1
  157. package/dist/components/slider/main.js +5 -2
  158. package/dist/components/slider/main.js.map +1 -1
  159. package/dist/components/slider/style.css +6 -6
  160. package/dist/components/stack/main.d.ts +8 -0
  161. package/dist/components/stack/main.d.ts.map +1 -0
  162. package/dist/components/stack/main.js +25 -0
  163. package/dist/components/stack/main.js.map +1 -0
  164. package/dist/components/stack/props.d.ts +42 -0
  165. package/dist/components/stack/props.d.ts.map +1 -0
  166. package/dist/components/stack/props.js +2 -0
  167. package/dist/components/stack/props.js.map +1 -0
  168. package/dist/components/stack/style.css +68 -0
  169. package/dist/components/stepper/main.d.ts +3 -1
  170. package/dist/components/stepper/main.d.ts.map +1 -1
  171. package/dist/components/stepper/main.js +4 -0
  172. package/dist/components/stepper/main.js.map +1 -1
  173. package/dist/components/stepper/style.css +2 -2
  174. package/dist/components/switch/main.d.ts.map +1 -1
  175. package/dist/components/switch/main.js +5 -1
  176. package/dist/components/switch/main.js.map +1 -1
  177. package/dist/components/switch/props.d.ts +4 -1
  178. package/dist/components/switch/props.d.ts.map +1 -1
  179. package/dist/components/tab-bar/style.css +36 -13
  180. package/dist/components/text-field/style.css +28 -17
  181. package/dist/components/toolbar/main.d.ts +5 -2
  182. package/dist/components/toolbar/main.d.ts.map +1 -1
  183. package/dist/components/toolbar/main.js +18 -0
  184. package/dist/components/toolbar/main.js.map +1 -1
  185. package/dist/components/toolbar/props.d.ts +15 -0
  186. package/dist/components/toolbar/props.d.ts.map +1 -1
  187. package/dist/components/toolbar/style.css +126 -10
  188. package/dist/components/tooltip/style.css +2 -2
  189. package/dist/components/typography/main.d.ts +1 -0
  190. package/dist/components/typography/main.d.ts.map +1 -1
  191. package/dist/components/typography/main.js +1 -0
  192. package/dist/components/typography/main.js.map +1 -1
  193. package/dist/components/typography/sizes.css +456 -0
  194. package/dist/components/typography/style.css +24 -456
  195. package/dist/components/utils/main.d.ts +23 -6
  196. package/dist/components/utils/main.d.ts.map +1 -1
  197. package/dist/components/utils/main.js +60 -7
  198. package/dist/components/utils/main.js.map +1 -1
  199. package/dist/components/viewport/edge-effect.d.ts.map +1 -1
  200. package/dist/components/viewport/edge-effect.js +6 -2
  201. package/dist/components/viewport/edge-effect.js.map +1 -1
  202. package/dist/components/viewport/focus-scroll.d.ts.map +1 -1
  203. package/dist/components/viewport/focus-scroll.js +2 -1
  204. package/dist/components/viewport/focus-scroll.js.map +1 -1
  205. package/dist/components/viewport/main.d.ts.map +1 -1
  206. package/dist/components/viewport/main.js +34 -2
  207. package/dist/components/viewport/main.js.map +1 -1
  208. package/dist/components/viewport/style.css +7 -13
  209. package/dist/styles.css +287 -120
  210. package/package.json +1 -1
@@ -0,0 +1,61 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type SymbolIcon } from '../symbol/main.js';
3
+ import type { CardSegmentedItemProps, CardSegmentedProps } from './props.js';
4
+ /** A segmented card's layout, by its tile's size (see `SegmentedCard`). */
5
+ export type SegmentedLayout = 'compact' | 'row' | 'tall' | 'upright';
6
+ /** Its layout (see `layoutOf`), and whether it's one wide (narrow). */
7
+ export declare const useSegmentedLayout: (orientation: CardSegmentedProps["orientation"]) => readonly [SegmentedLayout, boolean];
8
+ /** A segmented card's option, as it tells its card (see `SegmentedItem`). */
9
+ export type SegmentedOptionInfo = {
10
+ icon: SymbolIcon | undefined;
11
+ label: ReactNode;
12
+ tint: string | undefined;
13
+ };
14
+ /** What a segmented card's options read from it (see `SegmentedItem`). */
15
+ type SegmentedContextValue = {
16
+ content: 'both' | 'icon' | 'label';
17
+ layout: SegmentedLayout;
18
+ /** Tells it an option (its symbol, words, tint), until it's gone. */
19
+ register: (value: string, info: SegmentedOptionInfo) => () => void;
20
+ };
21
+ /**
22
+ * Its options, as they've told it (in the order they did: theirs), see
23
+ * `SegmentedItem`.
24
+ */
25
+ export declare const useSegmentedOptions: () => readonly [ReadonlyMap<string, SegmentedOptionInfo>, SegmentedContextValue["register"]];
26
+ /**
27
+ * What a ready-made card holding a choice tells it (see ControlCards'
28
+ * `Segmented`): where its options register too (their symbols, words,
29
+ * tints: its symbol and value the chosen one's), and where its value and
30
+ * layout go. Internal.
31
+ */
32
+ type SegmentedHost = {
33
+ register: SegmentedContextValue['register'];
34
+ report: (value: string, layout: SegmentedLayout) => void;
35
+ };
36
+ export declare const SegmentedHostContext: import("preact").Context<SegmentedHost | undefined>;
37
+ /**
38
+ * A card's choice of a few (Base UI's radio group; its options its
39
+ * children, see `SegmentedItem`; named by its card's title, or its
40
+ * `aria-label`): segments in a well at its bottom, laid out by its tile's
41
+ * size and its `orientation` (see `useSegmentedLayout`), the chosen one's
42
+ * raised (a thumb, moved to it as it's chosen, by its box: its corners the
43
+ * well's less its padding, a pill while short); dragged between (see
44
+ * `dragProps`). None shown (1x1): there all the same, unseen, its options
45
+ * telling a ready-made card theirs.
46
+ */
47
+ export declare const Segmented: import("preact").FunctionalComponent<import("react").PropsWithoutRef<CardSegmentedProps> & {
48
+ ref?: import("preact").Ref<HTMLDivElement> | undefined;
49
+ }>;
50
+ /**
51
+ * A choice's option (a radio, Base UI's): its symbol and its words
52
+ * (`children`), or either (its choice's `optionContent`; its symbol only,
53
+ * its words unseen, its name), a subtitle under them where there's room;
54
+ * telling its choice its symbol, words and tint (a ready-made card's value
55
+ * and symbol while it's chosen).
56
+ */
57
+ export declare const SegmentedItem: import("preact").FunctionalComponent<import("react").PropsWithoutRef<CardSegmentedItemProps> & {
58
+ ref?: import("preact").Ref<HTMLElement> | undefined;
59
+ }>;
60
+ export {};
61
+ //# sourceMappingURL=segmented.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"segmented.d.ts","sourceRoot":"","sources":["../../../src/components/card/segmented.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,SAAS,EAOf,MAAM,OAAO,CAAC;AAGf,OAAO,EAAU,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG5D,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAM7E,2EAA2E;AAC3E,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;AAuBrE,uEAAuE;AACvE,eAAO,MAAM,kBAAkB,GAC7B,aAAa,kBAAkB,CAAC,aAAa,CAAC,KAC7C,SAAS,CAAC,eAAe,EAAE,OAAO,CAQpC,CAAC;AA4IF,6EAA6E;AAC7E,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;IAC7B,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B,CAAC;AAEF,0EAA0E;AAC1E,KAAK,qBAAqB,GAAG;IAC3B,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IACnC,MAAM,EAAE,eAAe,CAAC;IACxB,qEAAqE;IACrE,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,KAAK,MAAM,IAAI,CAAC;CACpE,CAAC;AAMF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,QAAO,SAAS,CAC9C,WAAW,CAAC,MAAM,EAAE,mBAAmB,CAAC,EACxC,qBAAqB,CAAC,UAAU,CAAC,CAelC,CAAC;AAEF;;;;;GAKG;AACH,KAAK,aAAa,GAAG;IACnB,QAAQ,EAAE,qBAAqB,CAAC,UAAU,CAAC,CAAC;IAC5C,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;CAC1D,CAAC;AACF,eAAO,MAAM,oBAAoB,qDAEhC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS;;EA6IrB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;;EAqCzB,CAAC"}
@@ -0,0 +1,289 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Radio as BaseRadio } from '@base-ui/react/radio';
3
+ import { RadioGroup as BaseRadioGroup } from '@base-ui/react/radio-group';
4
+ import { createContext, forwardRef, useCallback, useContext, useLayoutEffect, useMemo, useRef, useState, } from 'react';
5
+ import { useGridItem } from '../grid/main.js';
6
+ import { Symbol } from '../symbol/main.js';
7
+ import { cn } from '../utils/main.js';
8
+ import { pressSlop, touchSlop } from './press.js';
9
+ import { useCardTitleId, useControlled } from './shared.js';
10
+ /**
11
+ * Its layout by its size (open above the page, that one) and its
12
+ * orientation (the app's; none, by its size): taller than a row, its
13
+ * options stacked (`upright`: vertical, or one wide) or side by side, a
14
+ * symbol over its words (`tall`: horizontal, or wider); one row, side by
15
+ * side across it (`row`: wider, not vertical); else none (`compact`: 1x1,
16
+ * or vertical in one row, no room to stack them). Outside a grid, a row,
17
+ * or stacked (vertical).
18
+ */
19
+ const layoutOf = (orientation, isWide, isTall) => {
20
+ if (isTall) {
21
+ if (orientation === undefined)
22
+ return isWide ? 'tall' : 'upright';
23
+ return orientation === 'vertical' ? 'upright' : 'tall';
24
+ }
25
+ return isWide && orientation !== 'vertical' ? 'row' : 'compact';
26
+ };
27
+ /** Its layout (see `layoutOf`), and whether it's one wide (narrow). */
28
+ export const useSegmentedLayout = (orientation) => {
29
+ const item = useGridItem();
30
+ if (!item)
31
+ return [orientation === 'vertical' ? 'upright' : 'row', false];
32
+ const [columns = '1', rows = '1'] = (item.open ? item.openSize : item.size).split('x');
33
+ const isWide = columns === '*' || Number(columns) >= 2;
34
+ return [layoutOf(orientation, isWide, Number(rows) >= 2), !isWide];
35
+ };
36
+ /** A segmented card's thumb, placed on an option's box (see below). */
37
+ const placeThumb = (thumb, on) => {
38
+ thumb.hidden = !on;
39
+ if (!on)
40
+ return;
41
+ thumb.style.setProperty('--uikit-card-segmented-thumb-x', `${String(on.offsetLeft)}px`);
42
+ thumb.style.setProperty('--uikit-card-segmented-thumb-y', `${String(on.offsetTop)}px`);
43
+ thumb.style.setProperty('--uikit-card-segmented-thumb-width', `${String(on.offsetWidth)}px`);
44
+ thumb.style.setProperty('--uikit-card-segmented-thumb-height', `${String(on.offsetHeight)}px`);
45
+ };
46
+ /** The option nearest a point, along the options (see `dragProps`). */
47
+ const nearestOption = (root, isUpright, { clientX, clientY }) => {
48
+ let nearest;
49
+ let distance = Infinity;
50
+ for (const option of root.querySelectorAll('[role="radio"]')) {
51
+ if (Object.hasOwn(option.dataset, 'disabled'))
52
+ continue;
53
+ const box = option.getBoundingClientRect();
54
+ const away = isUpright
55
+ ? Math.abs(box.top + box.height / 2 - clientY)
56
+ : Math.abs(box.left + box.width / 2 - clientX);
57
+ if (!(away < distance)) {
58
+ continue;
59
+ }
60
+ distance = away;
61
+ nearest = option;
62
+ }
63
+ return nearest;
64
+ };
65
+ /**
66
+ * Dragging between a segmented card's options (as Segmented's, no lens:
67
+ * its thumb what moves): held back until it moves (`pressSlop`; a touch,
68
+ * `touchSlop`), then along the options (a mouse, any way), the nearest one
69
+ * chosen as it's reached (its thumb going there); a touch across them, or
70
+ * the browser panning first (it's cancelled), a scroll, let go (as a
71
+ * slider card's, see `pressProps`). Dragging, the page doesn't pan (see
72
+ * `SegmentedChoice`). Released before, a press: the option's own (its
73
+ * click).
74
+ */
75
+ const dragProps = (isUpright, onChoose) => ({
76
+ onPointerDown: (event) => {
77
+ if (event.button !== 0)
78
+ return;
79
+ const root = event.currentTarget;
80
+ const { clientX, clientY, pointerId, pointerType } = event;
81
+ const isMouse = pointerType === 'mouse';
82
+ const slop = isMouse ? pressSlop : touchSlop;
83
+ let isDragging = false;
84
+ let under;
85
+ const listening = new AbortController();
86
+ const options = { capture: true, signal: listening.signal };
87
+ const end = () => {
88
+ listening.abort();
89
+ delete root.dataset.dragging;
90
+ };
91
+ addEventListener('pointermove', (move) => {
92
+ if (move.pointerId !== pointerId)
93
+ return;
94
+ if (!isDragging) {
95
+ const across = Math.abs(move.clientX - clientX);
96
+ const upright = Math.abs(move.clientY - clientY);
97
+ if (Math.hypot(across, upright) < slop)
98
+ return;
99
+ const along = isUpright ? upright : across;
100
+ const crossing = isUpright ? across : upright;
101
+ // (A touch across them: a scroll, let go.)
102
+ if (!isMouse && crossing > along) {
103
+ end();
104
+ return;
105
+ }
106
+ isDragging = true;
107
+ root.dataset.dragging = '';
108
+ }
109
+ // (Its nearest option chosen as it's reached.)
110
+ const next = nearestOption(root, isUpright, move);
111
+ if (!next || next === under)
112
+ return;
113
+ under = next;
114
+ const { value } = next.dataset;
115
+ if (value !== undefined && !Object.hasOwn(next.dataset, 'checked')) {
116
+ onChoose(value);
117
+ }
118
+ }, options);
119
+ addEventListener('pointerup', (up) => {
120
+ if (up.pointerId !== pointerId)
121
+ return;
122
+ end();
123
+ if (!isDragging)
124
+ return;
125
+ // (Its click next, if any: not an option's (dragged, not pressed);
126
+ // none before another press or key, nothing.)
127
+ const clicking = new AbortController();
128
+ const once = { capture: true, signal: clicking.signal };
129
+ addEventListener('click', (clicked) => {
130
+ clicking.abort();
131
+ clicked.preventDefault();
132
+ clicked.stopPropagation();
133
+ }, once);
134
+ for (const type of ['pointerdown', 'keydown']) {
135
+ addEventListener(type, () => clicking.abort(), once);
136
+ }
137
+ }, options);
138
+ addEventListener('pointercancel', (cancel) => {
139
+ if (cancel.pointerId === pointerId)
140
+ end();
141
+ }, options);
142
+ },
143
+ });
144
+ const SegmentedContext = createContext(undefined);
145
+ /**
146
+ * Its options, as they've told it (in the order they did: theirs), see
147
+ * `SegmentedItem`.
148
+ */
149
+ export const useSegmentedOptions = () => {
150
+ const [options, setOptions] = useState(() => new Map());
151
+ const register = useCallback((value, info) => {
152
+ setOptions((current) => new Map(current).set(value, info));
153
+ return () => setOptions((current) => {
154
+ const next = new Map(current);
155
+ next.delete(value);
156
+ return next;
157
+ });
158
+ }, []);
159
+ return [options, register];
160
+ };
161
+ export const SegmentedHostContext = createContext(undefined);
162
+ /**
163
+ * A card's choice of a few (Base UI's radio group; its options its
164
+ * children, see `SegmentedItem`; named by its card's title, or its
165
+ * `aria-label`): segments in a well at its bottom, laid out by its tile's
166
+ * size and its `orientation` (see `useSegmentedLayout`), the chosen one's
167
+ * raised (a thumb, moved to it as it's chosen, by its box: its corners the
168
+ * well's less its padding, a pill while short); dragged between (see
169
+ * `dragProps`). None shown (1x1): there all the same, unseen, its options
170
+ * telling a ready-made card theirs.
171
+ */
172
+ export const Segmented = forwardRef(({ children, className, defaultValue = '', onValueChange, optionContent = 'both', orientation, value, ...props }, forwardedRef) => {
173
+ const titleId = useCardTitleId();
174
+ const host = useContext(SegmentedHostContext);
175
+ const [options, registerOwn] = useSegmentedOptions();
176
+ const register = useCallback((option, info) => {
177
+ const own = registerOwn(option, info);
178
+ const hosted = host?.register(option, info);
179
+ return () => {
180
+ own();
181
+ hosted?.();
182
+ };
183
+ }, [host, registerOwn]);
184
+ // (None chosen at first: its first option.)
185
+ const [chosen, setChosen] = useControlled(value, defaultValue);
186
+ const current = chosen || (options.keys().next().value ?? '');
187
+ const [layout, isNarrow] = useSegmentedLayout(orientation);
188
+ // (Its value and layout told a ready-made card holding it, before
189
+ // it's painted.)
190
+ const report = host?.report;
191
+ useLayoutEffect(() => {
192
+ report?.(current, layout);
193
+ }, [current, layout, report]);
194
+ const context = useMemo(() => ({ content: optionContent, layout, register }), [layout, optionContent, register]);
195
+ const choose = (next) => {
196
+ setChosen(next);
197
+ onValueChange?.(next);
198
+ };
199
+ const group = useRef(null);
200
+ const isShown = layout !== 'compact';
201
+ // (Its thumb on the chosen segment, as it's chosen and as its box
202
+ // changes; moved (transitioned) once it's been placed.)
203
+ useLayoutEffect(() => {
204
+ const root = group.current;
205
+ const thumb = root?.querySelector('[data-part="thumb"]');
206
+ if (!root || !thumb || !isShown)
207
+ return undefined;
208
+ const place = () => {
209
+ placeThumb(thumb, root.querySelector('[data-checked]'));
210
+ };
211
+ place();
212
+ let frame = requestAnimationFrame(() => {
213
+ root.dataset.placed = '';
214
+ });
215
+ // (Its box changing (e.g. its card resized, opened): there at once,
216
+ // as its options are; moved only as another's chosen. Its first
217
+ // report (as it's observed, each choice: this effect's again) no
218
+ // change.)
219
+ let size = `${String(root.offsetWidth)}x${String(root.offsetHeight)}`;
220
+ const observer = new ResizeObserver(() => {
221
+ const next = `${String(root.offsetWidth)}x${String(root.offsetHeight)}`;
222
+ if (next === size)
223
+ return;
224
+ size = next;
225
+ cancelAnimationFrame(frame);
226
+ delete root.dataset.placed;
227
+ place();
228
+ frame = requestAnimationFrame(() => {
229
+ root.dataset.placed = '';
230
+ });
231
+ });
232
+ observer.observe(root);
233
+ // (Its options changing (added, removed, laid out anew), or another
234
+ // marked chosen (Base UI's radios a render after its value): placed
235
+ // again.)
236
+ const mutations = new MutationObserver(place);
237
+ mutations.observe(root, {
238
+ attributeFilter: ['data-checked'],
239
+ childList: true,
240
+ subtree: true,
241
+ });
242
+ return () => {
243
+ cancelAnimationFrame(frame);
244
+ observer.disconnect();
245
+ mutations.disconnect();
246
+ };
247
+ }, [current, isShown, layout]);
248
+ // (Dragged (see `dragProps`): its touch's moves not the page's, its pan
249
+ // not starting as the finger strays across its options; not passive,
250
+ // as React's listeners are.)
251
+ useLayoutEffect(() => {
252
+ const root = group.current;
253
+ if (!root)
254
+ return undefined;
255
+ const hold = (move) => {
256
+ if (Object.hasOwn(root.dataset, 'dragging') && move.cancelable) {
257
+ move.preventDefault();
258
+ }
259
+ };
260
+ root.addEventListener('touchmove', hold, { passive: false });
261
+ return () => root.removeEventListener('touchmove', hold);
262
+ }, []);
263
+ return (_jsx(SegmentedContext.Provider, { value: context, children: _jsxs(BaseRadioGroup, { ref: (element) => {
264
+ group.current = element;
265
+ if (typeof forwardedRef === 'function')
266
+ forwardedRef(element);
267
+ else if (forwardedRef)
268
+ forwardedRef.current = element;
269
+ }, "aria-labelledby": props['aria-label'] === undefined ? titleId : undefined, ...props, className: cn('uikit-card-segmented', className), "data-card-own-press": "", "data-card-part": "segmented", "data-layout": layout, "data-narrow": isNarrow ? '' : undefined, hidden: !isShown, value: current, onValueChange: (next) => choose(next), ...dragProps(layout === 'upright', choose), children: [_jsx("span", { "aria-hidden": "true", className: "uikit-card-segmented-thumb", "data-part": "thumb" }), children] }) }));
270
+ });
271
+ /**
272
+ * A choice's option (a radio, Base UI's): its symbol and its words
273
+ * (`children`), or either (its choice's `optionContent`; its symbol only,
274
+ * its words unseen, its name), a subtitle under them where there's room;
275
+ * telling its choice its symbol, words and tint (a ready-made card's value
276
+ * and symbol while it's chosen).
277
+ */
278
+ export const SegmentedItem = forwardRef(({ children, className, icon, subtitle, tint, value, ...props }, ref) => {
279
+ const context = useContext(SegmentedContext);
280
+ if (!context) {
281
+ throw new Error('Card.SegmentedItem goes in a Card.Segmented.');
282
+ }
283
+ const { register } = context;
284
+ useLayoutEffect(() => register(value, { icon, label: children, tint }), [children, icon, register, tint, value]);
285
+ const hasIcon = icon !== undefined && context.content !== 'label';
286
+ const isIconOnly = hasIcon && context.content === 'icon';
287
+ return (_jsxs(BaseRadio.Root, { ref: ref, ...props, className: cn('uikit-card-segmented-item', className), "data-card-part": "segmented-item", "data-value": value, value: value, children: [hasIcon ? _jsx(Symbol, { icon: icon }) : null, _jsxs("span", { className: "uikit-card-segmented-text", "data-unseen": isIconOnly ? '' : undefined, children: [_jsx("span", { className: "uikit-card-segmented-label", children: children }), context.layout !== 'row' && subtitle !== undefined ? (_jsx("span", { className: "uikit-card-segmented-subtitle", children: subtitle })) : null] })] }));
288
+ });
289
+ //# sourceMappingURL=segmented.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"segmented.js","sourceRoot":"","sources":["../../../src/components/card/segmented.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EACL,aAAa,EACb,UAAU,EAGV,WAAW,EACX,UAAU,EACV,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAmB,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAElD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C,SAAS,CAAC,IAAI,IACb,GAAG,EAAE,GAAG,KACJ,KAAK,EACT,SAAS,EAAE,EAAE,CAAC,2BAA2B,EAAE,SAAS,CAAC,oBACtC,gBAAgB,gBACnB,KAAK,EACjB,KAAK,EAAE,KAAK,aAEX,OAAO,CAAC,CAAC,CAAC,KAAC,MAAM,IAAC,IAAI,EAAE,IAAI,GAAI,CAAC,CAAC,CAAC,IAAI,EAGxC,gBACE,SAAS,EAAC,2BAA2B,iBACxB,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,aAExC,eAAM,SAAS,EAAC,4BAA4B,YAAE,QAAQ,GAAQ,EAC7D,OAAO,CAAC,MAAM,KAAK,KAAK,IAAI,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,CACpD,eAAM,SAAS,EAAC,+BAA+B,YAAE,QAAQ,GAAQ,CAClE,CAAC,CAAC,CAAC,IAAI,IACH,IACQ,CAClB,CAAC;AACJ,CAAC,CACF,CAAC"}
@@ -0,0 +1,55 @@
1
+ import type { CardFormat } from './props.js';
2
+ /** What a card tells its parts (see `Card.Root`). */
3
+ type CardContextValue = {
4
+ /** Its title's id (see `Card.Title`): what its parts are named by. */
5
+ setTitleId: (id: string | undefined) => void;
6
+ titleId: string | undefined;
7
+ };
8
+ export declare const CardContext: import("preact").Context<CardContextValue | undefined>;
9
+ /**
10
+ * Its card's title's id, for a part named by it (e.g. a progress bar, a
11
+ * list of stages, a choice): none until its title is there (or none at
12
+ * all, or outside a card).
13
+ */
14
+ export declare const useCardTitleId: () => string | undefined;
15
+ /**
16
+ * Controlled or uncontrolled state, as Base UI's components keep it: which
17
+ * one by whether a value's given as it mounts, for as long as it's there.
18
+ */
19
+ export declare const useControlled: <T>(value: T | undefined, defaultValue: T) => [T, (next: T) => void];
20
+ /**
21
+ * A number, formatted (see `CardFormat`; its locale resolved, see
22
+ * Settings' `useLocale`).
23
+ */
24
+ export declare const formatted: (value: number, { format, locale }: CardFormat) => string;
25
+ /** A share's default format: a whole percentage. */
26
+ export declare const percentFormat: Intl.NumberFormatOptions;
27
+ /** Its share of its range (0 to 1); none, none. */
28
+ export declare const shareOf: (value: number | null | undefined, min: number, max: number) => number;
29
+ /**
30
+ * A value's words by a format (see `CardFormat`): a percentage of its
31
+ * share (`style: 'percent'`), else the value itself.
32
+ */
33
+ export declare const formattedShare: (value: number, share: number, { format, locale }: CardFormat) => string;
34
+ /**
35
+ * Whether its card shows its large layout: its tile at least 2x2 (a full
36
+ * width's: wide), however it got there (expanded, resized), or open above
37
+ * the page.
38
+ */
39
+ export declare const useIsLarge: () => boolean;
40
+ /**
41
+ * The color scheme of what's drawn over a fill (see `textSchemeOn`), as
42
+ * its tint or the color scheme changes (not as it moves). Its tint's, read
43
+ * where it's drawn (its `light-dark()` resolved there), not what's painted:
44
+ * off, with a switch, a slider's fill isn't drawn (see Card), and its
45
+ * scheme is still wanted as it's switched on.
46
+ */
47
+ export declare const useFillScheme: (probe: {
48
+ current: HTMLElement | null;
49
+ }, tint: string | undefined) => "dark" | "light" | undefined;
50
+ /** A fill's tint, resolved where it's drawn (see `useFillScheme`). */
51
+ export declare const TintProbe: import("preact").FunctionalComponent<import("react").PropsWithoutRef<{}> & {
52
+ ref?: import("preact").Ref<HTMLSpanElement> | undefined;
53
+ }>;
54
+ export {};
55
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/components/card/shared.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAK7C,qDAAqD;AACrD,KAAK,gBAAgB,GAAG;IACtB,sEAAsE;IACtE,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC7C,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,WAAW,wDAEvB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAO,MAAM,GAAG,SACT,CAAC;AAEnC;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,EAC7B,OAAO,CAAC,GAAG,SAAS,EACpB,cAAc,CAAC,KACd,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAIvB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS,GACpB,OAAO,MAAM,EACb,oBAAoB,UAAU,KAC7B,MAA6D,CAAC;AAEjE,oDAAoD;AACpD,eAAO,MAAM,aAAa,EAAE,IAAI,CAAC,mBAGhC,CAAC;AAEF,mDAAmD;AACnD,eAAO,MAAM,OAAO,GAClB,OAAO,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,KAAK,MAAM,EACX,KAAK,MAAM,KACV,MAGwD,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,MAAM,EACb,OAAO,MAAM,EACb,oBAAoB,UAAU,KAC7B,MACyE,CAAC;AAE7E;;;;GAIG;AACH,eAAO,MAAM,UAAU,QAAO,OAQ7B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GACxB,OAAO;IAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;CAAE,EACtC,MAAM,MAAM,GAAG,SAAS,KACvB,MAAM,GAAG,OAAO,GAAG,SAerB,CAAC;AAEF,sEAAsE;AACtE,eAAO,MAAM,SAAS;;EAOpB,CAAC"}
@@ -0,0 +1,80 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, forwardRef, useContext, useLayoutEffect, useState, } from 'react';
3
+ import { useGridItem } from '../grid/main.js';
4
+ import { useSettings } from '../settings/main.js';
5
+ import { textSchemeOn } from './color.js';
6
+ export const CardContext = createContext(undefined);
7
+ /**
8
+ * Its card's title's id, for a part named by it (e.g. a progress bar, a
9
+ * list of stages, a choice): none until its title is there (or none at
10
+ * all, or outside a card).
11
+ */
12
+ export const useCardTitleId = () => useContext(CardContext)?.titleId;
13
+ /**
14
+ * Controlled or uncontrolled state, as Base UI's components keep it: which
15
+ * one by whether a value's given as it mounts, for as long as it's there.
16
+ */
17
+ export const useControlled = (value, defaultValue) => {
18
+ const [isControlled] = useState(value !== undefined);
19
+ const [state, setState] = useState(defaultValue);
20
+ return [isControlled ? value : state, setState];
21
+ };
22
+ /**
23
+ * A number, formatted (see `CardFormat`; its locale resolved, see
24
+ * Settings' `useLocale`).
25
+ */
26
+ export const formatted = (value, { format, locale }) => new Intl.NumberFormat(locale, format).format(value);
27
+ /** A share's default format: a whole percentage. */
28
+ export const percentFormat = {
29
+ maximumFractionDigits: 0,
30
+ style: 'percent',
31
+ };
32
+ /** Its share of its range (0 to 1); none, none. */
33
+ export const shareOf = (value, min, max) => value === undefined || value === null || max <= min
34
+ ? 0
35
+ : Math.min(Math.max((value - min) / (max - min), 0), 1);
36
+ /**
37
+ * A value's words by a format (see `CardFormat`): a percentage of its
38
+ * share (`style: 'percent'`), else the value itself.
39
+ */
40
+ export const formattedShare = (value, share, { format, locale }) => formatted(format?.style === 'percent' ? share : value, { format, locale });
41
+ /**
42
+ * Whether its card shows its large layout: its tile at least 2x2 (a full
43
+ * width's: wide), however it got there (expanded, resized), or open above
44
+ * the page.
45
+ */
46
+ export const useIsLarge = () => {
47
+ const item = useGridItem();
48
+ if (!item)
49
+ return false;
50
+ const [columns = '1', rows = '1'] = item.size.split('x');
51
+ return (item.open ||
52
+ ((columns === '*' || Number(columns) >= 2) && Number(rows) >= 2));
53
+ };
54
+ /**
55
+ * The color scheme of what's drawn over a fill (see `textSchemeOn`), as
56
+ * its tint or the color scheme changes (not as it moves). Its tint's, read
57
+ * where it's drawn (its `light-dark()` resolved there), not what's painted:
58
+ * off, with a switch, a slider's fill isn't drawn (see Card), and its
59
+ * scheme is still wanted as it's switched on.
60
+ */
61
+ export const useFillScheme = (probe, tint) => {
62
+ const { colorScheme } = useSettings();
63
+ const [scheme, setScheme] = useState();
64
+ useLayoutEffect(() => {
65
+ const { current: element } = probe;
66
+ if (!element)
67
+ return;
68
+ // (Its color computed, the var resolved, by a probe kept in its fill
69
+ // (see `TintProbe`): only read, nothing changed on the page, so many
70
+ // cards mounting at once (e.g. a page pushed) don't each restyle it.)
71
+ const read = () => {
72
+ setScheme(textSchemeOn(getComputedStyle(element).color));
73
+ };
74
+ read();
75
+ }, [colorScheme, probe, tint]);
76
+ return scheme;
77
+ };
78
+ /** A fill's tint, resolved where it's drawn (see `useFillScheme`). */
79
+ export const TintProbe = forwardRef((_, ref) => (_jsx("span", { ref: ref, hidden: true, "aria-hidden": "true", className: "uikit-card-tint-probe" })));
80
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/components/card/shared.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EACb,UAAU,EACV,UAAU,EACV,eAAe,EACf,QAAQ,GACT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAa1C,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CACtC,SAAS,CACV,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,GAAuB,EAAE,CACrD,UAAU,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;AAEnC;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,KAAoB,EACpB,YAAe,EACS,EAAE;IAC1B,MAAM,CAAC,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IACrD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;IACjD,OAAO,CAAC,YAAY,CAAC,CAAC,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,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACzD,OAAO,CACL,IAAI,CAAC,IAAI;QACT,CAAC,CAAC,OAAO,KAAK,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CACjE,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,KAAsC,EACtC,IAAwB,EACM,EAAE;IAChC,MAAM,EAAE,WAAW,EAAE,GAAG,WAAW,EAAE,CAAC;IACtC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,EAAgC,CAAC;IACrE,eAAe,CAAC,GAAG,EAAE;QACnB,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;QACnC,IAAI,CAAC,OAAO;YAAE,OAAO;QACrB,qEAAqE;QACrE,qEAAqE;QACrE,sEAAsE;QACtE,MAAM,IAAI,GAAG,GAAG,EAAE;YAChB,SAAS,CAAC,YAAY,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QAC3D,CAAC,CAAC;QACF,IAAI,EAAE,CAAC;IACT,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;IAC/B,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,sEAAsE;AACtE,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAkB,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,CAC/D,eACE,GAAG,EAAE,GAAG,EACR,MAAM,uBACM,MAAM,EAClB,SAAS,EAAC,uBAAuB,GACjC,CACH,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { CardSliderProps } from './props.js';
2
+ /**
3
+ * A slider filling its card (among the card's parts): its fill the card's
4
+ * background (from its leading edge, or from its bottom upright, by its
5
+ * tile's shape), ticks at its steps (`step`), its label and value at the
6
+ * card's bottom. What's over the fill (its label, value and ticks, the
7
+ * card's symbol and corner buttons) drawn twice: on the card, and again
8
+ * inside the fill in the fill's color scheme (dark on a bright fill, light
9
+ * on a dim one), clipped by its edge, so it reads whatever its tint. With
10
+ * an `onPress`, a press on it is that (e.g. a switch toggled), a drag sets
11
+ * its value.
12
+ */
13
+ export declare const CardSlider: import("preact").FunctionalComponent<import("react").PropsWithoutRef<CardSliderProps> & {
14
+ ref?: import("preact").Ref<HTMLDivElement> | undefined;
15
+ }>;
16
+ //# sourceMappingURL=slider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slider.d.ts","sourceRoot":"","sources":["../../../src/components/card/slider.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAmB,eAAe,EAAE,MAAM,YAAY,CAAC;AAoEnE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU;;EA+EtB,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useContext, useRef } from 'react';
3
+ import { colorSchemeStyle } from '../glass/main.js';
4
+ import { Slider } from '../slider/main.js';
5
+ import { cn } from '../utils/main.js';
6
+ import { pressProps } from './press.js';
7
+ import { CardBlendScope, useCardOrientation } from './root.js';
8
+ import { TintProbe, useControlled, useFillScheme } from './shared.js';
9
+ /** Its value's words (see `children`) as `Slider.Value`'s children. */
10
+ const valueTextOf = (children) => children
11
+ ? (formattedValues, values) => children(formattedValues[0] ?? '', values[0] ?? 0)
12
+ : undefined;
13
+ /**
14
+ * What's over a slider's fill, drawn again in it: a layer at the card's
15
+ * size, in the fill's color scheme, its label, its value and its ticks in
16
+ * it; the card's own parts portaled in (see `CardBlendScope`). Hidden from
17
+ * assistive technology, inert.
18
+ */
19
+ const FillCopies = ({ label, layerRef, orientation, scheme, ticks, valueText, }) => (_jsxs("span", { ref: layerRef, "aria-hidden": true, inert: true, className: "uikit-card-blend", "data-color-scheme": scheme, "data-orientation": orientation, style: colorSchemeStyle(scheme), children: [_jsx("span", { className: "uikit-slider-label", "data-card-copy": "", children: label }), _jsx(Slider.Value, { "data-card-copy": "", children: valueText }), ticks === undefined ? null : (_jsx(Slider.Ticks, { count: ticks, "data-card-copy": "" }))] }));
20
+ /**
21
+ * A slider filling its card (among the card's parts): its fill the card's
22
+ * background (from its leading edge, or from its bottom upright, by its
23
+ * tile's shape), ticks at its steps (`step`), its label and value at the
24
+ * card's bottom. What's over the fill (its label, value and ticks, the
25
+ * card's symbol and corner buttons) drawn twice: on the card, and again
26
+ * inside the fill in the fill's color scheme (dark on a bright fill, light
27
+ * on a dim one), clipped by its edge, so it reads whatever its tint. With
28
+ * an `onPress`, a press on it is that (e.g. a switch toggled), a drag sets
29
+ * its value.
30
+ */
31
+ export const CardSlider = forwardRef(({ children, className, defaultValue, getAriaValueText, label, max = 100, min = 0, onPress, onValueChange, step, tint, value, ...props }, ref) => {
32
+ const orientation = useCardOrientation();
33
+ const [current, setCurrent] = useControlled(value, defaultValue ?? min);
34
+ // (Its fill's color scheme; the layer in it registered with its card,
35
+ // see `CardBlendScope`.)
36
+ const probe = useRef(null);
37
+ const scheme = useFillScheme(probe, tint);
38
+ const setLayer = useContext(CardBlendScope)?.setLayer;
39
+ const ticks = step === undefined ? undefined : Math.round((max - min) / step) + 1;
40
+ const valueText = valueTextOf(children);
41
+ return (_jsxs(Slider.Root, { ref: ref, ...props, className: cn('uikit-card-slider', className), "data-card-part": "slider", max: max, min: min, orientation: orientation, step: step ?? (max - min) / 100, tint: tint, value: current, onValueChange: (next) => {
42
+ setCurrent(next);
43
+ onValueChange?.(next);
44
+ }, ...pressProps(onPress, orientation), children: [_jsx(Slider.Control, { children: _jsxs(Slider.Track, { children: [_jsxs(Slider.Indicator, { children: [_jsx(TintProbe, { ref: probe }), scheme ? (_jsx(FillCopies, { label: label, layerRef: setLayer, orientation: orientation, scheme: scheme, ticks: ticks, valueText: valueText })) : null] }), ticks === undefined ? null : _jsx(Slider.Ticks, { count: ticks }), _jsx(Slider.Thumb, { "aria-label": label, getAriaValueText: getAriaValueText
45
+ ? (formattedValue, thumbValue) => getAriaValueText(formattedValue, thumbValue)
46
+ : undefined })] }) }), _jsx(Slider.Label, { children: label }), _jsx(Slider.Value, { children: valueText })] }));
47
+ });
48
+ //# sourceMappingURL=slider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slider.js","sourceRoot":"","sources":["../../../src/components/card/slider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAkB,UAAU,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAWtE,uEAAuE;AACvE,MAAM,WAAW,GAAG,CAClB,QAAqC,EACd,EAAE,CACzB,QAAQ;IACN,CAAC,CAAC,CAAC,eAAe,EAAE,MAAM,EAAE,EAAE,CAC1B,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC,CAAC,SAAS,CAAC;AAEhB;;;;;GAKG;AACH,MAAM,UAAU,GAAG,CAAC,EAClB,KAAK,EACL,QAAQ,EACR,WAAW,EACX,MAAM,EACN,KAAK,EACL,SAAS,GAQV,EAAE,EAAE,CAAC,CACJ,gBACE,GAAG,EAAE,QAAQ,uBAEb,KAAK,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A,EACjB,KAAC,MAAM,CAAC,KAAK,cAAE,KAAK,GAAgB,EACpC,KAAC,MAAM,CAAC,KAAK,cAAE,SAAS,GAAgB,IAC5B,CACf,CAAC;AACJ,CAAC,CACF,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { CardStageListProps, CardStageProps } from './props.js';
2
+ /**
3
+ * A card's stages: an ordered list (named by its card's title, or its
4
+ * `aria-label`), its `Stage`s along a line at the card's bottom as dots,
5
+ * those done (before its `value`) checked, its current one in its tint,
6
+ * those to come empty; their words under them.
7
+ */
8
+ export declare const StageList: import("preact").FunctionalComponent<import("react").PropsWithoutRef<CardStageListProps> & {
9
+ ref?: import("preact").Ref<HTMLOListElement> | undefined;
10
+ }>;
11
+ /**
12
+ * A stage (in a `StageList`): its dot and its words; done (before the
13
+ * current one), current, or to come, by its place (see the CSS).
14
+ */
15
+ export declare const Stage: import("preact").FunctionalComponent<import("react").PropsWithoutRef<CardStageProps> & {
16
+ ref?: import("preact").Ref<HTMLLIElement> | undefined;
17
+ }>;
18
+ //# sourceMappingURL=stages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stages.d.ts","sourceRoot":"","sources":["../../../src/components/card/stages.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAkBrE;;;;;GAKG;AACH,eAAO,MAAM,SAAS;;EAqBrB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,KAAK;;EAgCjB,CAAC"}