@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.
- package/lib/_internal/components/primitive/primitive.d.ts +2 -1
- package/lib/_internal/components/primitive/primitive.qwik.mjs +1 -0
- package/lib/_internal/hooks/index.d.ts +2 -0
- package/lib/_internal/hooks/use-id/index.d.ts +2 -0
- package/lib/_internal/hooks/use-id/use-id.d.ts +21 -0
- package/lib/_internal/hooks/use-id/use-id.qwik.mjs +10 -0
- package/lib/_internal/hooks/use-id/use-id.types.d.ts +22 -0
- package/lib/_internal/hooks/use-id-manager/index.d.ts +2 -0
- package/lib/_internal/hooks/use-id-manager/use-id-manager.d.ts +21 -0
- package/lib/_internal/hooks/use-id-manager/use-id-manager.qwik.mjs +25 -0
- package/lib/_internal/hooks/use-id-manager/use-id-manager.types.d.ts +56 -0
- package/lib/_internal/index.d.ts +1 -0
- package/lib/_internal/utilities/error/error.qwik.mjs +10 -0
- package/lib/_internal/utilities/warn/warn.qwik.mjs +10 -0
- package/lib/components/accordion/contexts/accordion-item-context/accordion-item-context.d.ts +11 -0
- package/lib/components/accordion/contexts/accordion-item-context/accordion-item-context.qwik.mjs +10 -0
- package/lib/components/accordion/contexts/accordion-item-context/accordion-item-context.types.d.ts +64 -0
- package/lib/components/accordion/contexts/accordion-item-context/index.d.ts +2 -0
- package/lib/components/accordion/contexts/accordion-item-trigger-context/accordion-item-trigger-context.d.ts +6 -0
- package/lib/components/accordion/contexts/accordion-item-trigger-context/accordion-item-trigger-context.qwik.mjs +5 -0
- package/lib/components/accordion/contexts/accordion-item-trigger-context/accordion-item-trigger-context.types.d.ts +13 -0
- package/lib/components/accordion/contexts/accordion-item-trigger-context/index.d.ts +2 -0
- package/lib/components/accordion/contexts/accordion-root-context/accordion-root-context.d.ts +11 -0
- package/lib/components/accordion/contexts/accordion-root-context/accordion-root-context.qwik.mjs +10 -0
- package/lib/components/accordion/contexts/accordion-root-context/accordion-root-context.types.d.ts +34 -0
- package/lib/components/accordion/contexts/accordion-root-context/index.d.ts +2 -0
- package/lib/components/accordion/contexts/index.d.ts +3 -0
- package/lib/components/accordion/hooks/index.d.ts +3 -0
- package/lib/components/accordion/hooks/use-accordion-item-context/index.d.ts +2 -0
- package/lib/components/accordion/hooks/use-accordion-item-context/use-accordion-item-context.d.ts +7 -0
- package/lib/components/accordion/hooks/use-accordion-item-context/use-accordion-item-context.qwik.mjs +14 -0
- package/lib/components/accordion/hooks/use-accordion-item-context/use-accordion-item-context.types.d.ts +28 -0
- package/lib/components/accordion/hooks/use-accordion-item-trigger-context/index.d.ts +2 -0
- package/lib/components/accordion/hooks/use-accordion-item-trigger-context/use-accordion-item-trigger-context.d.ts +7 -0
- package/lib/components/accordion/hooks/use-accordion-item-trigger-context/use-accordion-item-trigger-context.qwik.mjs +11 -0
- package/lib/components/accordion/hooks/use-accordion-item-trigger-context/use-accordion-item-trigger-context.types.d.ts +13 -0
- package/lib/components/accordion/hooks/use-accordion-root-context/index.d.ts +2 -0
- package/lib/components/accordion/hooks/use-accordion-root-context/use-accordion-root-context.d.ts +8 -0
- package/lib/components/accordion/hooks/use-accordion-root-context/use-accordion-root-context.qwik.mjs +13 -0
- package/lib/components/accordion/hooks/use-accordion-root-context/use-accordion-root-context.types.d.ts +22 -0
- package/lib/components/accordion/index.d.ts +2 -0
- package/lib/components/accordion/index.qwik.mjs +10 -0
- package/lib/components/accordion/parts/accordion-item/accordion-item.d.ts +7 -0
- package/lib/components/accordion/parts/accordion-item/accordion-item.qwik.mjs +49 -0
- package/lib/components/accordion/parts/accordion-item/accordion-item.types.d.ts +29 -0
- package/lib/components/accordion/parts/accordion-item/index.d.ts +2 -0
- package/lib/components/accordion/parts/accordion-item-header/accordion-item-header.d.ts +11 -0
- package/lib/components/accordion/parts/accordion-item-header/accordion-item-header.qwik.mjs +19 -0
- package/lib/components/accordion/parts/accordion-item-header/accordion-item-header.types.d.ts +15 -0
- package/lib/components/accordion/parts/accordion-item-header/index.d.ts +2 -0
- package/lib/components/accordion/parts/accordion-item-indicator/accordion-item-indicator.d.ts +8 -0
- package/lib/components/accordion/parts/accordion-item-indicator/accordion-item-indicator.qwik.mjs +27 -0
- package/lib/components/accordion/parts/accordion-item-indicator/accordion-item-indicator.types.d.ts +15 -0
- package/lib/components/accordion/parts/accordion-item-indicator/index.d.ts +2 -0
- package/lib/components/accordion/parts/accordion-item-panel/accordion-item-panel.d.ts +7 -0
- package/lib/components/accordion/parts/accordion-item-panel/accordion-item-panel.qwik.mjs +199 -0
- package/lib/components/accordion/parts/accordion-item-panel/accordion-item-panel.types.d.ts +31 -0
- package/lib/components/accordion/parts/accordion-item-panel/index.d.ts +2 -0
- package/lib/components/accordion/parts/accordion-item-trigger/accordion-item-trigger.d.ts +7 -0
- package/lib/components/accordion/parts/accordion-item-trigger/accordion-item-trigger.qwik.mjs +52 -0
- package/lib/components/accordion/parts/accordion-item-trigger/accordion-item-trigger.types.d.ts +23 -0
- package/lib/components/accordion/parts/accordion-item-trigger/index.d.ts +2 -0
- package/lib/components/accordion/parts/accordion-root/accordion-root.d.ts +7 -0
- package/lib/components/accordion/parts/accordion-root/accordion-root.qwik.mjs +137 -0
- package/lib/components/accordion/parts/accordion-root/accordion-root.types.d.ts +68 -0
- package/lib/components/accordion/parts/accordion-root/index.d.ts +2 -0
- package/lib/components/accordion/parts/index.d.ts +12 -0
- package/lib/components/accordion/parts/index.qwik.mjs +14 -0
- package/lib/components/collapsible/contexts/collapsible-root-context/collapsible-root-context.d.ts +11 -0
- package/lib/components/collapsible/contexts/collapsible-root-context/collapsible-root-context.qwik.mjs +10 -0
- package/lib/components/collapsible/contexts/collapsible-root-context/collapsible-root-context.types.d.ts +58 -0
- package/lib/components/collapsible/contexts/collapsible-root-context/index.d.ts +2 -0
- package/lib/components/collapsible/contexts/collapsible-trigger-context/collapsible-trigger-context.d.ts +6 -0
- package/lib/components/collapsible/contexts/collapsible-trigger-context/collapsible-trigger-context.qwik.mjs +5 -0
- package/lib/components/collapsible/contexts/collapsible-trigger-context/collapsible-trigger-context.types.d.ts +13 -0
- package/lib/components/collapsible/contexts/collapsible-trigger-context/index.d.ts +2 -0
- package/lib/components/collapsible/contexts/index.d.ts +2 -0
- package/lib/components/collapsible/hooks/index.d.ts +2 -0
- package/lib/components/collapsible/hooks/use-collapsible-root-context/index.d.ts +2 -0
- package/lib/components/collapsible/hooks/use-collapsible-root-context/use-collapsible-root-context.d.ts +7 -0
- package/lib/components/collapsible/hooks/use-collapsible-root-context/use-collapsible-root-context.qwik.mjs +13 -0
- package/lib/components/collapsible/hooks/use-collapsible-root-context/use-collapsible-root-context.types.d.ts +22 -0
- package/lib/components/collapsible/hooks/use-collapsible-trigger-context/index.d.ts +2 -0
- package/lib/components/collapsible/hooks/use-collapsible-trigger-context/use-collapsible-trigger-context.d.ts +7 -0
- package/lib/components/collapsible/hooks/use-collapsible-trigger-context/use-collapsible-trigger-context.qwik.mjs +11 -0
- package/lib/components/collapsible/hooks/use-collapsible-trigger-context/use-collapsible-trigger-context.types.d.ts +13 -0
- package/lib/components/collapsible/index.d.ts +2 -0
- package/lib/components/collapsible/index.qwik.mjs +8 -0
- package/lib/components/collapsible/parts/collapsible-indicator/collapsible-indicator.d.ts +8 -0
- package/lib/components/collapsible/parts/collapsible-indicator/collapsible-indicator.qwik.mjs +27 -0
- package/lib/components/collapsible/parts/collapsible-indicator/collapsible-indicator.types.d.ts +15 -0
- package/lib/components/collapsible/parts/collapsible-indicator/index.d.ts +2 -0
- package/lib/components/collapsible/parts/collapsible-panel/collapsible-panel.d.ts +7 -0
- package/lib/components/collapsible/parts/collapsible-panel/collapsible-panel.qwik.mjs +192 -0
- package/lib/components/collapsible/parts/collapsible-panel/collapsible-panel.types.d.ts +31 -0
- package/lib/components/collapsible/parts/collapsible-panel/index.d.ts +2 -0
- package/lib/components/collapsible/parts/collapsible-root/collapsible-root.d.ts +7 -0
- package/lib/components/collapsible/parts/collapsible-root/collapsible-root.qwik.mjs +56 -0
- package/lib/components/collapsible/parts/collapsible-root/collapsible-root.types.d.ts +41 -0
- package/lib/components/collapsible/parts/collapsible-root/index.d.ts +2 -0
- package/lib/components/collapsible/parts/collapsible-trigger/collapsible-trigger.d.ts +7 -0
- package/lib/components/collapsible/parts/collapsible-trigger/collapsible-trigger.qwik.mjs +52 -0
- package/lib/components/collapsible/parts/collapsible-trigger/collapsible-trigger.types.d.ts +23 -0
- package/lib/components/collapsible/parts/collapsible-trigger/index.d.ts +2 -0
- package/lib/components/collapsible/parts/index.d.ts +8 -0
- package/lib/components/collapsible/parts/index.qwik.mjs +10 -0
- package/lib/components/index.d.ts +2 -0
- package/lib/hooks/index.d.ts +2 -0
- package/lib/hooks/use-counter/index.d.ts +2 -0
- package/lib/hooks/use-counter/index.qwik.mjs +4 -0
- package/lib/hooks/use-counter/use-counter.d.ts +15 -0
- package/lib/hooks/use-counter/use-counter.qwik.mjs +113 -0
- package/lib/hooks/use-counter/use-counter.types.d.ts +73 -0
- package/lib/hooks/use-lifecycle/index.d.ts +2 -0
- package/lib/hooks/use-lifecycle/index.qwik.mjs +4 -0
- package/lib/hooks/use-lifecycle/use-lifecycle.d.ts +21 -0
- package/lib/hooks/use-lifecycle/use-lifecycle.qwik.mjs +59 -0
- package/lib/hooks/use-lifecycle/use-lifecycle.types.d.ts +33 -0
- package/lib/hooks/use-lifecycle/utilities/create-global-unmount-observer/create-global-unmount-observer.d.ts +13 -0
- package/lib/hooks/use-lifecycle/utilities/create-global-unmount-observer/create-global-unmount-observer.qwik.mjs +91 -0
- package/lib/hooks/use-lifecycle/utilities/create-global-unmount-observer/create-global-unmount-observer.types.d.ts +26 -0
- package/lib/hooks/use-lifecycle/utilities/create-global-unmount-observer/index.d.ts +2 -0
- package/lib/hooks/use-lifecycle/utilities/index.d.ts +1 -0
- package/lib/index.qwik.mjs +24 -6
- package/lib/types/index.d.ts +1 -0
- package/lib/types/signal-or-readonly-signal/index.d.ts +1 -0
- package/lib/types/signal-or-readonly-signal/signal-or-readonly-signal.types.d.ts +12 -0
- package/lib/utilities/merge-refs/merge-refs.d.ts +1 -1
- package/package.json +18 -2
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { jsx } from "@qwik.dev/core/jsx-runtime";
|
|
2
|
+
import { component$, useComputed$, $, sync$, useContextProvider, Slot } from "@qwik.dev/core";
|
|
3
|
+
import { isDev } from "@qwik.dev/core/build";
|
|
4
|
+
import { useControllable } from "../../../../hooks/use-controllable/use-controllable.qwik.mjs";
|
|
5
|
+
import { mergeStyles } from "../../../../utilities/merge-styles/merge-styles.qwik.mjs";
|
|
6
|
+
import { warn } from "../../../../_internal/utilities/warn/warn.qwik.mjs";
|
|
7
|
+
import { Primitive } from "../../../../_internal/components/primitive/primitive.qwik.mjs";
|
|
8
|
+
import { AccordionRootContext } from "../../contexts/accordion-root-context/accordion-root-context.qwik.mjs";
|
|
9
|
+
const AccordionRoot = component$((props) => {
|
|
10
|
+
const { as = "div", defaultValue, value: _value, onValueChange$, multiple = false, loopFocus = true, hiddenUntilFound: _hiddenUntilFound = false, disabled: _disabled = false, onKeyDown$, style, ...others } = props;
|
|
11
|
+
const { state: value, setState$: setValue$ } = useControllable({
|
|
12
|
+
defaultValue: defaultValue ?? [],
|
|
13
|
+
controlledSignal: _value,
|
|
14
|
+
onChange$: onValueChange$
|
|
15
|
+
});
|
|
16
|
+
const hiddenUntilFound = useComputed$(() => _hiddenUntilFound);
|
|
17
|
+
const disabled = useComputed$(() => _disabled);
|
|
18
|
+
if (isDev && !multiple && value.value.length > 1) {
|
|
19
|
+
warn([
|
|
20
|
+
`The 'Accordion.Root' component is in single-selection mode,`,
|
|
21
|
+
`but received ${value.value.length} open items in 'value' or 'defaultValue'.`,
|
|
22
|
+
`This may lead to unpredictable behavior.`
|
|
23
|
+
]);
|
|
24
|
+
}
|
|
25
|
+
const onItemOpen$ = $((itemValue) => {
|
|
26
|
+
if (!multiple) {
|
|
27
|
+
setValue$([
|
|
28
|
+
itemValue
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
31
|
+
if (multiple) {
|
|
32
|
+
setValue$([
|
|
33
|
+
...value.value,
|
|
34
|
+
itemValue
|
|
35
|
+
]);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const onItemClose$ = $((itemValue) => {
|
|
39
|
+
if (!multiple) {
|
|
40
|
+
setValue$([]);
|
|
41
|
+
}
|
|
42
|
+
if (multiple) {
|
|
43
|
+
setValue$(value.value.filter((value2) => value2 !== itemValue));
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const handleKeyDownSync$ = sync$((event) => {
|
|
47
|
+
const entryUIQwikEvent = event;
|
|
48
|
+
if (!entryUIQwikEvent.entryUIQwikHandlerPrevented && [
|
|
49
|
+
"ArrowDown",
|
|
50
|
+
"ArrowUp",
|
|
51
|
+
"Home",
|
|
52
|
+
"End"
|
|
53
|
+
].includes(event.key)) {
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const handleKeyDown$ = $((event, currentTarget) => {
|
|
58
|
+
const entryUIQwikEvent = event;
|
|
59
|
+
if (!entryUIQwikEvent.entryUIQwikHandlerPrevented && [
|
|
60
|
+
"ArrowDown",
|
|
61
|
+
"ArrowUp",
|
|
62
|
+
"Home",
|
|
63
|
+
"End"
|
|
64
|
+
].includes(event.key)) {
|
|
65
|
+
const target = event.target;
|
|
66
|
+
const ENABLED_TRIGGERS_SELECTOR = "[data-entry-ui-qwik-accordion-item-trigger]:not([disabled])";
|
|
67
|
+
const enabledTriggers = Array.from(currentTarget.querySelectorAll(ENABLED_TRIGGERS_SELECTOR));
|
|
68
|
+
const thisIndex = enabledTriggers.indexOf(target);
|
|
69
|
+
const lastIndex = enabledTriggers.length - 1;
|
|
70
|
+
let nextIndex = -1;
|
|
71
|
+
switch (event.key) {
|
|
72
|
+
case "ArrowDown":
|
|
73
|
+
if (loopFocus) {
|
|
74
|
+
nextIndex = thisIndex + 1 > lastIndex ? 0 : thisIndex + 1;
|
|
75
|
+
} else {
|
|
76
|
+
nextIndex = Math.min(thisIndex + 1, lastIndex);
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
case "ArrowUp":
|
|
80
|
+
if (loopFocus) {
|
|
81
|
+
nextIndex = thisIndex === 0 ? lastIndex : thisIndex - 1;
|
|
82
|
+
} else {
|
|
83
|
+
nextIndex = thisIndex - 1;
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
case "Home":
|
|
87
|
+
nextIndex = 0;
|
|
88
|
+
break;
|
|
89
|
+
case "End":
|
|
90
|
+
nextIndex = lastIndex;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
if (nextIndex > -1) {
|
|
94
|
+
enabledTriggers[nextIndex]?.focus();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
useContextProvider(AccordionRootContext, {
|
|
99
|
+
value,
|
|
100
|
+
setValue$,
|
|
101
|
+
hiddenUntilFound,
|
|
102
|
+
disabled,
|
|
103
|
+
onItemOpen$,
|
|
104
|
+
onItemClose$
|
|
105
|
+
});
|
|
106
|
+
return /* @__PURE__ */ jsx(Primitive.div, {
|
|
107
|
+
as,
|
|
108
|
+
"data-entry-ui-qwik-accordion-root": "",
|
|
109
|
+
"data-disabled": disabled.value ? "" : void 0,
|
|
110
|
+
onKeyDown$: [
|
|
111
|
+
onKeyDown$,
|
|
112
|
+
handleKeyDownSync$,
|
|
113
|
+
handleKeyDown$
|
|
114
|
+
],
|
|
115
|
+
style: mergeStyles([
|
|
116
|
+
{
|
|
117
|
+
// Performance optimization
|
|
118
|
+
// The `contain: layout style;` CSS property is used here to improve rendering performance.
|
|
119
|
+
// `contain: layout;` tells the browser that the internal layout of this accordion
|
|
120
|
+
// is self-contained and does not affect the layout of elements outside of it. This prevents
|
|
121
|
+
// costly re-calculations of the entire page layout when an accordion item expands or collapses,
|
|
122
|
+
// which is especially beneficial during animations.
|
|
123
|
+
// `contain: style;` ensures that CSS properties that can affect the rest of the page,
|
|
124
|
+
// like counters, are isolated to this element.
|
|
125
|
+
// Together, these properties create a performance "bubble", allowing the browser to optimize
|
|
126
|
+
// rendering by treating the accordion component as an independent unit.
|
|
127
|
+
contain: "layout style"
|
|
128
|
+
},
|
|
129
|
+
style
|
|
130
|
+
]),
|
|
131
|
+
...others,
|
|
132
|
+
children: /* @__PURE__ */ jsx(Slot, {})
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
export {
|
|
136
|
+
AccordionRoot
|
|
137
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { PropsOf, Component, Signal, QRL } from '@qwik.dev/core';
|
|
2
|
+
/**
|
|
3
|
+
* Props for the `Accordion.Root` component.
|
|
4
|
+
* Extends the standard HTML attributes for a `<div>` element.
|
|
5
|
+
*/
|
|
6
|
+
export interface AccordionRootProps 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 value of the accordion item or items to expand when initially rendered.
|
|
17
|
+
* When `multiple` is `false`, this array should contain at most one element.
|
|
18
|
+
* Use when you do not need to control the state of the accordion items.
|
|
19
|
+
*
|
|
20
|
+
* @default []
|
|
21
|
+
*/
|
|
22
|
+
defaultValue?: string[];
|
|
23
|
+
/**
|
|
24
|
+
* The controlled value of the accordion item or items to expand.
|
|
25
|
+
* When `multiple` is `false`, this array should contain at most one element.
|
|
26
|
+
* Must be used in conjunction with `onValueChange$`.
|
|
27
|
+
*
|
|
28
|
+
* @default undefined
|
|
29
|
+
*/
|
|
30
|
+
value?: Signal<string[]>;
|
|
31
|
+
/**
|
|
32
|
+
* A `QRL` callback function that is called when the expanded state of an accordion item or items changes.
|
|
33
|
+
*
|
|
34
|
+
* @default undefined
|
|
35
|
+
*/
|
|
36
|
+
onValueChange$?: QRL<(value: string[]) => void>;
|
|
37
|
+
/**
|
|
38
|
+
* Whether or not multiple accordion items can be expanded at the same time.
|
|
39
|
+
* When `false`, expanding one item will automatically collapse the others.
|
|
40
|
+
*
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
multiple?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Whether the keyboard focus should wrap back to the first or last item trigger
|
|
46
|
+
* when navigating through the accordion.
|
|
47
|
+
* When `true`, pressing `ArrowDown` on the last enabled trigger moves focus to the
|
|
48
|
+
* first one, and `ArrowUp` on the first enabled trigger moves focus to the last one.
|
|
49
|
+
*
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
52
|
+
loopFocus?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* When `true`, all collapsed accordion panels will use the `hidden="until-found"`
|
|
55
|
+
* attribute. This allows the browser's "Find in page" feature to
|
|
56
|
+
* search through collapsed content and automatically expand the item when
|
|
57
|
+
* a match is found.
|
|
58
|
+
*
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
hiddenUntilFound?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* When `true`, prevents the user from interacting with the accordion and all its items.
|
|
64
|
+
*
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
67
|
+
disabled?: boolean;
|
|
68
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type { AccordionRootProps as RootProps } from './accordion-root';
|
|
2
|
+
export type { AccordionItemProps as ItemProps } from './accordion-item';
|
|
3
|
+
export type { AccordionItemHeaderProps as ItemHeaderProps } from './accordion-item-header';
|
|
4
|
+
export type { AccordionItemTriggerProps as ItemTriggerProps } from './accordion-item-trigger';
|
|
5
|
+
export type { AccordionItemPanelProps as ItemPanelProps } from './accordion-item-panel';
|
|
6
|
+
export type { AccordionItemIndicatorProps as ItemIndicatorProps } from './accordion-item-indicator';
|
|
7
|
+
export { AccordionRoot as Root } from './accordion-root';
|
|
8
|
+
export { AccordionItem as Item } from './accordion-item';
|
|
9
|
+
export { AccordionItemHeader as ItemHeader } from './accordion-item-header';
|
|
10
|
+
export { AccordionItemTrigger as ItemTrigger } from './accordion-item-trigger';
|
|
11
|
+
export { AccordionItemPanel as ItemPanel } from './accordion-item-panel';
|
|
12
|
+
export { AccordionItemIndicator as ItemIndicator } from './accordion-item-indicator';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AccordionRoot } from "./accordion-root/accordion-root.qwik.mjs";
|
|
2
|
+
import { AccordionItem } from "./accordion-item/accordion-item.qwik.mjs";
|
|
3
|
+
import { AccordionItemHeader } from "./accordion-item-header/accordion-item-header.qwik.mjs";
|
|
4
|
+
import { AccordionItemTrigger } from "./accordion-item-trigger/accordion-item-trigger.qwik.mjs";
|
|
5
|
+
import { AccordionItemPanel } from "./accordion-item-panel/accordion-item-panel.qwik.mjs";
|
|
6
|
+
import { AccordionItemIndicator } from "./accordion-item-indicator/accordion-item-indicator.qwik.mjs";
|
|
7
|
+
export {
|
|
8
|
+
AccordionItem as Item,
|
|
9
|
+
AccordionItemHeader as ItemHeader,
|
|
10
|
+
AccordionItemIndicator as ItemIndicator,
|
|
11
|
+
AccordionItemPanel as ItemPanel,
|
|
12
|
+
AccordionItemTrigger as ItemTrigger,
|
|
13
|
+
AccordionRoot as Root
|
|
14
|
+
};
|
package/lib/components/collapsible/contexts/collapsible-root-context/collapsible-root-context.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CollapsibleRootContextValue } from './collapsible-root-context.types';
|
|
2
|
+
/**
|
|
3
|
+
* Provides the context for the `Collapsible.Root` component, allowing descendant
|
|
4
|
+
* components to access readonly signals and `QRL` functions without prop drilling.
|
|
5
|
+
*/
|
|
6
|
+
export declare const CollapsibleRootContext: import("@qwik.dev/core").ContextId<CollapsibleRootContextValue>;
|
|
7
|
+
/**
|
|
8
|
+
* A hook that provides access to the `Collapsible.Root` component's internal state.
|
|
9
|
+
* It exposes readonly signals and `QRL` functions to interact with the component's state,
|
|
10
|
+
*/
|
|
11
|
+
export declare const useCollapsibleRootContext: () => CollapsibleRootContextValue;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createContextId, useContext } from "@qwik.dev/core";
|
|
2
|
+
const CollapsibleRootContext = createContextId("entry-ui-qwik-collapsible-root-context");
|
|
3
|
+
const useCollapsibleRootContext = () => {
|
|
4
|
+
const context = useContext(CollapsibleRootContext);
|
|
5
|
+
return context;
|
|
6
|
+
};
|
|
7
|
+
export {
|
|
8
|
+
CollapsibleRootContext,
|
|
9
|
+
useCollapsibleRootContext
|
|
10
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ReadonlySignal, QRL } from '@qwik.dev/core';
|
|
2
|
+
/**
|
|
3
|
+
* The value provided by the `CollapsibleRootContext` context.
|
|
4
|
+
* Contains the readonly signals and `QRL` functions shared with descendant components.
|
|
5
|
+
*/
|
|
6
|
+
export interface CollapsibleRootContextValue {
|
|
7
|
+
/**
|
|
8
|
+
* A readonly signal whose value indicates the collapsible's current open state.
|
|
9
|
+
* It is `true` when the collapsible is open, and `false` when closed.
|
|
10
|
+
*/
|
|
11
|
+
open: ReadonlySignal<boolean>;
|
|
12
|
+
/**
|
|
13
|
+
* A `QRL` function used to programmatically set the open state of the collapsible.
|
|
14
|
+
* When invoked with `true`, the collapsible will open; with `false`, it will close.
|
|
15
|
+
*/
|
|
16
|
+
setOpen$: QRL<(open: boolean) => void>;
|
|
17
|
+
/**
|
|
18
|
+
* A readonly signal whose value indicates the collapsible's current disabled state.
|
|
19
|
+
* It is `true` when the collapsible is prevented from user interaction.
|
|
20
|
+
*/
|
|
21
|
+
disabled: ReadonlySignal<boolean>;
|
|
22
|
+
/**
|
|
23
|
+
* An object containing the identifier state and management `QRL` functions for the trigger element.
|
|
24
|
+
* This is used to link the trigger and the collapsible panel for accessibility purposes (WAI-ARIA).
|
|
25
|
+
*/
|
|
26
|
+
triggerId: {
|
|
27
|
+
/**
|
|
28
|
+
* A readonly signal representing the unique identifier of the trigger.
|
|
29
|
+
*/
|
|
30
|
+
id: ReadonlySignal<string | undefined>;
|
|
31
|
+
/**
|
|
32
|
+
* A `QRL` function to manually set or update the trigger's identifier.
|
|
33
|
+
*/
|
|
34
|
+
set$: QRL<(value: string | undefined) => void>;
|
|
35
|
+
/**
|
|
36
|
+
* A `QRL` function to clear the trigger's identifier.
|
|
37
|
+
*/
|
|
38
|
+
delete$: QRL<() => void>;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* An object containing the identifier state and management functions for the panel element.
|
|
42
|
+
* This ensures the content panel can be correctly referenced by the trigger's `aria-controls` attribute.
|
|
43
|
+
*/
|
|
44
|
+
panelId: {
|
|
45
|
+
/**
|
|
46
|
+
* A readonly signal representing the unique identifier of the collapsible panel.
|
|
47
|
+
*/
|
|
48
|
+
id: ReadonlySignal<string | undefined>;
|
|
49
|
+
/**
|
|
50
|
+
* A `QRL` function to manually set or update the panel's identifier.
|
|
51
|
+
*/
|
|
52
|
+
set$: QRL<(value: string | undefined) => void>;
|
|
53
|
+
/**
|
|
54
|
+
* A `QRL` function to clear the panel's identifier.
|
|
55
|
+
*/
|
|
56
|
+
delete$: QRL<() => void>;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CollapsibleTriggerContextValue } from './collapsible-trigger-context.types';
|
|
2
|
+
/**
|
|
3
|
+
* Provides the context for the `Collapsible.Trigger` component, allowing descendant
|
|
4
|
+
* components to access readonly signal without prop drilling.
|
|
5
|
+
*/
|
|
6
|
+
export declare const CollapsibleTriggerContext: import("@qwik.dev/core").ContextId<CollapsibleTriggerContextValue>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ReadonlySignal } from '@qwik.dev/core';
|
|
2
|
+
/**
|
|
3
|
+
* The value provided by the `CollapsibleTriggerContext` context.
|
|
4
|
+
* Contains the readonly signal shared with descendant components.
|
|
5
|
+
*/
|
|
6
|
+
export interface CollapsibleTriggerContextValue {
|
|
7
|
+
/**
|
|
8
|
+
* A readonly signal representing the effective disabled state of the trigger.
|
|
9
|
+
* This value is computed by prioritizing the trigger's own `disabled` prop,
|
|
10
|
+
* falling back to the `Collapsible.Root` disabled state if not explicitly set.
|
|
11
|
+
*/
|
|
12
|
+
disabled: ReadonlySignal<boolean>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { UseCollapsibleRootContextReturnValue } from './use-collapsible-root-context.types';
|
|
2
|
+
/**
|
|
3
|
+
* A hook that provides access to the `Collapsible.Root` component's internal state.
|
|
4
|
+
* It exposes readonly signals and `QRL` function to interact with the collapsible's state,
|
|
5
|
+
* allowing descendant components to control or react to its expanded/collapsed state.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useCollapsibleRootContext: () => UseCollapsibleRootContextReturnValue;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useContext } from "@qwik.dev/core";
|
|
2
|
+
import { CollapsibleRootContext } from "../../contexts/collapsible-root-context/collapsible-root-context.qwik.mjs";
|
|
3
|
+
const useCollapsibleRootContext = () => {
|
|
4
|
+
const { open, setOpen$, disabled } = useContext(CollapsibleRootContext);
|
|
5
|
+
return {
|
|
6
|
+
open,
|
|
7
|
+
setOpen$,
|
|
8
|
+
disabled
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
useCollapsibleRootContext
|
|
13
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReadonlySignal, QRL } from '@qwik.dev/core';
|
|
2
|
+
/**
|
|
3
|
+
* The value returned by the `useCollapsibleRootContext` hook.
|
|
4
|
+
* Provides access to the collapsible's readonly signals and `QRL` function for descendant components.
|
|
5
|
+
*/
|
|
6
|
+
export interface UseCollapsibleRootContextReturnValue {
|
|
7
|
+
/**
|
|
8
|
+
* A readonly signal whose value indicates the collapsible's current open state.
|
|
9
|
+
* It is `true` when the collapsible is open, and `false` when closed.
|
|
10
|
+
*/
|
|
11
|
+
open: ReadonlySignal<boolean>;
|
|
12
|
+
/**
|
|
13
|
+
* A `QRL` function used to programmatically set the open state of the collapsible.
|
|
14
|
+
* When invoked with `true`, the collapsible will open; with `false`, it will close.
|
|
15
|
+
*/
|
|
16
|
+
setOpen$: QRL<(open: boolean) => void>;
|
|
17
|
+
/**
|
|
18
|
+
* A readonly signal whose value indicates the collapsible's current disabled state.
|
|
19
|
+
* It is `true` when the collapsible is prevented from user interaction.
|
|
20
|
+
*/
|
|
21
|
+
disabled: ReadonlySignal<boolean>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { UseCollapsibleTriggerContextReturnValue } from './use-collapsible-trigger-context.types';
|
|
2
|
+
/**
|
|
3
|
+
* A hook that provides access to the `Collapsible.Trigger` component's internal state.
|
|
4
|
+
* It exposes readonly signal to interact with the trigger's state,
|
|
5
|
+
* allowing descendant components to react to its disabled/enabled state.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useCollapsibleTriggerContext: () => UseCollapsibleTriggerContextReturnValue;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useContext } from "@qwik.dev/core";
|
|
2
|
+
import { CollapsibleTriggerContext } from "../../contexts/collapsible-trigger-context/collapsible-trigger-context.qwik.mjs";
|
|
3
|
+
const useCollapsibleTriggerContext = () => {
|
|
4
|
+
const { disabled } = useContext(CollapsibleTriggerContext);
|
|
5
|
+
return {
|
|
6
|
+
disabled
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
useCollapsibleTriggerContext
|
|
11
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ReadonlySignal } from '@qwik.dev/core';
|
|
2
|
+
/**
|
|
3
|
+
* The value returned by the `useCollapsibleTriggerContext` hook.
|
|
4
|
+
* Provides access to the trigger's readonly signal for descendant components.
|
|
5
|
+
*/
|
|
6
|
+
export interface UseCollapsibleTriggerContextReturnValue {
|
|
7
|
+
/**
|
|
8
|
+
* A readonly signal representing the effective disabled state of the trigger.
|
|
9
|
+
* This value is computed by prioritizing the trigger's own `disabled` prop,
|
|
10
|
+
* falling back to the `Collapsible.Root` disabled state if not explicitly set.
|
|
11
|
+
*/
|
|
12
|
+
disabled: ReadonlySignal<boolean>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as index from "./parts/index.qwik.mjs";
|
|
2
|
+
import { useCollapsibleRootContext } from "./hooks/use-collapsible-root-context/use-collapsible-root-context.qwik.mjs";
|
|
3
|
+
import { useCollapsibleTriggerContext } from "./hooks/use-collapsible-trigger-context/use-collapsible-trigger-context.qwik.mjs";
|
|
4
|
+
export {
|
|
5
|
+
index as Collapsible,
|
|
6
|
+
useCollapsibleRootContext,
|
|
7
|
+
useCollapsibleTriggerContext
|
|
8
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CollapsibleIndicatorProps } from './collapsible-indicator.types';
|
|
2
|
+
/**
|
|
3
|
+
* An optional visual indicator that reflects the collapsible's open or closed state.
|
|
4
|
+
* It typically displays an icon or other visual cue to show the current status.
|
|
5
|
+
*
|
|
6
|
+
* Renders a `<span>` element.
|
|
7
|
+
*/
|
|
8
|
+
export declare const CollapsibleIndicator: import("@qwik.dev/core").Component<CollapsibleIndicatorProps>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx } from "@qwik.dev/core/jsx-runtime";
|
|
2
|
+
import { component$, Slot } from "@qwik.dev/core";
|
|
3
|
+
import { mergeStyles } from "../../../../utilities/merge-styles/merge-styles.qwik.mjs";
|
|
4
|
+
import { Primitive } from "../../../../_internal/components/primitive/primitive.qwik.mjs";
|
|
5
|
+
import { useCollapsibleRootContext } from "../../contexts/collapsible-root-context/collapsible-root-context.qwik.mjs";
|
|
6
|
+
const CollapsibleIndicator = component$((props) => {
|
|
7
|
+
const { style, ...others } = props;
|
|
8
|
+
const { open, disabled } = useCollapsibleRootContext();
|
|
9
|
+
return /* @__PURE__ */ jsx(Primitive.span, {
|
|
10
|
+
"aria-hidden": "true",
|
|
11
|
+
"data-entry-ui-qwik-collapsible-indicator": "",
|
|
12
|
+
"data-state": open.value ? "open" : "closed",
|
|
13
|
+
"data-disabled": disabled.value ? "" : void 0,
|
|
14
|
+
style: mergeStyles([
|
|
15
|
+
{
|
|
16
|
+
pointerEvents: "none",
|
|
17
|
+
userSelect: "none"
|
|
18
|
+
},
|
|
19
|
+
style
|
|
20
|
+
]),
|
|
21
|
+
...others,
|
|
22
|
+
children: /* @__PURE__ */ jsx(Slot, {})
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
export {
|
|
26
|
+
CollapsibleIndicator
|
|
27
|
+
};
|
package/lib/components/collapsible/parts/collapsible-indicator/collapsible-indicator.types.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PropsOf, Component } from '@qwik.dev/core';
|
|
2
|
+
/**
|
|
3
|
+
* Props for the `Collapsible.Indicator` component.
|
|
4
|
+
* Extends the standard HTML attributes for a `<span>` element.
|
|
5
|
+
*/
|
|
6
|
+
export interface CollapsibleIndicatorProps extends PropsOf<'span'> {
|
|
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 "span"
|
|
13
|
+
*/
|
|
14
|
+
as?: string | Component;
|
|
15
|
+
}
|