@entry-ui/qwik 0.5.0 → 0.7.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 (129) hide show
  1. package/lib/_internal/components/primitive/primitive.d.ts +2 -1
  2. package/lib/_internal/components/primitive/primitive.qwik.mjs +1 -0
  3. package/lib/_internal/hooks/index.d.ts +2 -0
  4. package/lib/_internal/hooks/use-id/index.d.ts +2 -0
  5. package/lib/_internal/hooks/use-id/use-id.d.ts +21 -0
  6. package/lib/_internal/hooks/use-id/use-id.qwik.mjs +10 -0
  7. package/lib/_internal/hooks/use-id/use-id.types.d.ts +22 -0
  8. package/lib/_internal/hooks/use-id-manager/index.d.ts +2 -0
  9. package/lib/_internal/hooks/use-id-manager/use-id-manager.d.ts +21 -0
  10. package/lib/_internal/hooks/use-id-manager/use-id-manager.qwik.mjs +25 -0
  11. package/lib/_internal/hooks/use-id-manager/use-id-manager.types.d.ts +56 -0
  12. package/lib/_internal/index.d.ts +1 -0
  13. package/lib/_internal/utilities/error/error.qwik.mjs +10 -0
  14. package/lib/_internal/utilities/warn/warn.qwik.mjs +10 -0
  15. package/lib/components/accordion/contexts/accordion-item-context/accordion-item-context.d.ts +11 -0
  16. package/lib/components/accordion/contexts/accordion-item-context/accordion-item-context.qwik.mjs +10 -0
  17. package/lib/components/accordion/contexts/accordion-item-context/accordion-item-context.types.d.ts +64 -0
  18. package/lib/components/accordion/contexts/accordion-item-context/index.d.ts +2 -0
  19. package/lib/components/accordion/contexts/accordion-item-trigger-context/accordion-item-trigger-context.d.ts +6 -0
  20. package/lib/components/accordion/contexts/accordion-item-trigger-context/accordion-item-trigger-context.qwik.mjs +5 -0
  21. package/lib/components/accordion/contexts/accordion-item-trigger-context/accordion-item-trigger-context.types.d.ts +13 -0
  22. package/lib/components/accordion/contexts/accordion-item-trigger-context/index.d.ts +2 -0
  23. package/lib/components/accordion/contexts/accordion-root-context/accordion-root-context.d.ts +11 -0
  24. package/lib/components/accordion/contexts/accordion-root-context/accordion-root-context.qwik.mjs +10 -0
  25. package/lib/components/accordion/contexts/accordion-root-context/accordion-root-context.types.d.ts +34 -0
  26. package/lib/components/accordion/contexts/accordion-root-context/index.d.ts +2 -0
  27. package/lib/components/accordion/contexts/index.d.ts +3 -0
  28. package/lib/components/accordion/hooks/index.d.ts +3 -0
  29. package/lib/components/accordion/hooks/use-accordion-item-context/index.d.ts +2 -0
  30. package/lib/components/accordion/hooks/use-accordion-item-context/use-accordion-item-context.d.ts +7 -0
  31. package/lib/components/accordion/hooks/use-accordion-item-context/use-accordion-item-context.qwik.mjs +14 -0
  32. package/lib/components/accordion/hooks/use-accordion-item-context/use-accordion-item-context.types.d.ts +28 -0
  33. package/lib/components/accordion/hooks/use-accordion-item-trigger-context/index.d.ts +2 -0
  34. package/lib/components/accordion/hooks/use-accordion-item-trigger-context/use-accordion-item-trigger-context.d.ts +7 -0
  35. package/lib/components/accordion/hooks/use-accordion-item-trigger-context/use-accordion-item-trigger-context.qwik.mjs +11 -0
  36. package/lib/components/accordion/hooks/use-accordion-item-trigger-context/use-accordion-item-trigger-context.types.d.ts +13 -0
  37. package/lib/components/accordion/hooks/use-accordion-root-context/index.d.ts +2 -0
  38. package/lib/components/accordion/hooks/use-accordion-root-context/use-accordion-root-context.d.ts +8 -0
  39. package/lib/components/accordion/hooks/use-accordion-root-context/use-accordion-root-context.qwik.mjs +13 -0
  40. package/lib/components/accordion/hooks/use-accordion-root-context/use-accordion-root-context.types.d.ts +22 -0
  41. package/lib/components/accordion/index.d.ts +2 -0
  42. package/lib/components/accordion/index.qwik.mjs +10 -0
  43. package/lib/components/accordion/parts/accordion-item/accordion-item.d.ts +7 -0
  44. package/lib/components/accordion/parts/accordion-item/accordion-item.qwik.mjs +49 -0
  45. package/lib/components/accordion/parts/accordion-item/accordion-item.types.d.ts +29 -0
  46. package/lib/components/accordion/parts/accordion-item/index.d.ts +2 -0
  47. package/lib/components/accordion/parts/accordion-item-header/accordion-item-header.d.ts +11 -0
  48. package/lib/components/accordion/parts/accordion-item-header/accordion-item-header.qwik.mjs +19 -0
  49. package/lib/components/accordion/parts/accordion-item-header/accordion-item-header.types.d.ts +15 -0
  50. package/lib/components/accordion/parts/accordion-item-header/index.d.ts +2 -0
  51. package/lib/components/accordion/parts/accordion-item-indicator/accordion-item-indicator.d.ts +8 -0
  52. package/lib/components/accordion/parts/accordion-item-indicator/accordion-item-indicator.qwik.mjs +27 -0
  53. package/lib/components/accordion/parts/accordion-item-indicator/accordion-item-indicator.types.d.ts +15 -0
  54. package/lib/components/accordion/parts/accordion-item-indicator/index.d.ts +2 -0
  55. package/lib/components/accordion/parts/accordion-item-panel/accordion-item-panel.d.ts +7 -0
  56. package/lib/components/accordion/parts/accordion-item-panel/accordion-item-panel.qwik.mjs +199 -0
  57. package/lib/components/accordion/parts/accordion-item-panel/accordion-item-panel.types.d.ts +31 -0
  58. package/lib/components/accordion/parts/accordion-item-panel/index.d.ts +2 -0
  59. package/lib/components/accordion/parts/accordion-item-trigger/accordion-item-trigger.d.ts +7 -0
  60. package/lib/components/accordion/parts/accordion-item-trigger/accordion-item-trigger.qwik.mjs +52 -0
  61. package/lib/components/accordion/parts/accordion-item-trigger/accordion-item-trigger.types.d.ts +23 -0
  62. package/lib/components/accordion/parts/accordion-item-trigger/index.d.ts +2 -0
  63. package/lib/components/accordion/parts/accordion-root/accordion-root.d.ts +7 -0
  64. package/lib/components/accordion/parts/accordion-root/accordion-root.qwik.mjs +137 -0
  65. package/lib/components/accordion/parts/accordion-root/accordion-root.types.d.ts +68 -0
  66. package/lib/components/accordion/parts/accordion-root/index.d.ts +2 -0
  67. package/lib/components/accordion/parts/index.d.ts +12 -0
  68. package/lib/components/accordion/parts/index.qwik.mjs +14 -0
  69. package/lib/components/collapsible/contexts/collapsible-root-context/collapsible-root-context.d.ts +11 -0
  70. package/lib/components/collapsible/contexts/collapsible-root-context/collapsible-root-context.qwik.mjs +10 -0
  71. package/lib/components/collapsible/contexts/collapsible-root-context/collapsible-root-context.types.d.ts +58 -0
  72. package/lib/components/collapsible/contexts/collapsible-root-context/index.d.ts +2 -0
  73. package/lib/components/collapsible/contexts/collapsible-trigger-context/collapsible-trigger-context.d.ts +6 -0
  74. package/lib/components/collapsible/contexts/collapsible-trigger-context/collapsible-trigger-context.qwik.mjs +5 -0
  75. package/lib/components/collapsible/contexts/collapsible-trigger-context/collapsible-trigger-context.types.d.ts +13 -0
  76. package/lib/components/collapsible/contexts/collapsible-trigger-context/index.d.ts +2 -0
  77. package/lib/components/collapsible/contexts/index.d.ts +2 -0
  78. package/lib/components/collapsible/hooks/index.d.ts +2 -0
  79. package/lib/components/collapsible/hooks/use-collapsible-root-context/index.d.ts +2 -0
  80. package/lib/components/collapsible/hooks/use-collapsible-root-context/use-collapsible-root-context.d.ts +7 -0
  81. package/lib/components/collapsible/hooks/use-collapsible-root-context/use-collapsible-root-context.qwik.mjs +13 -0
  82. package/lib/components/collapsible/hooks/use-collapsible-root-context/use-collapsible-root-context.types.d.ts +22 -0
  83. package/lib/components/collapsible/hooks/use-collapsible-trigger-context/index.d.ts +2 -0
  84. package/lib/components/collapsible/hooks/use-collapsible-trigger-context/use-collapsible-trigger-context.d.ts +7 -0
  85. package/lib/components/collapsible/hooks/use-collapsible-trigger-context/use-collapsible-trigger-context.qwik.mjs +11 -0
  86. package/lib/components/collapsible/hooks/use-collapsible-trigger-context/use-collapsible-trigger-context.types.d.ts +13 -0
  87. package/lib/components/collapsible/index.d.ts +2 -0
  88. package/lib/components/collapsible/index.qwik.mjs +8 -0
  89. package/lib/components/collapsible/parts/collapsible-indicator/collapsible-indicator.d.ts +8 -0
  90. package/lib/components/collapsible/parts/collapsible-indicator/collapsible-indicator.qwik.mjs +27 -0
  91. package/lib/components/collapsible/parts/collapsible-indicator/collapsible-indicator.types.d.ts +15 -0
  92. package/lib/components/collapsible/parts/collapsible-indicator/index.d.ts +2 -0
  93. package/lib/components/collapsible/parts/collapsible-panel/collapsible-panel.d.ts +7 -0
  94. package/lib/components/collapsible/parts/collapsible-panel/collapsible-panel.qwik.mjs +192 -0
  95. package/lib/components/collapsible/parts/collapsible-panel/collapsible-panel.types.d.ts +31 -0
  96. package/lib/components/collapsible/parts/collapsible-panel/index.d.ts +2 -0
  97. package/lib/components/collapsible/parts/collapsible-root/collapsible-root.d.ts +7 -0
  98. package/lib/components/collapsible/parts/collapsible-root/collapsible-root.qwik.mjs +56 -0
  99. package/lib/components/collapsible/parts/collapsible-root/collapsible-root.types.d.ts +41 -0
  100. package/lib/components/collapsible/parts/collapsible-root/index.d.ts +2 -0
  101. package/lib/components/collapsible/parts/collapsible-trigger/collapsible-trigger.d.ts +7 -0
  102. package/lib/components/collapsible/parts/collapsible-trigger/collapsible-trigger.qwik.mjs +52 -0
  103. package/lib/components/collapsible/parts/collapsible-trigger/collapsible-trigger.types.d.ts +23 -0
  104. package/lib/components/collapsible/parts/collapsible-trigger/index.d.ts +2 -0
  105. package/lib/components/collapsible/parts/index.d.ts +8 -0
  106. package/lib/components/collapsible/parts/index.qwik.mjs +10 -0
  107. package/lib/components/index.d.ts +2 -0
  108. package/lib/hooks/index.d.ts +2 -0
  109. package/lib/hooks/use-counter/index.d.ts +2 -0
  110. package/lib/hooks/use-counter/index.qwik.mjs +4 -0
  111. package/lib/hooks/use-counter/use-counter.d.ts +15 -0
  112. package/lib/hooks/use-counter/use-counter.qwik.mjs +113 -0
  113. package/lib/hooks/use-counter/use-counter.types.d.ts +73 -0
  114. package/lib/hooks/use-lifecycle/index.d.ts +2 -0
  115. package/lib/hooks/use-lifecycle/index.qwik.mjs +4 -0
  116. package/lib/hooks/use-lifecycle/use-lifecycle.d.ts +21 -0
  117. package/lib/hooks/use-lifecycle/use-lifecycle.qwik.mjs +59 -0
  118. package/lib/hooks/use-lifecycle/use-lifecycle.types.d.ts +33 -0
  119. package/lib/hooks/use-lifecycle/utilities/create-global-unmount-observer/create-global-unmount-observer.d.ts +13 -0
  120. package/lib/hooks/use-lifecycle/utilities/create-global-unmount-observer/create-global-unmount-observer.qwik.mjs +91 -0
  121. package/lib/hooks/use-lifecycle/utilities/create-global-unmount-observer/create-global-unmount-observer.types.d.ts +26 -0
  122. package/lib/hooks/use-lifecycle/utilities/create-global-unmount-observer/index.d.ts +2 -0
  123. package/lib/hooks/use-lifecycle/utilities/index.d.ts +1 -0
  124. package/lib/index.qwik.mjs +24 -6
  125. package/lib/types/index.d.ts +1 -0
  126. package/lib/types/signal-or-readonly-signal/index.d.ts +1 -0
  127. package/lib/types/signal-or-readonly-signal/signal-or-readonly-signal.types.d.ts +12 -0
  128. package/lib/utilities/merge-refs/merge-refs.d.ts +1 -1
  129. package/package.json +18 -2
