@ariakit/components 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/checkbox/checkbox-store.d.ts +47 -0
  3. package/dist/checkbox/checkbox-store.d.ts.map +1 -0
  4. package/dist/checkbox/checkbox-store.js +16 -0
  5. package/dist/checkbox/checkbox-store.js.map +1 -0
  6. package/dist/collection/collection-store.d.ts +2 -0
  7. package/dist/collection/collection-store.js +132 -0
  8. package/dist/collection/collection-store.js.map +1 -0
  9. package/dist/collection-store-yNe83BiS.d.ts +81 -0
  10. package/dist/collection-store-yNe83BiS.d.ts.map +1 -0
  11. package/dist/combobox/combobox-store.d.ts +150 -0
  12. package/dist/combobox/combobox-store.d.ts.map +1 -0
  13. package/dist/combobox/combobox-store.js +83 -0
  14. package/dist/combobox/combobox-store.js.map +1 -0
  15. package/dist/composite/composite-overflow-store.d.ts +16 -0
  16. package/dist/composite/composite-overflow-store.d.ts.map +1 -0
  17. package/dist/composite/composite-overflow-store.js +12 -0
  18. package/dist/composite/composite-overflow-store.js.map +1 -0
  19. package/dist/composite/composite-store.d.ts +2 -0
  20. package/dist/composite/composite-store.js +167 -0
  21. package/dist/composite/composite-store.js.map +1 -0
  22. package/dist/composite-store-B-iDEtZZ.d.ts +331 -0
  23. package/dist/composite-store-B-iDEtZZ.d.ts.map +1 -0
  24. package/dist/dialog/dialog-store.d.ts +2 -0
  25. package/dist/dialog/dialog-store.js +12 -0
  26. package/dist/dialog/dialog-store.js.map +1 -0
  27. package/dist/dialog-store-BOLvw2IX.d.ts +16 -0
  28. package/dist/dialog-store-BOLvw2IX.d.ts.map +1 -0
  29. package/dist/disclosure/disclosure-store.d.ts +2 -0
  30. package/dist/disclosure/disclosure-store.js +47 -0
  31. package/dist/disclosure/disclosure-store.js.map +1 -0
  32. package/dist/disclosure-store-xKlQffR0.d.ts +142 -0
  33. package/dist/disclosure-store-xKlQffR0.d.ts.map +1 -0
  34. package/dist/form/form-store.d.ts +247 -0
  35. package/dist/form/form-store.d.ts.map +1 -0
  36. package/dist/form/form-store.js +211 -0
  37. package/dist/form/form-store.js.map +1 -0
  38. package/dist/form/types.d.ts +37 -0
  39. package/dist/form/types.d.ts.map +1 -0
  40. package/dist/form/types.js +0 -0
  41. package/dist/hovercard/hovercard-store.d.ts +65 -0
  42. package/dist/hovercard/hovercard-store.d.ts.map +1 -0
  43. package/dist/hovercard/hovercard-store.js +31 -0
  44. package/dist/hovercard/hovercard-store.js.map +1 -0
  45. package/dist/index.d.ts +5 -0
  46. package/dist/index.d.ts.map +1 -0
  47. package/dist/index.js +6 -0
  48. package/dist/index.js.map +1 -0
  49. package/dist/menu/menu-bar-store.d.ts +16 -0
  50. package/dist/menu/menu-bar-store.d.ts.map +1 -0
  51. package/dist/menu/menu-bar-store.js +12 -0
  52. package/dist/menu/menu-bar-store.js.map +1 -0
  53. package/dist/menu/menu-store.d.ts +100 -0
  54. package/dist/menu/menu-store.d.ts.map +1 -0
  55. package/dist/menu/menu-store.js +74 -0
  56. package/dist/menu/menu-store.js.map +1 -0
  57. package/dist/menubar/menubar-store.d.ts +2 -0
  58. package/dist/menubar/menubar-store.js +24 -0
  59. package/dist/menubar/menubar-store.js.map +1 -0
  60. package/dist/menubar-store-CD3YDYfW.d.ts +16 -0
  61. package/dist/menubar-store-CD3YDYfW.d.ts.map +1 -0
  62. package/dist/popover/popover-store.d.ts +2 -0
  63. package/dist/popover/popover-store.js +44 -0
  64. package/dist/popover/popover-store.js.map +1 -0
  65. package/dist/popover-store-DoCiTmUQ.d.ts +106 -0
  66. package/dist/popover-store-DoCiTmUQ.d.ts.map +1 -0
  67. package/dist/radio/radio-store.d.ts +42 -0
  68. package/dist/radio/radio-store.d.ts.map +1 -0
  69. package/dist/radio/radio-store.js +27 -0
  70. package/dist/radio/radio-store.js.map +1 -0
  71. package/dist/select/select-store.d.ts +116 -0
  72. package/dist/select/select-store.d.ts.map +1 -0
  73. package/dist/select/select-store.js +93 -0
  74. package/dist/select/select-store.js.map +1 -0
  75. package/dist/tab/tab-store.d.ts +127 -0
  76. package/dist/tab/tab-store.d.ts.map +1 -0
  77. package/dist/tab/tab-store.js +107 -0
  78. package/dist/tab/tab-store.js.map +1 -0
  79. package/dist/tag/tag-store.d.ts +2 -0
  80. package/dist/tag/tag-store.js +60 -0
  81. package/dist/tag/tag-store.js.map +1 -0
  82. package/dist/tag-store-D47X5_zA.d.ts +83 -0
  83. package/dist/tag-store-D47X5_zA.d.ts.map +1 -0
  84. package/dist/toolbar/toolbar-store.d.ts +21 -0
  85. package/dist/toolbar/toolbar-store.d.ts.map +1 -0
  86. package/dist/toolbar/toolbar-store.js +18 -0
  87. package/dist/toolbar/toolbar-store.js.map +1 -0
  88. package/dist/tooltip/tooltip-store.d.ts +35 -0
  89. package/dist/tooltip/tooltip-store.d.ts.map +1 -0
  90. package/dist/tooltip/tooltip-store.js +29 -0
  91. package/dist/tooltip/tooltip-store.js.map +1 -0
  92. package/license +21 -0
  93. package/package.json +121 -0
  94. package/readme.md +19 -0
  95. package/src/checkbox/checkbox-store.ts +93 -0
  96. package/src/collection/collection-store.ts +301 -0
  97. package/src/combobox/combobox-store.ts +382 -0
  98. package/src/composite/composite-overflow-store.ts +30 -0
  99. package/src/composite/composite-store.ts +711 -0
  100. package/src/dialog/dialog-store.ts +26 -0
  101. package/src/disclosure/disclosure-store.ts +226 -0
  102. package/src/form/form-store.ts +608 -0
  103. package/src/form/types.ts +44 -0
  104. package/src/hovercard/hovercard-store.ts +112 -0
  105. package/src/index.ts +1 -0
  106. package/src/menu/menu-bar-store.ts +28 -0
  107. package/src/menu/menu-store.ts +263 -0
  108. package/src/menubar/menubar-store.ts +51 -0
  109. package/src/popover/popover-store.ts +170 -0
  110. package/src/radio/radio-store.ts +80 -0
  111. package/src/select/select-store.ts +323 -0
  112. package/src/tab/tab-store.ts +330 -0
  113. package/src/tag/tag-store.ts +170 -0
  114. package/src/toolbar/toolbar-store.ts +47 -0
  115. package/src/tooltip/tooltip-store.ts +93 -0