@@ -0,0 +1,192 @@
1
+ import { jsx } from "@qwik.dev/core/jsx-runtime";
2
+ import { component$, useSignal, useComputed$, $, useTask$, isBrowser, isDev, sync$, Slot } from "@qwik.dev/core";
3
+ import { getComputedStyle } from "@entry-ui/utilities/get-computed-style";
4
+ import { getHiddenElementHeight } from "@entry-ui/utilities/get-hidden-element-height";
5
+ import { addEventListenerOnce } from "@entry-ui/utilities/add-event-listener-once";
6
+ import { useLifecycle } from "../../../../hooks/use-lifecycle/use-lifecycle.qwik.mjs";
7
+ import { mergeStyles } from "../../../../utilities/merge-styles/merge-styles.qwik.mjs";
8
+ import { mergeRefs } from "../../../../utilities/merge-refs/merge-refs.qwik.mjs";
9
+ import { warn } from "../../../../_internal/utilities/warn/warn.qwik.mjs";
10
+ import { Primitive } from "../../../../_internal/components/primitive/primitive.qwik.mjs";
11
+ import { useCollapsibleRootContext } from "../../contexts/collapsible-root-context/collapsible-root-context.qwik.mjs";
12
+ const CollapsiblePanel = component$((props) => {
13
+ const { as = "div", ref: _ref, id, hiddenUntilFound: _hiddenUntilFound = false, onOpenChangeComplete$, onBeforematch$, style, ...others } = props;
14
+ const { open, setOpen$, disabled, panelId, triggerId } = useCollapsibleRootContext();
15
+ const ref = useSignal(void 0);
16
+ const hidden = useSignal(!open.value);
17
+ const state = useSignal(open.value ? "open" : "closed");
18
+ const height = useSignal(open.value ? "auto" : _hiddenUntilFound ? disabled.value ? "0px" : "none" : "0px");
19
+ const isBeforeMatch = useSignal(false);
20
+ const preventInitialAnimation = useSignal(true);
21
+ const hiddenUntilFound = useComputed$(() => disabled.value ? false : _hiddenUntilFound);
22
+ const mergedStyles = useComputed$(() => mergeStyles([
23
+ {
24
+ display: hidden.value ? hiddenUntilFound.value ? void 0 : "none !important" : void 0,
25
+ transitionDuration: preventInitialAnimation.value ? "0s" : void 0,
26
+ animationDuration: preventInitialAnimation.value ? "0s" : void 0,
27
+ "--entry-ui-qwik-collapsible-panel-height": height.value
28
+ },
29
+ style
30
+ ]));
31
+ useLifecycle({
32
+ element: ref,
33
+ onMount$: $(() => panelId.set$(id)),
34
+ onUnmount$: $(() => panelId.delete$())
35
+ });
36
+ useTask$(({ track }) => {
37
+ const isHiddenUntilFound = track(() => hiddenUntilFound.value);
38
+ const panelRef = ref.value;
39
+ if (isBrowser && panelRef) {
40
+ const panelHeight = open.value ? "auto" : isHiddenUntilFound ? "none" : "0px";
41
+ height.value = panelHeight;
42
+ panelRef.style.setProperty("--entry-ui-qwik-collapsible-panel-height", panelHeight);
43
+ }
44
+ });
45
+ useTask$(({ track, cleanup }) => {
46
+ const isOpen = track(() => open.value);
47
+ const panelRef = ref.value;
48
+ if (isBrowser && panelRef) {
49
+ if (preventInitialAnimation.value && !isBeforeMatch.value) {
50
+ preventInitialAnimation.value = false;
51
+ panelRef.style.removeProperty("transition-duration");
52
+ panelRef.style.removeProperty("animation-duration");
53
+ }
54
+ if (isOpen) {
55
+ hidden.value = false;
56
+ panelRef.removeAttribute("hidden");
57
+ if (hiddenUntilFound.value) {
58
+ isBeforeMatch.value = false;
59
+ } else {
60
+ panelRef.style.removeProperty("display");
61
+ }
62
+ state.value = "open";
63
+ panelRef.setAttribute("data-state", "open");
64
+ const { animationDuration: animationDuration2, transitionDuration: transitionDuration2 } = getComputedStyle(panelRef);
65
+ const panelHeight = getHiddenElementHeight(panelRef);
66
+ if (animationDuration2 === "0s" && transitionDuration2 !== "0s") {
67
+ if (height.value === "none") {
68
+ height.value = "0px";
69
+ panelRef.style.setProperty("--entry-ui-qwik-collapsible-panel-height", "0px");
70
+ setTimeout(() => {
71
+ height.value = `${panelHeight}px`;
72
+ panelRef.style.setProperty("--entry-ui-qwik-collapsible-panel-height", `${panelHeight}px`);
73
+ }, 0);
74
+ } else {
75
+ height.value = `${panelHeight}px`;
76
+ panelRef.style.setProperty("--entry-ui-qwik-collapsible-panel-height", `${panelHeight}px`);
77
+ }
78
+ } else {
79
+ height.value = `${panelHeight}px`;
80
+ panelRef.style.setProperty("--entry-ui-qwik-collapsible-panel-height", `${panelHeight}px`);
81
+ }
82
+ } else {
83
+ state.value = "closed";
84
+ panelRef.setAttribute("data-state", "closed");
85
+ const { animationDuration: animationDuration2, transitionDuration: transitionDuration2 } = getComputedStyle(panelRef);
86
+ const panelHeight = getHiddenElementHeight(panelRef);
87
+ if (animationDuration2 === "0s" && transitionDuration2 !== "0s") {
88
+ if (height.value === "auto") {
89
+ height.value = `${panelHeight}px`;
90
+ panelRef.style.setProperty("--entry-ui-qwik-collapsible-panel-height", `${panelHeight}px`);
91
+ setTimeout(() => {
92
+ height.value = "0px";
93
+ panelRef.style.setProperty("--entry-ui-qwik-collapsible-panel-height", "0px");
94
+ }, 0);
95
+ } else {
96
+ height.value = "0px";
97
+ panelRef.style.setProperty("--entry-ui-qwik-collapsible-panel-height", "0px");
98
+ }
99
+ } else {
100
+ height.value = `${panelHeight}px`;
101
+ panelRef.style.setProperty("--entry-ui-qwik-collapsible-panel-height", `${panelHeight}px`);
102
+ }
103
+ }
104
+ const applyFinalState = () => {
105
+ if (isOpen) {
106
+ height.value = "auto";
107
+ panelRef.style.setProperty("--entry-ui-qwik-collapsible-panel-height", "auto");
108
+ } else {
109
+ hidden.value = true;
110
+ if (hiddenUntilFound.value) {
111
+ height.value = "none";
112
+ panelRef.style.setProperty("--entry-ui-qwik-collapsible-panel-height", "none");
113
+ } else {
114
+ height.value = "0px";
115
+ panelRef.style.setProperty("--entry-ui-qwik-collapsible-panel-height", "0px");
116
+ }
117
+ }
118
+ if (onOpenChangeComplete$) {
119
+ onOpenChangeComplete$(isOpen);
120
+ }
121
+ };
122
+ const { transitionDuration, animationDuration } = getComputedStyle(panelRef);
123
+ if (isDev && transitionDuration !== "0s" && animationDuration !== "0s") {
124
+ warn([
125
+ `Both CSS transitions and CSS animations are detected on 'Collapsible.Panel' component.`,
126
+ `Using both at the same time may cause unpredictable behavior.`,
127
+ `Please use only one animation method.`
128
+ ]);
129
+ applyFinalState();
130
+ } else if (transitionDuration !== "0s") {
131
+ const removeTransitionEndListener = addEventListenerOnce({
132
+ target: panelRef,
133
+ type: "transitionend",
134
+ listener: applyFinalState
135
+ });
136
+ cleanup(() => {
137
+ removeTransitionEndListener();
138
+ });
139
+ } else if (animationDuration !== "0s") {
140
+ const removeAnimationEndListener = addEventListenerOnce({
141
+ target: panelRef,
142
+ type: "animationend",
143
+ listener: applyFinalState
144
+ });
145
+ cleanup(() => {
146
+ removeAnimationEndListener();
147
+ });
148
+ } else {
149
+ applyFinalState();
150
+ }
151
+ }
152
+ });
153
+ const handleBeforeMatchSync$ = sync$((event) => {
154
+ const entryUIQwikEvent = event;
155
+ if (!entryUIQwikEvent.entryUIQwikHandlerPrevented) {
156
+ event.preventDefault();
157
+ }
158
+ });
159
+ const handleBeforeMatch$ = $((event) => {
160
+ const entryUIQwikEvent = event;
161
+ if (!entryUIQwikEvent.entryUIQwikHandlerPrevented) {
162
+ isBeforeMatch.value = true;
163
+ preventInitialAnimation.value = true;
164
+ setOpen$(true);
165
+ }
166
+ });
167
+ return /* @__PURE__ */ jsx(Primitive.div, {
168
+ as,
169
+ ref: mergeRefs([
170
+ _ref,
171
+ ref
172
+ ]),
173
+ id: panelId.id.value,
174
+ role: triggerId.id.value ? "group" : void 0,
175
+ hidden: hidden.value ? hiddenUntilFound.value ? "until-found" : "hidden" : void 0,
176
+ "aria-labelledby": triggerId.id.value,
177
+ "data-entry-ui-qwik-collapsible-panel": "",
178
+ "data-state": state.value,
179
+ "data-disabled": disabled.value ? "" : void 0,
180
+ onBeforematch$: [
181
+ onBeforematch$,
182
+ handleBeforeMatchSync$,
183
+ handleBeforeMatch$
184
+ ],
185
+ style: mergedStyles.value,
186
+ ...others,
187
+ children: /* @__PURE__ */ jsx(Slot, {})
188
+ });
189
+ });
190
+ export {
191
+ CollapsiblePanel
192
+ };
@@ -0,0 +1,31 @@
1
+ import { PropsOf, Component, QRL } from '@qwik.dev/core';
2
+ /**
3
+ * Props for the `Collapsible.Panel` component.
4
+ * Extends the standard HTML attributes for a `<div>` element.
5
+ */
6
+ export interface CollapsiblePanelProps extends PropsOf<'div'> {
7
+ /**
8
+ * The element or component this component should render as.
9
+ *
10
+ * @see {@link https://github.com/ZAHON/entry-ui/tree/main/packages/qwik/docs/guides/composition.md Composition} guide for more details.
11
+ *
12
+ * @default "div"
13
+ */
14
+ as?: string | Component;
15
+ /**
16
+ * When `true`, the panel uses the `hidden="until-found"` attribute when closed.
17
+ * This allows the browser to search and reveal content within the panel
18
+ * even before it is manually opened.
19
+ *
20
+ * @default false
21
+ */
22
+ hiddenUntilFound?: boolean;
23
+ /**
24
+ * A `QRL` callback invoked once the panel's expansion or collapse has fully settled.
25
+ * If CSS transitions or animations are present, it triggers after they finish;
26
+ * otherwise, it executes immediately upon the state change.
27
+ *
28
+ * @default undefined
29
+ */
30
+ onOpenChangeComplete$?: QRL<(open: boolean) => void>;
31
+ }
@@ -0,0 +1,2 @@
1
+ export type { CollapsiblePanelProps } from './collapsible-panel.types';
2
+ export { CollapsiblePanel } from './collapsible-panel';
@@ -0,0 +1,7 @@
1
+ import type { CollapsibleRootProps } from './collapsible-root.types';
2
+ /**
3
+ * Groups all parts of the collapsible.
4
+ *
5
+ * Renders a `<div>` element.
6
+ */
7
+ export declare const CollapsibleRoot: import("@qwik.dev/core").Component<CollapsibleRootProps>;
@@ -0,0 +1,56 @@
1
+ import { jsx } from "@qwik.dev/core/jsx-runtime";
2
+ import { component$, useComputed$, useContextProvider, Slot } from "@qwik.dev/core";
3
+ import { useControllable } from "../../../../hooks/use-controllable/use-controllable.qwik.mjs";
4
+ import { useIdManager } from "../../../../_internal/hooks/use-id-manager/use-id-manager.qwik.mjs";
5
+ import { mergeStyles } from "../../../../utilities/merge-styles/merge-styles.qwik.mjs";
6
+ import { Primitive } from "../../../../_internal/components/primitive/primitive.qwik.mjs";
7
+ import { CollapsibleRootContext } from "../../contexts/collapsible-root-context/collapsible-root-context.qwik.mjs";
8
+ const CollapsibleRoot = component$((props) => {
9
+ const { as = "div", defaultOpen, open: _open, onOpenChange$, disabled: _disabled = false, style, ...others } = props;
10
+ const { state: open, setState$: setOpen$ } = useControllable({
11
+ defaultValue: defaultOpen ?? false,
12
+ controlledSignal: _open,
13
+ onChange$: onOpenChange$
14
+ });
15
+ const disabled = useComputed$(() => _disabled);
16
+ const triggerId = useIdManager({
17
+ prefix: "entry-ui-qwik-collapsible-trigger-"
18
+ });
19
+ const panelId = useIdManager({
20
+ prefix: "entry-ui-qwik-collapsible-panel-"
21
+ });
22
+ useContextProvider(CollapsibleRootContext, {
23
+ open,
24
+ setOpen$,
25
+ disabled,
26
+ triggerId,
27
+ panelId
28
+ });
29
+ return /* @__PURE__ */ jsx(Primitive.div, {
30
+ as,
31
+ "data-entry-ui-qwik-collapsible-root": "",
32
+ "data-state": open.value ? "open" : "closed",
33
+ "data-disabled": disabled.value ? "" : void 0,
34
+ style: mergeStyles([
35
+ {
36
+ // Performance optimization
37
+ // The `contain: layout style;` CSS property is used here to improve rendering performance.
38
+ // `contain: layout;` tells the browser that the internal layout of this component
39
+ // is self-contained and does not affect the layout of elements outside of it. This prevents
40
+ // costly re-calculations of the entire page layout when the collapsible panel expands or collapses,
41
+ // which is especially beneficial during animations.
42
+ // `contain: style;` ensures that CSS properties that can affect the rest of the page,
43
+ // like counters, are isolated to this element.
44
+ // Together, these properties create a performance "bubble," allowing the browser to optimize
45
+ // rendering by treating the collapsible component as an independent unit.
46
+ contain: "layout style"
47
+ },
48
+ style
49
+ ]),
50
+ ...others,
51
+ children: /* @__PURE__ */ jsx(Slot, {})
52
+ });
53
+ });
54
+ export {
55
+ CollapsibleRoot
56
+ };
@@ -0,0 +1,41 @@
1
+ import { PropsOf, Component, Signal, QRL } from '@qwik.dev/core';
2
+ /**
3
+ * Props for the `Collapsible.Root` component.
4
+ * Extends the standard HTML attributes for a `<div>` element.
5
+ */
6
+ export interface CollapsibleRootProps extends PropsOf<'div'> {
7
+ /**
8
+ * The element or component this component should render as.
9
+ *
10
+ * @see {@link https://github.com/ZAHON/entry-ui/tree/main/packages/qwik/docs/guides/composition.md Composition} guide for more details.
11
+ *
12
+ * @default "div"
13
+ */
14
+ as?: string | Component;
15
+ /**
16
+ * The open state of the collapsible when it is initially rendered.
17
+ * Use when you do not need to control its open state.
18
+ *
19
+ * @default undefined
20
+ */
21
+ defaultOpen?: boolean;
22
+ /**
23
+ * The controlled open state of the collapsible.
24
+ * Must be used in conjunction with `onOpenChange$`.
25
+ *
26
+ * @default undefined
27
+ */
28
+ open?: Signal<boolean>;
29
+ /**
30
+ * A `QRL` callback function that is called when the open state of the collapsible changes.
31
+ *
32
+ * @default undefined
33
+ */
34
+ onOpenChange$?: QRL<(open: boolean) => void>;
35
+ /**
36
+ * When `true`, prevents the user from interacting with the collapsible.
37
+ *
38
+ * @default false
39
+ */
40
+ disabled?: boolean;
41
+ }
@@ -0,0 +1,2 @@
1
+ export type { CollapsibleRootProps } from './collapsible-root.types';
2
+ export { CollapsibleRoot } from './collapsible-root';
@@ -0,0 +1,7 @@
1
+ import type { CollapsibleTriggerProps } from './collapsible-trigger.types';
2
+ /**
3
+ * A button that opens and closes the collapsible panel.
4
+ *
5
+ * Renders a `<button>` element.
6
+ */
7
+ export declare const CollapsibleTrigger: import("@qwik.dev/core").Component<CollapsibleTriggerProps>;
@@ -0,0 +1,52 @@
1
+ import { jsx } from "@qwik.dev/core/jsx-runtime";
2
+ import { component$, useSignal, useComputed$, $, useContextProvider, Slot } from "@qwik.dev/core";
3
+ import { useLifecycle } from "../../../../hooks/use-lifecycle/use-lifecycle.qwik.mjs";
4
+ import { mergeRefs } from "../../../../utilities/merge-refs/merge-refs.qwik.mjs";
5
+ import { Primitive } from "../../../../_internal/components/primitive/primitive.qwik.mjs";
6
+ import { useCollapsibleRootContext } from "../../contexts/collapsible-root-context/collapsible-root-context.qwik.mjs";
7
+ import { CollapsibleTriggerContext } from "../../contexts/collapsible-trigger-context/collapsible-trigger-context.qwik.mjs";
8
+ const CollapsibleTrigger = component$((props) => {
9
+ const { as = "button", ref: _ref, id, disabled: _disabled, onClick$, ...others } = props;
10
+ const { open, setOpen$, disabled: rootDisabled, triggerId, panelId } = useCollapsibleRootContext();
11
+ const ref = useSignal(void 0);
12
+ const disabled = useComputed$(() => _disabled ?? rootDisabled.value);
13
+ useLifecycle({
14
+ element: ref,
15
+ onMount$: $(() => triggerId.set$(id)),
16
+ onUnmount$: $(() => triggerId.delete$())
17
+ });
18
+ const handleClick$ = $((event) => {
19
+ const entryUIQwikEvent = event;
20
+ if (!entryUIQwikEvent.entryUIQwikHandlerPrevented && !disabled.value) {
21
+ setOpen$(!open.value);
22
+ }
23
+ });
24
+ useContextProvider(CollapsibleTriggerContext, {
25
+ disabled
26
+ });
27
+ return /* @__PURE__ */ jsx(Primitive.button, {
28
+ as,
29
+ ref: mergeRefs([
30
+ _ref,
31
+ ref
32
+ ]),
33
+ type: "button",
34
+ id: triggerId.id.value,
35
+ disabled: disabled.value,
36
+ "aria-controls": panelId.id.value && open.value ? panelId.id.value : void 0,
37
+ "aria-expanded": panelId.id.value ? open.value : void 0,
38
+ "data-entry-ui-qwik-collapsible-trigger": "",
39
+ "data-state": open.value ? "open" : "closed",
40
+ // Present when the entire collapsible component is in a disabled state.
41
+ "data-disabled": rootDisabled.value ? "" : void 0,
42
+ onClick$: [
43
+ onClick$,
44
+ handleClick$
45
+ ],
46
+ ...others,
47
+ children: /* @__PURE__ */ jsx(Slot, {})
48
+ });
49
+ });
50
+ export {
51
+ CollapsibleTrigger
52
+ };
@@ -0,0 +1,23 @@
1
+ import { PropsOf, Component } from '@qwik.dev/core';
2
+ /**
3
+ * Props for the `Collapsible.Trigger` component.
4
+ * Extends the standard HTML attributes for a `<button>` element.
5
+ */
6
+ export interface CollapsibleTriggerProps extends PropsOf<'button'> {
7
+ /**
8
+ * The element or component this component should render as.
9
+ *
10
+ * @see {@link https://github.com/ZAHON/entry-ui/tree/main/packages/qwik/docs/guides/composition.md Composition} guide for more details.
11
+ *
12
+ * @default "button"
13
+ */
14
+ as?: string | Component;
15
+ /**
16
+ * When `true`, prevents the user from interacting with the trigger.
17
+ * If left `undefined`, this state will be inherited from the `disabled`
18
+ * prop of the `Collapsible.Root` component.
19
+ *
20
+ * @default undefined
21
+ */
22
+ disabled?: boolean;
23
+ }
@@ -0,0 +1,2 @@
1
+ export type { CollapsibleTriggerProps } from './collapsible-trigger.types';
2
+ export { CollapsibleTrigger } from './collapsible-trigger';
@@ -0,0 +1,8 @@
1
+ export type { CollapsibleRootProps as RootProps } from './collapsible-root';
2
+ export type { CollapsibleTriggerProps as TriggerProps } from './collapsible-trigger';
3
+ export type { CollapsiblePanelProps as PanelProps } from './collapsible-panel';
4
+ export type { CollapsibleIndicatorProps as IndicatorProps } from './collapsible-indicator';
5
+ export { CollapsibleRoot as Root } from './collapsible-root';
6
+ export { CollapsibleTrigger as Trigger } from './collapsible-trigger';
7
+ export { CollapsiblePanel as Panel } from './collapsible-panel';
8
+ export { CollapsibleIndicator as Indicator } from './collapsible-indicator';
@@ -0,0 +1,10 @@
1
+ import { CollapsibleRoot } from "./collapsible-root/collapsible-root.qwik.mjs";
2
+ import { CollapsibleTrigger } from "./collapsible-trigger/collapsible-trigger.qwik.mjs";
3
+ import { CollapsiblePanel } from "./collapsible-panel/collapsible-panel.qwik.mjs";
4
+ import { CollapsibleIndicator } from "./collapsible-indicator/collapsible-indicator.qwik.mjs";
5
+ export {
6
+ CollapsibleIndicator as Indicator,
7
+ CollapsiblePanel as Panel,
8
+ CollapsibleRoot as Root,
9
+ CollapsibleTrigger as Trigger
10
+ };
@@ -1,3 +1,5 @@
1
+ export * from './accordion';
1
2
  export * from './alert';
3
+ export * from './collapsible';
2
4
  export * from './separator';
3
5
  export * from './toggle';
@@ -1,3 +1,5 @@
1
1
  export * from './use-boolean';
2
2
  export * from './use-controllable';
3
+ export * from './use-counter';
3
4
  export * from './use-cycle';
5
+ export * from './use-lifecycle';
@@ -0,0 +1,2 @@
1
+ export type { UseCounterParams, UseCounterReturnValue } from './use-counter.types';
2
+ export { useCounter } from './use-counter';
@@ -0,0 +1,4 @@
1
+ import { useCounter } from "./use-counter.qwik.mjs";
2
+ export {
3
+ useCounter
4
+ };
@@ -0,0 +1,15 @@
1
+ import type { UseCounterParams, UseCounterReturnValue } from './use-counter.types';
2
+ /**
3
+ * A hook that manages a numeric state with built-in clamping and validation logic.
4
+ *
5
+ * This hook provides a secure way to handle counter states by ensuring the value
6
+ * always remains within defined boundaries. It encapsulates a numeric signal and
7
+ * exposes it as a readonly signal, enforcing predictable state transitions through
8
+ * dedicated `QRL` functions.
9
+ *
10
+ * It features strict validation during development to ensure all parameters
11
+ * and operations result in finite numbers, preventing common pitfalls such as
12
+ * `NaN` or `Infinity` from polluting the state. It is ideal for quantity selectors,
13
+ * pagination, volume controls, or any UI element requiring bounded numeric input.
14
+ */
15
+ export declare const useCounter: (params?: UseCounterParams) => UseCounterReturnValue;
@@ -0,0 +1,113 @@
1
+ import { useSignal, $ } from "@qwik.dev/core";
2
+ import { isDev } from "@qwik.dev/core/build";
3
+ import { isValidNumber } from "@entry-ui/utilities/is-valid-number";
4
+ import { clamp } from "@entry-ui/utilities/clamp";
5
+ import { fail } from "../../_internal/utilities/fail/fail.qwik.mjs";
6
+ import { warn } from "../../_internal/utilities/warn/warn.qwik.mjs";
7
+ const useCounter = (params = {}) => {
8
+ const { initialCount = 0, step = 1, min = -Number.MAX_VALUE, max = Number.MAX_VALUE } = params;
9
+ if (isDev) {
10
+ if (!isValidNumber(initialCount)) {
11
+ fail([
12
+ `Invalid 'initialCount' parameter in 'useCounter' hook.`,
13
+ `Expected a finite number, but received: ${initialCount}`
14
+ ]);
15
+ }
16
+ if (!isValidNumber(step)) {
17
+ fail([
18
+ `Invalid 'step' parameter in 'useCounter' hook.`,
19
+ `Expected a finite number, but received: ${step}`
20
+ ]);
21
+ }
22
+ if (!isValidNumber(min)) {
23
+ fail([
24
+ `Invalid 'min' parameter in 'useCounter' hook.`,
25
+ `Expected a finite number, but received: ${min}`
26
+ ]);
27
+ }
28
+ if (!isValidNumber(max)) {
29
+ fail([
30
+ `Invalid 'max' parameter in 'useCounter' hook.`,
31
+ `Expected a finite number, but received: ${max}`
32
+ ]);
33
+ }
34
+ if (min > max) {
35
+ fail([
36
+ `Invalid range for 'useCounter' hook.`,
37
+ `The 'min' parameter (${min}) must be less than or equal to the 'max' parameter (${max}).`
38
+ ]);
39
+ }
40
+ }
41
+ const count = useSignal(clamp({
42
+ value: initialCount,
43
+ min,
44
+ max
45
+ }));
46
+ const increment$ = $(() => {
47
+ const nextCount = count.value + step;
48
+ if (!isValidNumber(nextCount)) {
49
+ if (isDev) {
50
+ warn([
51
+ `The 'increment$' QRL function from the 'useCounter' hook resulted in an invalid, non-finite number: ${nextCount}.`,
52
+ `The 'count' was not updated to prevent application instability.`
53
+ ]);
54
+ }
55
+ return;
56
+ }
57
+ count.value = clamp({
58
+ value: nextCount,
59
+ min,
60
+ max
61
+ });
62
+ });
63
+ const decrement$ = $(() => {
64
+ const nextCount = count.value - step;
65
+ if (!isValidNumber(nextCount)) {
66
+ if (isDev) {
67
+ warn([
68
+ `The 'decrement$' QRL function from the 'useCounter' hook resulted in an invalid, non-finite number: ${nextCount}.`,
69
+ `The 'count' was not updated to prevent application instability.`
70
+ ]);
71
+ }
72
+ return;
73
+ }
74
+ count.value = clamp({
75
+ value: nextCount,
76
+ min,
77
+ max
78
+ });
79
+ });
80
+ const set$ = $((value) => {
81
+ if (!isValidNumber(value)) {
82
+ if (isDev) {
83
+ warn([
84
+ `The 'set$' QRL function from the 'useCounter' hook was called with an invalid, non-finite number: ${value}.`,
85
+ `The 'count' was not updated to prevent application instability.`
86
+ ]);
87
+ }
88
+ return;
89
+ }
90
+ count.value = clamp({
91
+ value,
92
+ min,
93
+ max
94
+ });
95
+ });
96
+ const reset$ = $(() => {
97
+ count.value = clamp({
98
+ value: initialCount,
99
+ min,
100
+ max
101
+ });
102
+ });
103
+ return {
104
+ count,
105
+ increment$,
106
+ decrement$,
107
+ reset$,
108
+ set$
109
+ };
110
+ };
111
+ export {
112
+ useCounter
113
+ };