@@ -0,0 +1,74 @@
1
+ import { createCompositeStore } from "../composite/composite-store.js";
2
+ import { createHovercardStore } from "../hovercard/hovercard-store.js";
3
+ import { createStore, mergeStore, omit, pick, setup, sync, throwOnConflictingProps } from "@ariakit/store";
4
+ import { applyState, defaultValue } from "@ariakit/utils";
5
+ //#region src/menu/menu-store.ts
6
+ function createMenuStore({ combobox, parent, menubar, ...props } = {}) {
7
+ const parentIsMenubar = !!menubar && !parent;
8
+ const store = mergeStore(props.store, pick(parent, ["values"]), omit(combobox, [
9
+ "arrowElement",
10
+ "anchorElement",
11
+ "contentElement",
12
+ "popoverElement",
13
+ "disclosureElement"
14
+ ]));
15
+ throwOnConflictingProps(props, store);
16
+ const syncState = store.getState();
17
+ const composite = createCompositeStore({
18
+ ...props,
19
+ store,
20
+ orientation: defaultValue(props.orientation, syncState.orientation, "vertical")
21
+ });
22
+ const hovercard = createHovercardStore({
23
+ ...props,
24
+ store,
25
+ placement: defaultValue(props.placement, syncState.placement, "bottom-start"),
26
+ timeout: defaultValue(props.timeout, syncState.timeout, parentIsMenubar ? 0 : 150),
27
+ hideTimeout: defaultValue(props.hideTimeout, syncState.hideTimeout, 0)
28
+ });
29
+ const menu = createStore({
30
+ ...composite.getState(),
31
+ ...hovercard.getState(),
32
+ initialFocus: defaultValue(syncState.initialFocus, "container"),
33
+ values: defaultValue(props.values, syncState.values, props.defaultValues, {})
34
+ }, composite, hovercard, store);
35
+ setup(menu, () => sync(menu, ["mounted"], (state) => {
36
+ if (state.mounted) return;
37
+ menu.setState("activeId", null);
38
+ }));
39
+ setup(menu, () => sync(parent, ["orientation"], (state) => {
40
+ menu.setState("placement", state.orientation === "vertical" ? "right-start" : "bottom-start");
41
+ }));
42
+ return {
43
+ ...composite,
44
+ ...hovercard,
45
+ ...menu,
46
+ combobox,
47
+ parent,
48
+ menubar,
49
+ hideAll: () => {
50
+ hovercard.hide();
51
+ parent?.hideAll();
52
+ },
53
+ setInitialFocus: (value) => menu.setState("initialFocus", value),
54
+ setValues: (values) => menu.setState("values", values),
55
+ setValue: (name, value) => {
56
+ if (name === "__proto__") return;
57
+ if (name === "constructor") return;
58
+ if (Array.isArray(name)) return;
59
+ menu.setState("values", (values) => {
60
+ const prevValue = values[name];
61
+ const nextValue = applyState(value, prevValue);
62
+ if (nextValue === prevValue) return values;
63
+ return {
64
+ ...values,
65
+ [name]: nextValue !== void 0 && nextValue
66
+ };
67
+ });
68
+ }
69
+ };
70
+ }
71
+ //#endregion
72
+ export { createMenuStore };
73
+
74
+ //# sourceMappingURL=menu-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menu-store.js","names":[],"sources":["../../src/menu/menu-store.ts"],"sourcesContent":["import {\n createStore,\n mergeStore,\n omit,\n pick,\n setup,\n sync,\n throwOnConflictingProps,\n} from \"@ariakit/store\";\nimport type { Store, StoreOptions, StoreProps } from \"@ariakit/store\";\nimport { applyState, defaultValue } from \"@ariakit/utils\";\nimport type {\n BivariantCallback,\n PickRequired,\n SetState,\n SetStateAction,\n} from \"@ariakit/utils\";\nimport type { ComboboxStore } from \"../combobox/combobox-store.ts\";\nimport type {\n CompositeStoreFunctions,\n CompositeStoreOptions,\n CompositeStoreState,\n} from \"../composite/composite-store.ts\";\nimport { createCompositeStore } from \"../composite/composite-store.ts\";\nimport type {\n HovercardStoreFunctions,\n HovercardStoreOptions,\n HovercardStoreState,\n} from \"../hovercard/hovercard-store.ts\";\nimport { createHovercardStore } from \"../hovercard/hovercard-store.ts\";\nimport type { MenuBarStore } from \"./menu-bar-store.ts\";\n\nexport function createMenuStore<T extends MenuStoreValues = MenuStoreValues>(\n props: PickRequired<MenuStoreProps<T>, \"values\" | \"defaultValues\">,\n): MenuStore<T>;\n\nexport function createMenuStore(props?: MenuStoreProps): MenuStore;\n\nexport function createMenuStore({\n combobox,\n parent,\n menubar,\n ...props\n}: MenuStoreProps = {}): MenuStore {\n const parentIsMenubar = !!menubar && !parent;\n\n const store = mergeStore(\n props.store,\n pick(parent, [\"values\"]),\n omit(combobox, [\n \"arrowElement\",\n \"anchorElement\",\n \"contentElement\",\n \"popoverElement\",\n \"disclosureElement\",\n ]),\n );\n\n throwOnConflictingProps(props, store);\n\n const syncState = store.getState();\n\n const composite = createCompositeStore({\n ...props,\n store,\n orientation: defaultValue(\n props.orientation,\n syncState.orientation,\n \"vertical\" as const,\n ),\n });\n\n const hovercard = createHovercardStore({\n ...props,\n store,\n placement: defaultValue(\n props.placement,\n syncState.placement,\n \"bottom-start\" as const,\n ),\n timeout: defaultValue(\n props.timeout,\n syncState.timeout,\n parentIsMenubar ? 0 : 150,\n ),\n hideTimeout: defaultValue(props.hideTimeout, syncState.hideTimeout, 0),\n });\n\n const initialState: MenuStoreState = {\n ...composite.getState(),\n ...hovercard.getState(),\n initialFocus: defaultValue(syncState.initialFocus, \"container\" as const),\n values: defaultValue(\n props.values,\n syncState.values,\n props.defaultValues,\n {},\n ),\n };\n\n const menu = createStore(initialState, composite, hovercard, store);\n\n setup(menu, () =>\n sync(menu, [\"mounted\"], (state) => {\n if (state.mounted) return;\n menu.setState(\"activeId\", null);\n }),\n );\n\n setup(menu, () =>\n sync(parent, [\"orientation\"], (state) => {\n menu.setState(\n \"placement\",\n state.orientation === \"vertical\" ? \"right-start\" : \"bottom-start\",\n );\n }),\n );\n\n return {\n ...composite,\n ...hovercard,\n ...menu,\n combobox,\n parent,\n menubar,\n hideAll: () => {\n hovercard.hide();\n parent?.hideAll();\n },\n setInitialFocus: (value) => menu.setState(\"initialFocus\", value),\n setValues: (values) => menu.setState(\"values\", values),\n setValue: (name, value) => {\n // Avoid prototype pollution\n if (name === \"__proto__\") return;\n if (name === \"constructor\") return;\n if (Array.isArray(name)) return;\n menu.setState(\"values\", (values) => {\n const prevValue = values[name];\n const nextValue = applyState(value, prevValue);\n if (nextValue === prevValue) return values;\n return {\n ...values,\n [name]: nextValue !== undefined && nextValue,\n };\n });\n },\n };\n}\n\nexport type MenuStoreValues = Record<\n string,\n string | boolean | number | ReadonlyArray<string | number>\n>;\n\nexport interface MenuStoreState<T extends MenuStoreValues = MenuStoreValues>\n extends CompositeStoreState, HovercardStoreState {\n /** @default \"vertical\" */\n orientation: CompositeStoreState[\"orientation\"];\n /** @default \"bottom-start\" */\n placement: HovercardStoreState[\"placement\"];\n /** @default 0 */\n hideTimeout?: HovercardStoreState[\"hideTimeout\"];\n /**\n * Determines the element that should be focused when the menu is opened.\n */\n initialFocus: \"container\" | \"first\" | \"last\";\n /**\n * A map of names and values that will be used by the\n * [`MenuItemCheckbox`](https://ariakit.com/reference/menu-item-checkbox) and\n * [`MenuItemRadio`](https://ariakit.com/reference/menu-item-radio)\n * components.\n *\n * Live examples:\n * - [MenuItemCheckbox](https://ariakit.com/examples/menu-item-checkbox)\n * - [Submenu with\n * Combobox](https://ariakit.com/examples/menu-nested-combobox)\n */\n values: T;\n}\n\nexport interface MenuStoreFunctions<T extends MenuStoreValues = MenuStoreValues>\n extends\n CompositeStoreFunctions,\n HovercardStoreFunctions,\n Pick<MenuStoreOptions, \"combobox\" | \"parent\" | \"menubar\"> {\n /**\n * Hides the menu and all its parent menus.\n *\n * Live examples:\n * - [Submenu with\n * Combobox](https://ariakit.com/examples/menu-nested-combobox)\n */\n hideAll: () => void;\n /**\n * Sets the `initialFocus` state.\n */\n setInitialFocus: SetState<MenuStoreState<T>[\"initialFocus\"]>;\n /**\n * Sets the [`values`](https://ariakit.com/reference/menu-provider#values)\n * state.\n * @example\n * store.setValues({ watching: [\"issues\"] });\n * store.setValues((values) => ({ ...values, watching: [\"issues\"] }));\n */\n setValues: SetState<MenuStoreState<T>[\"values\"]>;\n /**\n * Sets a specific menu value.\n *\n * Live examples:\n * - [Submenu with\n * Combobox](https://ariakit.com/examples/menu-nested-combobox)\n * @example\n * store.setValue(\"watching\", [\"issues\"]);\n * store.setValue(\"watching\", (value) => [...value, \"issues\"]);\n */\n setValue: BivariantCallback<\n (\n name: string,\n value: SetStateAction<MenuStoreState<T>[\"values\"][string]>,\n ) => void\n >;\n}\n\nexport interface MenuStoreOptions<T extends MenuStoreValues = MenuStoreValues>\n extends\n StoreOptions<\n MenuStoreState<T>,\n \"orientation\" | \"placement\" | \"hideTimeout\" | \"values\"\n >,\n CompositeStoreOptions,\n HovercardStoreOptions {\n /**\n * A reference to a combobox store. This is used when combining the combobox\n * with a menu (e.g., dropdown menu with a search input). The stores will\n * share the same state.\n */\n combobox?: ComboboxStore | null;\n /**\n * A reference to a parent menu store. This is used on nested menus.\n */\n parent?: MenuStore | null;\n /**\n * A reference to a menubar store. This is used when rendering menus inside a\n * menubar.\n */\n menubar?: MenuBarStore | null;\n /**\n * The default values for the\n * [`values`](https://ariakit.com/reference/menu-provider#values) state.\n *\n * Live examples:\n * - [MenuItemCheckbox](https://ariakit.com/examples/menu-item-checkbox)\n * - [MenuItemRadio](https://ariakit.com/examples/menu-item-radio)\n * @default {}\n */\n defaultValues?: MenuStoreState<T>[\"values\"];\n}\n\nexport interface MenuStoreProps<T extends MenuStoreValues = MenuStoreValues>\n extends MenuStoreOptions<T>, StoreProps<MenuStoreState<T>> {}\n\nexport interface MenuStore<T extends MenuStoreValues = MenuStoreValues>\n extends MenuStoreFunctions<T>, Store<MenuStoreState<T>> {}\n"],"mappings":";;;;;AAsCA,SAAgB,gBAAgB,EAC9B,UACA,QACA,SACA,GAAG,UACe,CAAC,GAAc;CACjC,MAAM,kBAAkB,CAAC,CAAC,WAAW,CAAC;CAEtC,MAAM,QAAQ,WACZ,MAAM,OACN,KAAK,QAAQ,CAAC,QAAQ,CAAC,GACvB,KAAK,UAAU;EACb;EACA;EACA;EACA;EACA;CACF,CAAC,CACH;CAEA,wBAAwB,OAAO,KAAK;CAEpC,MAAM,YAAY,MAAM,SAAS;CAEjC,MAAM,YAAY,qBAAqB;EACrC,GAAG;EACH;EACA,aAAa,aACX,MAAM,aACN,UAAU,aACV,UACF;CACF,CAAC;CAED,MAAM,YAAY,qBAAqB;EACrC,GAAG;EACH;EACA,WAAW,aACT,MAAM,WACN,UAAU,WACV,cACF;EACA,SAAS,aACP,MAAM,SACN,UAAU,SACV,kBAAkB,IAAI,GACxB;EACA,aAAa,aAAa,MAAM,aAAa,UAAU,aAAa,CAAC;CACvE,CAAC;CAcD,MAAM,OAAO,YAAY;EAXvB,GAAG,UAAU,SAAS;EACtB,GAAG,UAAU,SAAS;EACtB,cAAc,aAAa,UAAU,cAAc,WAAoB;EACvE,QAAQ,aACN,MAAM,QACN,UAAU,QACV,MAAM,eACN,CAAC,CACH;CAGkC,GAAG,WAAW,WAAW,KAAK;CAElE,MAAM,YACJ,KAAK,MAAM,CAAC,SAAS,IAAI,UAAU;EACjC,IAAI,MAAM,SAAS;EACnB,KAAK,SAAS,YAAY,IAAI;CAChC,CAAC,CACH;CAEA,MAAM,YACJ,KAAK,QAAQ,CAAC,aAAa,IAAI,UAAU;EACvC,KAAK,SACH,aACA,MAAM,gBAAgB,aAAa,gBAAgB,cACrD;CACF,CAAC,CACH;CAEA,OAAO;EACL,GAAG;EACH,GAAG;EACH,GAAG;EACH;EACA;EACA;EACA,eAAe;GACb,UAAU,KAAK;GACf,QAAQ,QAAQ;EAClB;EACA,kBAAkB,UAAU,KAAK,SAAS,gBAAgB,KAAK;EAC/D,YAAY,WAAW,KAAK,SAAS,UAAU,MAAM;EACrD,WAAW,MAAM,UAAU;GAEzB,IAAI,SAAS,aAAa;GAC1B,IAAI,SAAS,eAAe;GAC5B,IAAI,MAAM,QAAQ,IAAI,GAAG;GACzB,KAAK,SAAS,WAAW,WAAW;IAClC,MAAM,YAAY,OAAO;IACzB,MAAM,YAAY,WAAW,OAAO,SAAS;IAC7C,IAAI,cAAc,WAAW,OAAO;IACpC,OAAO;KACL,GAAG;MACF,OAAO,cAAc,KAAA,KAAa;IACrC;GACF,CAAC;EACH;CACF;AACF"}
@@ -0,0 +1,2 @@
1
+ import { a as MenubarStoreState, i as MenubarStoreProps, n as MenubarStoreFunctions, o as createMenubarStore, r as MenubarStoreOptions, t as MenubarStore } from "../menubar-store-CD3YDYfW.js";
2
+ export { MenubarStore, MenubarStoreFunctions, MenubarStoreOptions, MenubarStoreProps, MenubarStoreState, createMenubarStore };
@@ -0,0 +1,24 @@
1
+ import { createCompositeStore } from "../composite/composite-store.js";
2
+ import { createStore } from "@ariakit/store";
3
+ import { defaultValue } from "@ariakit/utils";
4
+ //#region src/menubar/menubar-store.ts
5
+ /**
6
+ * Creates a menubar store.
7
+ */
8
+ function createMenubarStore(props = {}) {
9
+ const syncState = props.store?.getState();
10
+ const composite = createCompositeStore({
11
+ ...props,
12
+ orientation: defaultValue(props.orientation, syncState?.orientation, "horizontal"),
13
+ focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, true)
14
+ });
15
+ const menubar = createStore({ ...composite.getState() }, composite, props.store);
16
+ return {
17
+ ...composite,
18
+ ...menubar
19
+ };
20
+ }
21
+ //#endregion
22
+ export { createMenubarStore };
23
+
24
+ //# sourceMappingURL=menubar-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menubar-store.js","names":[],"sources":["../../src/menubar/menubar-store.ts"],"sourcesContent":["import { createStore } from \"@ariakit/store\";\nimport type { Store, StoreProps } from \"@ariakit/store\";\nimport { defaultValue } from \"@ariakit/utils\";\nimport type {\n CompositeStoreFunctions,\n CompositeStoreOptions,\n CompositeStoreState,\n} from \"../composite/composite-store.ts\";\nimport { createCompositeStore } from \"../composite/composite-store.ts\";\n\n/**\n * Creates a menubar store.\n */\nexport function createMenubarStore(\n props: MenubarStoreProps = {},\n): MenubarStore {\n const syncState = props.store?.getState();\n\n const composite = createCompositeStore({\n ...props,\n orientation: defaultValue(\n props.orientation,\n syncState?.orientation,\n \"horizontal\" as const,\n ),\n focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, true),\n });\n\n const initialState: MenubarStoreState = {\n ...composite.getState(),\n };\n\n const menubar = createStore(initialState, composite, props.store);\n\n return {\n ...composite,\n ...menubar,\n };\n}\n\nexport interface MenubarStoreState extends CompositeStoreState {}\n\nexport interface MenubarStoreFunctions extends CompositeStoreFunctions {}\n\nexport interface MenubarStoreOptions extends CompositeStoreOptions {}\n\nexport interface MenubarStoreProps\n extends MenubarStoreOptions, StoreProps<MenubarStoreState> {}\n\nexport interface MenubarStore\n extends MenubarStoreFunctions, Store<MenubarStoreState> {}\n"],"mappings":";;;;;;;AAaA,SAAgB,mBACd,QAA2B,CAAC,GACd;CACd,MAAM,YAAY,MAAM,OAAO,SAAS;CAExC,MAAM,YAAY,qBAAqB;EACrC,GAAG;EACH,aAAa,aACX,MAAM,aACN,WAAW,aACX,YACF;EACA,WAAW,aAAa,MAAM,WAAW,WAAW,WAAW,IAAI;CACrE,CAAC;CAMD,MAAM,UAAU,YAAY,EAH1B,GAAG,UAAU,SAAS,EAGe,GAAG,WAAW,MAAM,KAAK;CAEhE,OAAO;EACL,GAAG;EACH,GAAG;CACL;AACF"}
@@ -0,0 +1,16 @@
1
+ import { i as CompositeStoreOptions, n as CompositeStoreFunctions, s as CompositeStoreState } from "./composite-store-B-iDEtZZ.js";
2
+ import { Store, StoreProps } from "@ariakit/store";
3
+
4
+ //#region src/menubar/menubar-store.d.ts
5
+ /**
6
+ * Creates a menubar store.
7
+ */
8
+ declare function createMenubarStore(props?: MenubarStoreProps): MenubarStore;
9
+ interface MenubarStoreState extends CompositeStoreState {}
10
+ interface MenubarStoreFunctions extends CompositeStoreFunctions {}
11
+ interface MenubarStoreOptions extends CompositeStoreOptions {}
12
+ interface MenubarStoreProps extends MenubarStoreOptions, StoreProps<MenubarStoreState> {}
13
+ interface MenubarStore extends MenubarStoreFunctions, Store<MenubarStoreState> {}
14
+ //#endregion
15
+ export { MenubarStoreState as a, MenubarStoreProps as i, MenubarStoreFunctions as n, createMenubarStore as o, MenubarStoreOptions as r, MenubarStore as t };
16
+ //# sourceMappingURL=menubar-store-CD3YDYfW.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menubar-store-CD3YDYfW.d.ts","names":["Store","StoreProps","CompositeStoreFunctions","CompositeStoreOptions","CompositeStoreState","createMenubarStore","MenubarStoreProps","MenubarStore","props","MenubarStoreState","MenubarStoreFunctions","MenubarStoreOptions"],"sources":["../src/menubar/menubar-store.d.ts"],"mappings":";;;;;;AAKA;iBAAwBK,kBAAAA,CAAmBG,KAAAA,GAAQF,iBAAAA,GAAoBC,YAAY;AAAA,UAClEE,iBAAAA,SAA0BL,mBAAmB;AAAA,UAE7CM,qBAAAA,SAA8BR,uBAAuB;AAAA,UAErDS,mBAAAA,SAA4BR,qBAAqB;AAAA,UAEjDG,iBAAAA,SAA0BK,mBAAAA,EAAqBV,UAAAA,CAAWQ,iBAAAA;AAAAA,UAE1DF,YAAAA,SAAqBG,qBAAAA,EAAuBV,KAAAA,CAAMS,iBAAAA"}
@@ -0,0 +1,2 @@
1
+ import { a as PopoverStoreState, i as PopoverStoreProps, n as PopoverStoreFunctions, o as createPopoverStore, r as PopoverStoreOptions, t as PopoverStore } from "../popover-store-DoCiTmUQ.js";
2
+ export { PopoverStore, PopoverStoreFunctions, PopoverStoreOptions, PopoverStoreProps, PopoverStoreState, createPopoverStore };
@@ -0,0 +1,44 @@
1
+ import { createDialogStore } from "../dialog/dialog-store.js";
2
+ import { createStore, mergeStore, omit, throwOnConflictingProps } from "@ariakit/store";
3
+ import { defaultValue } from "@ariakit/utils";
4
+ //#region src/popover/popover-store.ts
5
+ /**
6
+ * Creates a popover store.
7
+ */
8
+ function createPopoverStore({ popover: otherPopover, ...props } = {}) {
9
+ const store = mergeStore(props.store, omit(otherPopover, [
10
+ "arrowElement",
11
+ "anchorElement",
12
+ "contentElement",
13
+ "popoverElement",
14
+ "disclosureElement"
15
+ ]));
16
+ throwOnConflictingProps(props, store);
17
+ const syncState = store?.getState();
18
+ const dialog = createDialogStore({
19
+ ...props,
20
+ store
21
+ });
22
+ const placement = defaultValue(props.placement, syncState?.placement, "bottom");
23
+ const popover = createStore({
24
+ ...dialog.getState(),
25
+ placement,
26
+ currentPlacement: placement,
27
+ anchorElement: defaultValue(syncState?.anchorElement, null),
28
+ popoverElement: defaultValue(syncState?.popoverElement, null),
29
+ arrowElement: defaultValue(syncState?.arrowElement, null),
30
+ rendered: Symbol("rendered")
31
+ }, dialog, store);
32
+ return {
33
+ ...dialog,
34
+ ...popover,
35
+ setAnchorElement: (element) => popover.setState("anchorElement", element),
36
+ setPopoverElement: (element) => popover.setState("popoverElement", element),
37
+ setArrowElement: (element) => popover.setState("arrowElement", element),
38
+ render: () => popover.setState("rendered", Symbol("rendered"))
39
+ };
40
+ }
41
+ //#endregion
42
+ export { createPopoverStore };
43
+
44
+ //# sourceMappingURL=popover-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popover-store.js","names":[],"sources":["../../src/popover/popover-store.ts"],"sourcesContent":["import {\n createStore,\n mergeStore,\n omit,\n throwOnConflictingProps,\n} from \"@ariakit/store\";\nimport type { Store, StoreOptions, StoreProps } from \"@ariakit/store\";\nimport { defaultValue } from \"@ariakit/utils\";\nimport type { SetState } from \"@ariakit/utils\";\nimport type {\n DialogStoreFunctions,\n DialogStoreOptions,\n DialogStoreState,\n} from \"../dialog/dialog-store.ts\";\nimport { createDialogStore } from \"../dialog/dialog-store.ts\";\n\ntype BasePlacement = \"top\" | \"bottom\" | \"left\" | \"right\";\n\ntype Placement =\n | BasePlacement\n | `${BasePlacement}-start`\n | `${BasePlacement}-end`;\n\n/**\n * Creates a popover store.\n */\nexport function createPopoverStore({\n popover: otherPopover,\n ...props\n}: PopoverStoreProps = {}): PopoverStore {\n const store = mergeStore(\n props.store,\n omit(otherPopover, [\n \"arrowElement\",\n \"anchorElement\",\n \"contentElement\",\n \"popoverElement\",\n \"disclosureElement\",\n ]),\n );\n\n throwOnConflictingProps(props, store);\n\n const syncState = store?.getState();\n\n const dialog = createDialogStore({ ...props, store });\n\n const placement = defaultValue(\n props.placement,\n syncState?.placement,\n \"bottom\" as const,\n );\n\n const initialState: PopoverStoreState = {\n ...dialog.getState(),\n placement,\n currentPlacement: placement,\n anchorElement: defaultValue(syncState?.anchorElement, null),\n popoverElement: defaultValue(syncState?.popoverElement, null),\n arrowElement: defaultValue(syncState?.arrowElement, null),\n rendered: Symbol(\"rendered\"),\n };\n const popover = createStore(initialState, dialog, store);\n\n return {\n ...dialog,\n ...popover,\n setAnchorElement: (element) => popover.setState(\"anchorElement\", element),\n setPopoverElement: (element) => popover.setState(\"popoverElement\", element),\n setArrowElement: (element) => popover.setState(\"arrowElement\", element),\n render: () => popover.setState(\"rendered\", Symbol(\"rendered\")),\n };\n}\n\nexport interface PopoverStoreState extends DialogStoreState {\n /**\n * The anchor element.\n *\n * Live examples:\n * - [Navigation Menubar](https://ariakit.com/examples/menubar-navigation)\n */\n anchorElement: HTMLElement | null;\n /**\n * The popover element that will render the placement attributes.\n *\n * Live examples:\n * - [Form with Select](https://ariakit.com/examples/form-select)\n * - [Sliding Menu](https://ariakit.com/examples/menu-slide)\n * - [Responsive Popover](https://ariakit.com/examples/popover-responsive)\n */\n popoverElement: HTMLElement | null;\n /**\n * The arrow element.\n */\n arrowElement: HTMLElement | null;\n /**\n * The current temporary position of the popover. This might differ from the\n * [`placement`](https://ariakit.com/reference/popover-provider#placement)\n * state if the popover has had to adjust its position dynamically.\n *\n * Live examples:\n * - [Tooltip with\n * Motion](https://ariakit.com/examples/tooltip-framer-motion)\n */\n currentPlacement: Placement;\n /**\n * The placement of the popover.\n *\n * Live examples:\n * - [Submenu with\n * Combobox](https://ariakit.com/examples/menu-nested-combobox)\n * - [Sliding Menu](https://ariakit.com/examples/menu-slide)\n * - [Navigation Menubar](https://ariakit.com/examples/menubar-navigation)\n * - [Selection Popover](https://ariakit.com/examples/popover-selection)\n * - [Standalone Popover](https://ariakit.com/examples/popover-standalone)\n * - [Select Grid](https://ariakit.com/examples/select-grid)\n * @default \"bottom\"\n */\n placement: Placement;\n /**\n * A symbol that's used to recompute the popover position when the\n * [`render`](https://ariakit.com/reference/use-popover-store#render) method\n * is called.\n */\n rendered: symbol;\n}\n\nexport interface PopoverStoreFunctions extends DialogStoreFunctions {\n /**\n * Sets the anchor element.\n *\n * Live examples:\n * - [Navigation Menubar](https://ariakit.com/examples/menubar-navigation)\n */\n setAnchorElement: SetState<PopoverStoreState[\"anchorElement\"]>;\n /**\n * Sets the popover element.\n */\n setPopoverElement: SetState<PopoverStoreState[\"popoverElement\"]>;\n /**\n * Sets the arrow element.\n */\n setArrowElement: SetState<PopoverStoreState[\"arrowElement\"]>;\n /**\n * A function that can be used to recompute the popover position. This is\n * useful when the popover anchor changes in a way that affects the popover\n * position.\n *\n * Live examples:\n * - [Textarea with inline\n * Combobox](https://ariakit.com/examples/combobox-textarea)\n * - [Selection Popover](https://ariakit.com/examples/popover-selection)\n */\n render: () => void;\n}\n\nexport interface PopoverStoreOptions\n extends DialogStoreOptions, StoreOptions<PopoverStoreState, \"placement\"> {\n /**\n * A reference to another popover store that's controlling another popover to\n * keep them in sync.\n */\n popover?: PopoverStore | null;\n}\n\nexport interface PopoverStoreProps\n extends PopoverStoreOptions, StoreProps<PopoverStoreState> {}\n\nexport interface PopoverStore\n extends PopoverStoreFunctions, Store<PopoverStoreState> {}\n"],"mappings":";;;;;;;AA0BA,SAAgB,mBAAmB,EACjC,SAAS,cACT,GAAG,UACkB,CAAC,GAAiB;CACvC,MAAM,QAAQ,WACZ,MAAM,OACN,KAAK,cAAc;EACjB;EACA;EACA;EACA;EACA;CACF,CAAC,CACH;CAEA,wBAAwB,OAAO,KAAK;CAEpC,MAAM,YAAY,OAAO,SAAS;CAElC,MAAM,SAAS,kBAAkB;EAAE,GAAG;EAAO;CAAM,CAAC;CAEpD,MAAM,YAAY,aAChB,MAAM,WACN,WAAW,WACX,QACF;CAWA,MAAM,UAAU,YAAY;EAR1B,GAAG,OAAO,SAAS;EACnB;EACA,kBAAkB;EAClB,eAAe,aAAa,WAAW,eAAe,IAAI;EAC1D,gBAAgB,aAAa,WAAW,gBAAgB,IAAI;EAC5D,cAAc,aAAa,WAAW,cAAc,IAAI;EACxD,UAAU,OAAO,UAAU;CAEU,GAAG,QAAQ,KAAK;CAEvD,OAAO;EACL,GAAG;EACH,GAAG;EACH,mBAAmB,YAAY,QAAQ,SAAS,iBAAiB,OAAO;EACxE,oBAAoB,YAAY,QAAQ,SAAS,kBAAkB,OAAO;EAC1E,kBAAkB,YAAY,QAAQ,SAAS,gBAAgB,OAAO;EACtE,cAAc,QAAQ,SAAS,YAAY,OAAO,UAAU,CAAC;CAC/D;AACF"}
@@ -0,0 +1,106 @@
1
+ import { a as DialogStoreState, n as DialogStoreFunctions, r as DialogStoreOptions } from "./dialog-store-BOLvw2IX.js";
2
+ import { Store, StoreOptions, StoreProps } from "@ariakit/store";
3
+ import { SetState } from "@ariakit/utils";
4
+
5
+ //#region src/popover/popover-store.d.ts
6
+ type BasePlacement = "top" | "bottom" | "left" | "right";
7
+ type Placement = BasePlacement | `${BasePlacement}-start` | `${BasePlacement}-end`;
8
+ /**
9
+ * Creates a popover store.
10
+ */
11
+ declare function createPopoverStore({
12
+ popover: otherPopover,
13
+ ...props
14
+ }?: PopoverStoreProps): PopoverStore;
15
+ interface PopoverStoreState extends DialogStoreState {
16
+ /**
17
+ * The anchor element.
18
+ *
19
+ * Live examples:
20
+ * - [Navigation Menubar](https://ariakit.com/examples/menubar-navigation)
21
+ */
22
+ anchorElement: HTMLElement | null;
23
+ /**
24
+ * The popover element that will render the placement attributes.
25
+ *
26
+ * Live examples:
27
+ * - [Form with Select](https://ariakit.com/examples/form-select)
28
+ * - [Sliding Menu](https://ariakit.com/examples/menu-slide)
29
+ * - [Responsive Popover](https://ariakit.com/examples/popover-responsive)
30
+ */
31
+ popoverElement: HTMLElement | null;
32
+ /**
33
+ * The arrow element.
34
+ */
35
+ arrowElement: HTMLElement | null;
36
+ /**
37
+ * The current temporary position of the popover. This might differ from the
38
+ * [`placement`](https://ariakit.com/reference/popover-provider#placement)
39
+ * state if the popover has had to adjust its position dynamically.
40
+ *
41
+ * Live examples:
42
+ * - [Tooltip with
43
+ * Motion](https://ariakit.com/examples/tooltip-framer-motion)
44
+ */
45
+ currentPlacement: Placement;
46
+ /**
47
+ * The placement of the popover.
48
+ *
49
+ * Live examples:
50
+ * - [Submenu with
51
+ * Combobox](https://ariakit.com/examples/menu-nested-combobox)
52
+ * - [Sliding Menu](https://ariakit.com/examples/menu-slide)
53
+ * - [Navigation Menubar](https://ariakit.com/examples/menubar-navigation)
54
+ * - [Selection Popover](https://ariakit.com/examples/popover-selection)
55
+ * - [Standalone Popover](https://ariakit.com/examples/popover-standalone)
56
+ * - [Select Grid](https://ariakit.com/examples/select-grid)
57
+ * @default "bottom"
58
+ */
59
+ placement: Placement;
60
+ /**
61
+ * A symbol that's used to recompute the popover position when the
62
+ * [`render`](https://ariakit.com/reference/use-popover-store#render) method
63
+ * is called.
64
+ */
65
+ rendered: symbol;
66
+ }
67
+ interface PopoverStoreFunctions extends DialogStoreFunctions {
68
+ /**
69
+ * Sets the anchor element.
70
+ *
71
+ * Live examples:
72
+ * - [Navigation Menubar](https://ariakit.com/examples/menubar-navigation)
73
+ */
74
+ setAnchorElement: SetState<PopoverStoreState["anchorElement"]>;
75
+ /**
76
+ * Sets the popover element.
77
+ */
78
+ setPopoverElement: SetState<PopoverStoreState["popoverElement"]>;
79
+ /**
80
+ * Sets the arrow element.
81
+ */
82
+ setArrowElement: SetState<PopoverStoreState["arrowElement"]>;
83
+ /**
84
+ * A function that can be used to recompute the popover position. This is
85
+ * useful when the popover anchor changes in a way that affects the popover
86
+ * position.
87
+ *
88
+ * Live examples:
89
+ * - [Textarea with inline
90
+ * Combobox](https://ariakit.com/examples/combobox-textarea)
91
+ * - [Selection Popover](https://ariakit.com/examples/popover-selection)
92
+ */
93
+ render: () => void;
94
+ }
95
+ interface PopoverStoreOptions extends DialogStoreOptions, StoreOptions<PopoverStoreState, "placement"> {
96
+ /**
97
+ * A reference to another popover store that's controlling another popover to
98
+ * keep them in sync.
99
+ */
100
+ popover?: PopoverStore | null;
101
+ }
102
+ interface PopoverStoreProps extends PopoverStoreOptions, StoreProps<PopoverStoreState> {}
103
+ interface PopoverStore extends PopoverStoreFunctions, Store<PopoverStoreState> {}
104
+ //#endregion
105
+ export { PopoverStoreState as a, PopoverStoreProps as i, PopoverStoreFunctions as n, createPopoverStore as o, PopoverStoreOptions as r, PopoverStore as t };
106
+ //# sourceMappingURL=popover-store-DoCiTmUQ.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popover-store-DoCiTmUQ.d.ts","names":["Store","StoreOptions","StoreProps","SetState","DialogStoreFunctions","DialogStoreOptions","DialogStoreState","BasePlacement","Placement","createPopoverStore","otherPopover","PopoverStoreProps","PopoverStore","popover","props","PopoverStoreState","HTMLElement","anchorElement","popoverElement","arrowElement","currentPlacement","placement","rendered","PopoverStoreFunctions","setAnchorElement","setPopoverElement","setArrowElement","render","PopoverStoreOptions"],"sources":["../src/popover/popover-store.d.ts"],"mappings":";;;;;KAGKO,aAAAA;AAAAA,KACAC,SAAAA,GAAYD,aAAAA,MAAmBA,aAAAA,cAA2BA,aAAAA;AAF6C;;;AAAA,iBAMpFE,kBAAAA,CAAAA;EAAqBI,OAAAA,EAASH,YAAAA;EAAAA,GAAiBI;AAAAA,IAAUH,iBAAAA,GAAoBC,YAAAA;AAAAA,UACpFG,iBAAAA,SAA0BT,gBAAAA;EALtCE;;;;;;EAYDS,aAAAA,EAAeD,WAAAA;EAZyD;;;;;AAAA;AAI5E;;EAiBIE,cAAAA,EAAgBF,WAAAA;EAjBkCN;;;EAqBlDS,YAAAA,EAAcH,WAAAA;EArB+F;;;;;;;AAAA;AACjH;EA8BII,gBAAAA,EAAkBZ,SAAAA;;;;;;;;;;;;;;EAclBa,SAAAA,EAAWb,SAAAA;EAxBXW;;;;;EA8BAG,QAAAA;AAAAA;AAAAA,UAEaC,qBAAAA,SAA8BnB,oBAAAA;EAFnC;AAEZ;;;;;EAOIoB,gBAAAA,EAAkBrB,QAAAA,CAASY,iBAAAA;EAIRZ;;;EAAnBsB,iBAAAA,EAAmBtB,QAAAA,CAASY,iBAAAA;EAXmC;;;EAe/DW,eAAAA,EAAiBvB,QAAAA,CAASY,iBAAAA;EARRZ;;;;;;;;;;EAmBlBwB,MAAAA;AAAAA;AAAAA,UAEaC,mBAAAA,SAA4BvB,kBAAAA,EAAoBJ,YAAAA,CAAac,iBAAAA;;;;;EAK1EF,OAAAA,GAAUD,YAAAA;AAAAA;AAAAA,UAEGD,iBAAAA,SAA0BiB,mBAAAA,EAAqB1B,UAAAA,CAAWa,iBAAAA;AAAAA,UAE1DH,YAAAA,SAAqBW,qBAAAA,EAAuBvB,KAAAA,CAAMe,iBAAAA"}
@@ -0,0 +1,42 @@
1
+ import { i as CompositeStoreOptions, n as CompositeStoreFunctions, s as CompositeStoreState } from "../composite-store-B-iDEtZZ.js";
2
+ import { Store, StoreOptions, StoreProps } from "@ariakit/store";
3
+ import { SetState } from "@ariakit/utils";
4
+
5
+ //#region src/radio/radio-store.d.ts
6
+ /**
7
+ * Creates a radio store.
8
+ */
9
+ declare function createRadioStore({
10
+ ...props
11
+ }?: RadioStoreProps): RadioStore;
12
+ interface RadioStoreState extends CompositeStoreState {
13
+ /** @default true */
14
+ focusLoop: CompositeStoreState["focusLoop"];
15
+ /**
16
+ * The value of the radio group.
17
+ * @default null
18
+ */
19
+ value: string | number | null;
20
+ }
21
+ interface RadioStoreFunctions extends CompositeStoreFunctions {
22
+ /**
23
+ * Sets the [`value`](https://ariakit.com/reference/radio-provider#value)
24
+ * state.
25
+ * @example
26
+ * store.setValue("apple");
27
+ * store.setValue((value) => value === "apple" ? "orange" : "apple");
28
+ */
29
+ setValue: SetState<RadioStoreState["value"]>;
30
+ }
31
+ interface RadioStoreOptions extends StoreOptions<RadioStoreState, "focusLoop" | "value">, CompositeStoreOptions {
32
+ /**
33
+ * The default value of the radio group.
34
+ * @default null
35
+ */
36
+ defaultValue?: RadioStoreState["value"];
37
+ }
38
+ interface RadioStoreProps extends RadioStoreOptions, StoreProps<RadioStoreState> {}
39
+ interface RadioStore extends RadioStoreFunctions, Store<RadioStoreState> {}
40
+ //#endregion
41
+ export { RadioStore, RadioStoreFunctions, RadioStoreOptions, RadioStoreProps, RadioStoreState, createRadioStore };
42
+ //# sourceMappingURL=radio-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"radio-store.d.ts","names":["Store","StoreOptions","StoreProps","SetState","CompositeStoreFunctions","CompositeStoreOptions","CompositeStoreState","createRadioStore","RadioStoreProps","RadioStore","props","RadioStoreState","focusLoop","value","RadioStoreFunctions","setValue","RadioStoreOptions","defaultValue"],"sources":["../../src/radio/radio-store.d.ts"],"mappings":";;;;;;;AAMA;iBAAwBO,gBAAAA,CAAAA;EAAAA,GAAsBG;AAAAA,IAAUF,eAAAA,GAAkBC,UAAU;AAAA,UACnEE,eAAAA,SAAwBL,mBAAmB;EADwB;EAGhFM,SAAAA,EAAWN,mBAAAA;EAHyCE;;;AAA4B;EAQhFK,KAAAA;AAAAA;AAAAA,UAEaC,mBAAAA,SAA4BV,uBAAAA;EATe;;;;;;AAOnD;EAULW,QAAAA,EAAUZ,QAAAA,CAASQ,eAAAA;AAAAA;AAAAA,UAENK,iBAAAA,SAA0Bf,YAAAA,CAAaU,eAAAA,0BAAyCN,qBAAAA;EAF1EM;;;;EAOnBM,YAAAA,GAAeN,eAAAA;AAAAA;AAAAA,UAEFH,eAAAA,SAAwBQ,iBAAAA,EAAmBd,UAAAA,CAAWS,eAAAA;AAAAA,UAEtDF,UAAAA,SAAmBK,mBAAAA,EAAqBd,KAAAA,CAAMW,eAAAA"}
@@ -0,0 +1,27 @@
1
+ import { createCompositeStore } from "../composite/composite-store.js";
2
+ import { createStore } from "@ariakit/store";
3
+ import { defaultValue } from "@ariakit/utils";
4
+ //#region src/radio/radio-store.ts
5
+ /**
6
+ * Creates a radio store.
7
+ */
8
+ function createRadioStore({ ...props } = {}) {
9
+ const syncState = props.store?.getState();
10
+ const composite = createCompositeStore({
11
+ ...props,
12
+ focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, true)
13
+ });
14
+ const radio = createStore({
15
+ ...composite.getState(),
16
+ value: defaultValue(props.value, syncState?.value, props.defaultValue, null)
17
+ }, composite, props.store);
18
+ return {
19
+ ...composite,
20
+ ...radio,
21
+ setValue: (value) => radio.setState("value", value)
22
+ };
23
+ }
24
+ //#endregion
25
+ export { createRadioStore };
26
+
27
+ //# sourceMappingURL=radio-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"radio-store.js","names":[],"sources":["../../src/radio/radio-store.ts"],"sourcesContent":["import { createStore } from \"@ariakit/store\";\nimport type { Store, StoreOptions, StoreProps } from \"@ariakit/store\";\nimport { defaultValue } from \"@ariakit/utils\";\nimport type { SetState } from \"@ariakit/utils\";\nimport type {\n CompositeStoreFunctions,\n CompositeStoreOptions,\n CompositeStoreState,\n} from \"../composite/composite-store.ts\";\nimport { createCompositeStore } from \"../composite/composite-store.ts\";\n\n/**\n * Creates a radio store.\n */\nexport function createRadioStore({\n ...props\n}: RadioStoreProps = {}): RadioStore {\n const syncState = props.store?.getState();\n\n const composite = createCompositeStore({\n ...props,\n focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, true),\n });\n\n const initialState: RadioStoreState = {\n ...composite.getState(),\n value: defaultValue(\n props.value,\n syncState?.value,\n props.defaultValue,\n null,\n ),\n };\n\n const radio = createStore(initialState, composite, props.store);\n\n return {\n ...composite,\n ...radio,\n setValue: (value) => radio.setState(\"value\", value),\n };\n}\n\nexport interface RadioStoreState extends CompositeStoreState {\n /** @default true */\n focusLoop: CompositeStoreState[\"focusLoop\"];\n /**\n * The value of the radio group.\n * @default null\n */\n value: string | number | null;\n}\n\nexport interface RadioStoreFunctions extends CompositeStoreFunctions {\n /**\n * Sets the [`value`](https://ariakit.com/reference/radio-provider#value)\n * state.\n * @example\n * store.setValue(\"apple\");\n * store.setValue((value) => value === \"apple\" ? \"orange\" : \"apple\");\n */\n setValue: SetState<RadioStoreState[\"value\"]>;\n}\n\nexport interface RadioStoreOptions\n extends\n StoreOptions<RadioStoreState, \"focusLoop\" | \"value\">,\n CompositeStoreOptions {\n /**\n * The default value of the radio group.\n * @default null\n */\n defaultValue?: RadioStoreState[\"value\"];\n}\n\nexport interface RadioStoreProps\n extends RadioStoreOptions, StoreProps<RadioStoreState> {}\n\nexport interface RadioStore\n extends RadioStoreFunctions, Store<RadioStoreState> {}\n"],"mappings":";;;;;;;AAcA,SAAgB,iBAAiB,EAC/B,GAAG,UACgB,CAAC,GAAe;CACnC,MAAM,YAAY,MAAM,OAAO,SAAS;CAExC,MAAM,YAAY,qBAAqB;EACrC,GAAG;EACH,WAAW,aAAa,MAAM,WAAW,WAAW,WAAW,IAAI;CACrE,CAAC;CAYD,MAAM,QAAQ,YAAY;EATxB,GAAG,UAAU,SAAS;EACtB,OAAO,aACL,MAAM,OACN,WAAW,OACX,MAAM,cACN,IACF;CAGmC,GAAG,WAAW,MAAM,KAAK;CAE9D,OAAO;EACL,GAAG;EACH,GAAG;EACH,WAAW,UAAU,MAAM,SAAS,SAAS,KAAK;CACpD;AACF"}
@@ -0,0 +1,116 @@
1
+ import { i as CompositeStoreOptions, n as CompositeStoreFunctions, r as CompositeStoreItem, s as CompositeStoreState } from "../composite-store-B-iDEtZZ.js";
2
+ import { a as PopoverStoreState, n as PopoverStoreFunctions, r as PopoverStoreOptions } from "../popover-store-DoCiTmUQ.js";
3
+ import { ComboboxStore } from "../combobox/combobox-store.js";
4
+ import { Store, StoreOptions, StoreProps } from "@ariakit/store";
5
+ import { PickRequired, SetState } from "@ariakit/utils";
6
+
7
+ //#region src/select/select-store.d.ts
8
+ type MutableValue<T extends SelectStoreValue = SelectStoreValue> = T extends string ? string : T;
9
+ declare function createSelectStore<T extends SelectStoreValue = SelectStoreValue>(props: PickRequired<SelectStoreProps<T>, "value" | "defaultValue">): SelectStore<T>;
10
+ declare function createSelectStore(props?: SelectStoreProps): SelectStore;
11
+ type SelectStoreValue = string | readonly string[];
12
+ interface SelectStoreItem extends CompositeStoreItem {
13
+ value?: string;
14
+ }
15
+ interface SelectStoreState<T extends SelectStoreValue = SelectStoreValue> extends CompositeStoreState<SelectStoreItem>, PopoverStoreState {
16
+ /** @default true */
17
+ virtualFocus: CompositeStoreState<SelectStoreItem>["virtualFocus"];
18
+ /** @default null */
19
+ activeId: CompositeStoreState<SelectStoreItem>["activeId"];
20
+ /** @default "vertical" */
21
+ orientation: CompositeStoreState<SelectStoreItem>["orientation"];
22
+ /** @default "bottom-start" */
23
+ placement: PopoverStoreState["placement"];
24
+ /**
25
+ * The select value.
26
+ *
27
+ * Live examples:
28
+ * - [Form with Select](https://ariakit.com/examples/form-select)
29
+ * - [Select Grid](https://ariakit.com/examples/select-grid)
30
+ * - [Select with custom
31
+ * items](https://ariakit.com/examples/select-item-custom)
32
+ * - [Multi-Select](https://ariakit.com/examples/select-multiple)
33
+ * - [Toolbar with Select](https://ariakit.com/examples/toolbar-select)
34
+ * - [Select with Next.js App
35
+ * Router](https://ariakit.com/examples/select-next-router)
36
+ */
37
+ value: MutableValue<T>;
38
+ /**
39
+ * Whether the select
40
+ * [`value`](https://ariakit.com/reference/select-provider#value) should be
41
+ * set when the active item changes by moving (which usually happens when
42
+ * moving to an item using the keyboard).
43
+ *
44
+ * Live examples:
45
+ * - [Select Grid](https://ariakit.com/examples/select-grid)
46
+ * - [Select with custom
47
+ * items](https://ariakit.com/examples/select-item-custom)
48
+ * @default false
49
+ */
50
+ setValueOnMove: boolean;
51
+ /**
52
+ * The select label element.
53
+ */
54
+ labelElement: HTMLElement | null;
55
+ /**
56
+ * The select button element.
57
+ *
58
+ * Live examples:
59
+ * - [Form with Select](https://ariakit.com/examples/form-select)
60
+ */
61
+ selectElement: HTMLElement | null;
62
+ /**
63
+ * The select list element.
64
+ */
65
+ listElement: HTMLElement | null;
66
+ }
67
+ interface SelectStoreFunctions<T extends SelectStoreValue = SelectStoreValue> extends Pick<SelectStoreOptions<T>, "combobox">, CompositeStoreFunctions<SelectStoreItem>, PopoverStoreFunctions {
68
+ /**
69
+ * Sets the [`value`](https://ariakit.com/reference/select-provider#value)
70
+ * state.
71
+ * @example
72
+ * store.setValue("Apple");
73
+ * store.setValue(["Apple", "Banana"]);
74
+ * store.setValue((value) => value === "Apple" ? "Banana" : "Apple"));
75
+ */
76
+ setValue: SetState<SelectStoreState<T>["value"]>;
77
+ /**
78
+ * Sets the `labelElement` state.
79
+ */
80
+ setLabelElement: SetState<SelectStoreState<T>["labelElement"]>;
81
+ /**
82
+ * Sets the `selectElement` state.
83
+ */
84
+ setSelectElement: SetState<SelectStoreState<T>["selectElement"]>;
85
+ /**
86
+ * Sets the `listElement` state.
87
+ */
88
+ setListElement: SetState<SelectStoreState<T>["listElement"]>;
89
+ }
90
+ interface SelectStoreOptions<T extends SelectStoreValue = SelectStoreValue> extends StoreOptions<SelectStoreState<T>, "virtualFocus" | "activeId" | "orientation" | "placement" | "value" | "setValueOnMove">, CompositeStoreOptions<SelectStoreItem>, PopoverStoreOptions {
91
+ /**
92
+ * A reference to a combobox store. This is used when combining the combobox
93
+ * with a select (e.g., select with a search input). The stores will share the
94
+ * same state.
95
+ */
96
+ combobox?: ComboboxStore | null;
97
+ /**
98
+ * The default value. If not set, the first non-disabled item will be used.
99
+ *
100
+ * Live examples:
101
+ * - [Form with Select](https://ariakit.com/examples/form-select)
102
+ * - [Animated Select](https://ariakit.com/examples/select-animated)
103
+ * - [Select with Combobox](https://ariakit.com/examples/select-combobox)
104
+ * - [SelectGroup](https://ariakit.com/examples/select-group)
105
+ * - [Select with Next.js App
106
+ * Router](https://ariakit.com/examples/select-next-router)
107
+ * - [Select with Combobox and
108
+ * Tabs](https://ariakit.com/examples/select-combobox-tab)
109
+ */
110
+ defaultValue?: SelectStoreState<T>["value"];
111
+ }
112
+ interface SelectStoreProps<T extends SelectStoreValue = SelectStoreValue> extends SelectStoreOptions<T>, StoreProps<SelectStoreState<T>> {}
113
+ interface SelectStore<T extends SelectStoreValue = SelectStoreValue> extends SelectStoreFunctions<T>, Store<SelectStoreState<T>> {}
114
+ //#endregion
115
+ export { SelectStore, SelectStoreFunctions, SelectStoreItem, SelectStoreOptions, SelectStoreProps, SelectStoreState, SelectStoreValue, createSelectStore };
116
+ //# sourceMappingURL=select-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select-store.d.ts","names":["Store","StoreOptions","StoreProps","PickRequired","SetState","ComboboxStore","CompositeStoreFunctions","CompositeStoreItem","CompositeStoreOptions","CompositeStoreState","PopoverStoreFunctions","PopoverStoreOptions","PopoverStoreState","MutableValue","T","SelectStoreValue","createSelectStore","SelectStoreProps","SelectStore","props","SelectStoreItem","value","SelectStoreState","HTMLElement","virtualFocus","activeId","orientation","placement","setValueOnMove","labelElement","selectElement","listElement","SelectStoreFunctions","SelectStoreOptions","Pick","setValue","setLabelElement","setSelectElement","setListElement","combobox","defaultValue"],"sources":["../../src/select/select-store.d.ts"],"mappings":";;;;;;;KAKKa,YAAAA,WAAuBE,gBAAAA,GAAmBA,gBAAAA,IAAoBD,CAAAA,2BAA4BA,CAAAA;AAAAA,iBACvEE,iBAAAA,WAA4BD,gBAAAA,GAAmBA,gBAAAA,CAAAA,CAAkBI,KAAAA,EAAOhB,YAAAA,CAAac,gBAAAA,CAAiBH,CAAAA,+BAAgCI,WAAAA,CAAYJ,CAAAA;AAAAA,iBAClJE,iBAAAA,CAAkBG,KAAAA,GAAQF,gBAAAA,GAAmBC,WAAW;AAAA,KACpEH,gBAAAA;AAAAA,UACKK,eAAAA,SAAwBb,kBAAkB;EACvDc,KAAK;AAAA;AAAA,UAEQC,gBAAAA,WAA2BP,gBAAAA,GAAmBA,gBAAAA,UAA0BN,mBAAAA,CAAoBW,eAAAA,GAAkBR,iBAAAA;EAPhCE;EAS3FU,YAAAA,EAAcf,mBAAAA,CAAoBW,eAAAA;EAT0D;EAW5FK,QAAAA,EAAUhB,mBAAAA,CAAoBW,eAAAA;EAXNL;EAaxBW,WAAAA,EAAajB,mBAAAA,CAAoBW,eAAAA;EAb8BN;EAe/Da,SAAAA,EAAWf,iBAAAA;EAfiF;AAAA;AAChG;;;;;;;;;;;EA4BIS,KAAAA,EAAOR,YAAAA,CAAaC,CAAAA;EA5BkBA;;;;;;;;;;AAAiI;AAC3K;EAwCIc,cAAAA;;;;EAIAC,YAAAA,EAAcN,WAAAA;EA5CmDL;;AAAW;AAChF;;;EAkDIY,aAAAA,EAAeP,WAAAA;EAlDS;AAC5B;;EAqDIQ,WAAAA,EAAaR,WAAAA;AAAAA;AAAAA,UAEAS,oBAAAA,WAA+BjB,gBAAAA,GAAmBA,gBAAAA,UAA0BmB,IAAAA,CAAKD,kBAAAA,CAAmBnB,CAAAA,gBAAiBR,uBAAAA,CAAwBc,eAAAA,GAAkBV,qBAAAA;EApD/JY;;;;;;;;EA6Dba,QAAAA,EAAU/B,QAAAA,CAASkB,gBAAAA,CAAiBR,CAAAA;EAzD1BL;;;EA6DV2B,eAAAA,EAAiBhC,QAAAA,CAASkB,gBAAAA,CAAiBR,CAAAA;EA3CvBA;;;EA+CpBuB,gBAAAA,EAAkBjC,QAAAA,CAASkB,gBAAAA,CAAiBR,CAAAA;EAnB/BS;;;EAuBbe,cAAAA,EAAgBlC,QAAAA,CAASkB,gBAAAA,CAAiBR,CAAAA;AAAAA;AAAAA,UAE7BmB,kBAAAA,WAA6BlB,gBAAAA,GAAmBA,gBAAAA,UAA0Bd,YAAAA,CAAaqB,gBAAAA,CAAiBR,CAAAA,4FAA6FN,qBAAAA,CAAsBY,eAAAA,GAAkBT,mBAAAA;EA3ElNI;;;;;EAiFxCwB,QAAAA,GAAWlC,aAAAA;EA/EGI;;;;;;;;;;;;;EA6Fd+B,YAAAA,GAAelB,gBAAAA,CAAiBR,CAAAA;AAAAA;AAAAA,UAEnBG,gBAAAA,WAA2BF,gBAAAA,GAAmBA,gBAAAA,UAA0BkB,kBAAAA,CAAmBnB,CAAAA,GAAIZ,UAAAA,CAAWoB,gBAAAA,CAAiBR,CAAAA;AAAAA,UAE3HI,WAAAA,WAAsBH,gBAAAA,GAAmBA,gBAAAA,UAA0BiB,oBAAAA,CAAqBlB,CAAAA,GAAId,KAAAA,CAAMsB,gBAAAA,CAAiBR,CAAAA"}
@@ -0,0 +1,93 @@
1
+ import { createCompositeStore } from "../composite/composite-store.js";
2
+ import { createPopoverStore } from "../popover/popover-store.js";
3
+ import { batch, createStore, mergeStore, omit, setup, sync, throwOnConflictingProps } from "@ariakit/store";
4
+ import { defaultValue, toArray } from "@ariakit/utils";
5
+ //#region src/select/select-store.ts
6
+ function createSelectStore({ combobox, ...props } = {}) {
7
+ const store = mergeStore(props.store, omit(combobox, [
8
+ "value",
9
+ "items",
10
+ "renderedItems",
11
+ "baseElement",
12
+ "arrowElement",
13
+ "anchorElement",
14
+ "contentElement",
15
+ "popoverElement",
16
+ "disclosureElement"
17
+ ]));
18
+ throwOnConflictingProps(props, store);
19
+ const syncState = store.getState();
20
+ const composite = createCompositeStore({
21
+ ...props,
22
+ store,
23
+ virtualFocus: defaultValue(props.virtualFocus, syncState.virtualFocus, true),
24
+ includesBaseElement: defaultValue(props.includesBaseElement, syncState.includesBaseElement, false),
25
+ activeId: defaultValue(props.activeId, syncState.activeId, props.defaultActiveId, null),
26
+ orientation: defaultValue(props.orientation, syncState.orientation, "vertical")
27
+ });
28
+ const popover = createPopoverStore({
29
+ ...props,
30
+ store,
31
+ placement: defaultValue(props.placement, syncState.placement, "bottom-start")
32
+ });
33
+ const initialValue = /* @__PURE__ */ new String("");
34
+ const initialState = {
35
+ ...composite.getState(),
36
+ ...popover.getState(),
37
+ value: defaultValue(props.value, syncState.value, props.defaultValue, initialValue),
38
+ setValueOnMove: defaultValue(props.setValueOnMove, syncState.setValueOnMove, false),
39
+ labelElement: defaultValue(syncState.labelElement, null),
40
+ selectElement: defaultValue(syncState.selectElement, null),
41
+ listElement: defaultValue(syncState.listElement, null)
42
+ };
43
+ const select = createStore(initialState, composite, popover, store);
44
+ setup(select, () => sync(select, ["value", "items"], (state) => {
45
+ if (state.value !== initialValue) return;
46
+ if (!state.items.length) return;
47
+ const item = state.items.find((item) => !item.disabled && item.value != null);
48
+ if (item?.value == null) return;
49
+ select.setState("value", item.value);
50
+ }));
51
+ setup(select, () => sync(select, ["mounted"], (state) => {
52
+ if (state.mounted) return;
53
+ select.setState("activeId", initialState.activeId);
54
+ }));
55
+ setup(select, () => sync(select, [
56
+ "mounted",
57
+ "items",
58
+ "value"
59
+ ], (state) => {
60
+ if (combobox) return;
61
+ if (state.mounted) return;
62
+ const values = toArray(state.value);
63
+ const lastValue = values[values.length - 1];
64
+ if (lastValue == null) return;
65
+ const item = state.items.find((item) => !item.disabled && item.value === lastValue);
66
+ if (!item) return;
67
+ select.setState("activeId", item.id);
68
+ }));
69
+ setup(select, () => batch(select, ["setValueOnMove", "moves"], (state) => {
70
+ const { mounted, value, activeId } = select.getState();
71
+ if (!state.setValueOnMove && mounted) return;
72
+ if (Array.isArray(value)) return;
73
+ if (!state.moves) return;
74
+ if (!activeId) return;
75
+ const item = composite.item(activeId);
76
+ if (!item || item.disabled || item.value == null) return;
77
+ select.setState("value", item.value);
78
+ }));
79
+ return {
80
+ ...composite,
81
+ ...popover,
82
+ ...select,
83
+ combobox,
84
+ setValue: (value) => select.setState("value", value),
85
+ setLabelElement: (element) => select.setState("labelElement", element),
86
+ setSelectElement: (element) => select.setState("selectElement", element),
87
+ setListElement: (element) => select.setState("listElement", element)
88
+ };
89
+ }
90
+ //#endregion
91
+ export { createSelectStore };
92
+
93
+ //# sourceMappingURL=select-store.js.map