@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,49 @@
|
|
|
1
|
+
import { jsx } from "@qwik.dev/core/jsx-runtime";
|
|
2
|
+
import { component$, useComputed$, $, useContextProvider, Slot } from "@qwik.dev/core";
|
|
3
|
+
import { useId } from "../../../../_internal/hooks/use-id/use-id.qwik.mjs";
|
|
4
|
+
import { useIdManager } from "../../../../_internal/hooks/use-id-manager/use-id-manager.qwik.mjs";
|
|
5
|
+
import { Primitive } from "../../../../_internal/components/primitive/primitive.qwik.mjs";
|
|
6
|
+
import { useAccordionRootContext } from "../../contexts/accordion-root-context/accordion-root-context.qwik.mjs";
|
|
7
|
+
import { AccordionItemContext } from "../../contexts/accordion-item-context/accordion-item-context.qwik.mjs";
|
|
8
|
+
const AccordionItem = component$((props) => {
|
|
9
|
+
const { as = "div", value: _value, disabled: _disabled = false, ...others } = props;
|
|
10
|
+
const { value: rootValue, disabled: rootDisabled, onItemOpen$, onItemClose$ } = useAccordionRootContext();
|
|
11
|
+
const fallbackValue = useId({
|
|
12
|
+
prefix: "entry-ui-qwik-accordion-item-"
|
|
13
|
+
});
|
|
14
|
+
const value = useComputed$(() => _value ?? fallbackValue);
|
|
15
|
+
const open = useComputed$(() => rootValue.value.includes(value.value));
|
|
16
|
+
const disabled = useComputed$(() => _disabled || rootDisabled.value);
|
|
17
|
+
const triggerId = useIdManager({
|
|
18
|
+
prefix: "entry-ui-qwik-accordion-item-trigger-"
|
|
19
|
+
});
|
|
20
|
+
const panelId = useIdManager({
|
|
21
|
+
prefix: "entry-ui-qwik-accordion-item-panel-"
|
|
22
|
+
});
|
|
23
|
+
const setOpen$ = $((open2) => {
|
|
24
|
+
if (open2) {
|
|
25
|
+
onItemOpen$(value.value);
|
|
26
|
+
} else {
|
|
27
|
+
onItemClose$(value.value);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
useContextProvider(AccordionItemContext, {
|
|
31
|
+
value,
|
|
32
|
+
open,
|
|
33
|
+
setOpen$,
|
|
34
|
+
disabled,
|
|
35
|
+
triggerId,
|
|
36
|
+
panelId
|
|
37
|
+
});
|
|
38
|
+
return /* @__PURE__ */ jsx(Primitive.div, {
|
|
39
|
+
as,
|
|
40
|
+
"data-entry-ui-qwik-accordion-item": "",
|
|
41
|
+
"data-state": open.value ? "open" : "closed",
|
|
42
|
+
"data-disabled": disabled.value ? "" : void 0,
|
|
43
|
+
...others,
|
|
44
|
+
children: /* @__PURE__ */ jsx(Slot, {})
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
export {
|
|
48
|
+
AccordionItem
|
|
49
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { PropsOf, Component } from '@qwik.dev/core';
|
|
2
|
+
/**
|
|
3
|
+
* Props for the `Accordion.Item` component.
|
|
4
|
+
* Extends the standard HTML attributes for a `<div>` element.
|
|
5
|
+
*/
|
|
6
|
+
export interface AccordionItemProps 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
|
+
* A unique value that identifies this accordion item.
|
|
17
|
+
* If no value is provided, a unique ID will be generated automatically.
|
|
18
|
+
* Use when controlling the accordion programmatically, or to set an initial open state.
|
|
19
|
+
*
|
|
20
|
+
* @default undefined
|
|
21
|
+
*/
|
|
22
|
+
value?: string;
|
|
23
|
+
/**
|
|
24
|
+
* When `true`, prevents the user from interacting with the accordion item.
|
|
25
|
+
*
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AccordionItemHeaderProps } from './accordion-item-header.types';
|
|
2
|
+
/**
|
|
3
|
+
* A heading that labels the corresponding panel.
|
|
4
|
+
*
|
|
5
|
+
* It provides a semantic structure to the collapsible section,
|
|
6
|
+
* ensuring it follows accessibility best practices by wrapping
|
|
7
|
+
* the interactive trigger in a heading element.
|
|
8
|
+
*
|
|
9
|
+
* Renders an `<h3>` element.
|
|
10
|
+
*/
|
|
11
|
+
export declare const AccordionItemHeader: import("@qwik.dev/core").Component<AccordionItemHeaderProps>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx } from "@qwik.dev/core/jsx-runtime";
|
|
2
|
+
import { component$, Slot } from "@qwik.dev/core";
|
|
3
|
+
import { Primitive } from "../../../../_internal/components/primitive/primitive.qwik.mjs";
|
|
4
|
+
import { useAccordionItemContext } from "../../contexts/accordion-item-context/accordion-item-context.qwik.mjs";
|
|
5
|
+
const AccordionItemHeader = component$((props) => {
|
|
6
|
+
const { as = "h3", ...others } = props;
|
|
7
|
+
const { open, disabled } = useAccordionItemContext();
|
|
8
|
+
return /* @__PURE__ */ jsx(Primitive.h3, {
|
|
9
|
+
as,
|
|
10
|
+
"data-entry-ui-qwik-accordion-item-header": "",
|
|
11
|
+
"data-state": open.value ? "open" : "closed",
|
|
12
|
+
"data-disabled": disabled.value ? "" : void 0,
|
|
13
|
+
...others,
|
|
14
|
+
children: /* @__PURE__ */ jsx(Slot, {})
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
export {
|
|
18
|
+
AccordionItemHeader
|
|
19
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PropsOf, Component } from '@qwik.dev/core';
|
|
2
|
+
/**
|
|
3
|
+
* Props for the `Accordion.ItemHeader` component.
|
|
4
|
+
* Extends the standard HTML attributes for an `<h3>` element.
|
|
5
|
+
*/
|
|
6
|
+
export interface AccordionItemHeaderProps extends PropsOf<'h3'> {
|
|
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 "h3"
|
|
13
|
+
*/
|
|
14
|
+
as?: string | Component;
|
|
15
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AccordionItemIndicatorProps } from './accordion-item-indicator.types';
|
|
2
|
+
/**
|
|
3
|
+
* An optional visual indicator that reflects the item'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 AccordionItemIndicator: import("@qwik.dev/core").Component<AccordionItemIndicatorProps>;
|
package/lib/components/accordion/parts/accordion-item-indicator/accordion-item-indicator.qwik.mjs
ADDED
|
@@ -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 { useAccordionItemContext } from "../../contexts/accordion-item-context/accordion-item-context.qwik.mjs";
|
|
6
|
+
const AccordionItemIndicator = component$((props) => {
|
|
7
|
+
const { style, ...others } = props;
|
|
8
|
+
const { open, disabled } = useAccordionItemContext();
|
|
9
|
+
return /* @__PURE__ */ jsx(Primitive.span, {
|
|
10
|
+
"aria-hidden": "true",
|
|
11
|
+
"data-entry-ui-qwik-accordion-item-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
|
+
AccordionItemIndicator
|
|
27
|
+
};
|
package/lib/components/accordion/parts/accordion-item-indicator/accordion-item-indicator.types.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PropsOf, Component } from '@qwik.dev/core';
|
|
2
|
+
/**
|
|
3
|
+
* Props for the `Accordion.ItemIndicator` component.
|
|
4
|
+
* Extends the standard HTML attributes for a `<span>` element.
|
|
5
|
+
*/
|
|
6
|
+
export interface AccordionItemIndicatorProps 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
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AccordionItemPanelProps } from './accordion-item-panel.types';
|
|
2
|
+
/**
|
|
3
|
+
* A collapsible panel with the accordion item contents.
|
|
4
|
+
*
|
|
5
|
+
* Renders a `<div>` element.
|
|
6
|
+
*/
|
|
7
|
+
export declare const AccordionItemPanel: import("@qwik.dev/core").Component<AccordionItemPanelProps>;
|
|
@@ -0,0 +1,199 @@
|
|
|
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 { useAccordionRootContext } from "../../contexts/accordion-root-context/accordion-root-context.qwik.mjs";
|
|
12
|
+
import { useAccordionItemContext } from "../../contexts/accordion-item-context/accordion-item-context.qwik.mjs";
|
|
13
|
+
const AccordionItemPanel = component$((props) => {
|
|
14
|
+
const { as = "div", ref: _ref, id, hiddenUntilFound: _hiddenUntilFound = false, onOpenChangeComplete$, onBeforematch$, style, ...others } = props;
|
|
15
|
+
const { hiddenUntilFound: rootHiddenUntilFound } = useAccordionRootContext();
|
|
16
|
+
const { open, setOpen$, disabled, panelId, triggerId } = useAccordionItemContext();
|
|
17
|
+
const ref = useSignal(void 0);
|
|
18
|
+
const hidden = useSignal(!open.value);
|
|
19
|
+
const state = useSignal(open.value ? "open" : "closed");
|
|
20
|
+
const height = useSignal(() => {
|
|
21
|
+
if (open.value) {
|
|
22
|
+
return "auto";
|
|
23
|
+
}
|
|
24
|
+
return _hiddenUntilFound || rootHiddenUntilFound.value ? disabled.value ? "0px" : "none" : "0px";
|
|
25
|
+
});
|
|
26
|
+
const isBeforeMatch = useSignal(false);
|
|
27
|
+
const preventInitialAnimation = useSignal(true);
|
|
28
|
+
const hiddenUntilFound = useComputed$(() => disabled.value ? false : _hiddenUntilFound || rootHiddenUntilFound.value);
|
|
29
|
+
const mergedStyles = useComputed$(() => mergeStyles([
|
|
30
|
+
{
|
|
31
|
+
display: hidden.value ? hiddenUntilFound.value ? void 0 : "none !important" : void 0,
|
|
32
|
+
transitionDuration: preventInitialAnimation.value ? "0s" : void 0,
|
|
33
|
+
animationDuration: preventInitialAnimation.value ? "0s" : void 0,
|
|
34
|
+
"--entry-ui-qwik-accordion-item-panel-height": height.value
|
|
35
|
+
},
|
|
36
|
+
style
|
|
37
|
+
]));
|
|
38
|
+
useLifecycle({
|
|
39
|
+
element: ref,
|
|
40
|
+
onMount$: $(() => panelId.set$(id)),
|
|
41
|
+
onUnmount$: $(() => panelId.delete$())
|
|
42
|
+
});
|
|
43
|
+
useTask$(({ track }) => {
|
|
44
|
+
const isHiddenUntilFound = track(() => hiddenUntilFound.value);
|
|
45
|
+
const panelRef = ref.value;
|
|
46
|
+
if (isBrowser && panelRef) {
|
|
47
|
+
const panelHeight = open.value ? "auto" : isHiddenUntilFound ? "none" : "0px";
|
|
48
|
+
height.value = panelHeight;
|
|
49
|
+
panelRef.style.setProperty("--entry-ui-qwik-accordion-item-panel-height", panelHeight);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
useTask$(({ track, cleanup }) => {
|
|
53
|
+
const isOpen = track(() => open.value);
|
|
54
|
+
const panelRef = ref.value;
|
|
55
|
+
if (isBrowser && panelRef) {
|
|
56
|
+
if (preventInitialAnimation.value && !isBeforeMatch.value) {
|
|
57
|
+
preventInitialAnimation.value = false;
|
|
58
|
+
panelRef.style.removeProperty("transition-duration");
|
|
59
|
+
panelRef.style.removeProperty("animation-duration");
|
|
60
|
+
}
|
|
61
|
+
if (isOpen) {
|
|
62
|
+
hidden.value = false;
|
|
63
|
+
panelRef.removeAttribute("hidden");
|
|
64
|
+
if (hiddenUntilFound.value) {
|
|
65
|
+
isBeforeMatch.value = false;
|
|
66
|
+
} else {
|
|
67
|
+
panelRef.style.removeProperty("display");
|
|
68
|
+
}
|
|
69
|
+
state.value = "open";
|
|
70
|
+
panelRef.setAttribute("data-state", "open");
|
|
71
|
+
const { animationDuration: animationDuration2, transitionDuration: transitionDuration2 } = getComputedStyle(panelRef);
|
|
72
|
+
const panelHeight = getHiddenElementHeight(panelRef);
|
|
73
|
+
if (animationDuration2 === "0s" && transitionDuration2 !== "0s") {
|
|
74
|
+
if (height.value === "none") {
|
|
75
|
+
height.value = "0px";
|
|
76
|
+
panelRef.style.setProperty("--entry-ui-qwik-accordion-item-panel-height", "0px");
|
|
77
|
+
setTimeout(() => {
|
|
78
|
+
height.value = `${panelHeight}px`;
|
|
79
|
+
panelRef.style.setProperty("--entry-ui-qwik-accordion-item-panel-height", `${panelHeight}px`);
|
|
80
|
+
}, 0);
|
|
81
|
+
} else {
|
|
82
|
+
height.value = `${panelHeight}px`;
|
|
83
|
+
panelRef.style.setProperty("--entry-ui-qwik-accordion-item-panel-height", `${panelHeight}px`);
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
height.value = `${panelHeight}px`;
|
|
87
|
+
panelRef.style.setProperty("--entry-ui-qwik-accordion-item-panel-height", `${panelHeight}px`);
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
state.value = "closed";
|
|
91
|
+
panelRef.setAttribute("data-state", "closed");
|
|
92
|
+
const { animationDuration: animationDuration2, transitionDuration: transitionDuration2 } = getComputedStyle(panelRef);
|
|
93
|
+
const panelHeight = getHiddenElementHeight(panelRef);
|
|
94
|
+
if (animationDuration2 === "0s" && transitionDuration2 !== "0s") {
|
|
95
|
+
if (height.value === "auto") {
|
|
96
|
+
height.value = `${panelHeight}px`;
|
|
97
|
+
panelRef.style.setProperty("--entry-ui-qwik-accordion-item-panel-height", `${panelHeight}px`);
|
|
98
|
+
setTimeout(() => {
|
|
99
|
+
height.value = "0px";
|
|
100
|
+
panelRef.style.setProperty("--entry-ui-qwik-accordion-item-panel-height", "0px");
|
|
101
|
+
}, 0);
|
|
102
|
+
} else {
|
|
103
|
+
height.value = "0px";
|
|
104
|
+
panelRef.style.setProperty("--entry-ui-qwik-accordion-item-panel-height", "0px");
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
height.value = `${panelHeight}px`;
|
|
108
|
+
panelRef.style.setProperty("--entry-ui-qwik-accordion-item-panel-height", `${panelHeight}px`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const applyFinalState = () => {
|
|
112
|
+
if (isOpen) {
|
|
113
|
+
height.value = "auto";
|
|
114
|
+
panelRef.style.setProperty("--entry-ui-qwik-accordion-item-panel-height", "auto");
|
|
115
|
+
} else {
|
|
116
|
+
hidden.value = true;
|
|
117
|
+
if (hiddenUntilFound.value) {
|
|
118
|
+
height.value = "none";
|
|
119
|
+
panelRef.style.setProperty("--entry-ui-qwik-accordion-item-panel-height", "none");
|
|
120
|
+
} else {
|
|
121
|
+
height.value = "0px";
|
|
122
|
+
panelRef.style.setProperty("--entry-ui-qwik-accordion-item-panel-height", "0px");
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (onOpenChangeComplete$) {
|
|
126
|
+
onOpenChangeComplete$(isOpen);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const { transitionDuration, animationDuration } = getComputedStyle(panelRef);
|
|
130
|
+
if (isDev && transitionDuration !== "0s" && animationDuration !== "0s") {
|
|
131
|
+
warn([
|
|
132
|
+
`Both CSS transitions and CSS animations are detected on 'Accordion.ItemPanel' component.`,
|
|
133
|
+
`Using both at the same time may cause unpredictable behavior.`,
|
|
134
|
+
`Please use only one animation method.`
|
|
135
|
+
]);
|
|
136
|
+
applyFinalState();
|
|
137
|
+
} else if (transitionDuration !== "0s") {
|
|
138
|
+
const removeTransitionEndListener = addEventListenerOnce({
|
|
139
|
+
target: panelRef,
|
|
140
|
+
type: "transitionend",
|
|
141
|
+
listener: applyFinalState
|
|
142
|
+
});
|
|
143
|
+
cleanup(() => {
|
|
144
|
+
removeTransitionEndListener();
|
|
145
|
+
});
|
|
146
|
+
} else if (animationDuration !== "0s") {
|
|
147
|
+
const removeAnimationEndListener = addEventListenerOnce({
|
|
148
|
+
target: panelRef,
|
|
149
|
+
type: "animationend",
|
|
150
|
+
listener: applyFinalState
|
|
151
|
+
});
|
|
152
|
+
cleanup(() => {
|
|
153
|
+
removeAnimationEndListener();
|
|
154
|
+
});
|
|
155
|
+
} else {
|
|
156
|
+
applyFinalState();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
const handleBeforeMatchSync$ = sync$((event) => {
|
|
161
|
+
const entryUIQwikEvent = event;
|
|
162
|
+
if (!entryUIQwikEvent.entryUIQwikHandlerPrevented) {
|
|
163
|
+
event.preventDefault();
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
const handleBeforeMatch$ = $((event) => {
|
|
167
|
+
const entryUIQwikEvent = event;
|
|
168
|
+
if (!entryUIQwikEvent.entryUIQwikHandlerPrevented) {
|
|
169
|
+
isBeforeMatch.value = true;
|
|
170
|
+
preventInitialAnimation.value = true;
|
|
171
|
+
setOpen$(true);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
return /* @__PURE__ */ jsx(Primitive.div, {
|
|
175
|
+
as,
|
|
176
|
+
ref: mergeRefs([
|
|
177
|
+
_ref,
|
|
178
|
+
ref
|
|
179
|
+
]),
|
|
180
|
+
id: panelId.id.value,
|
|
181
|
+
role: triggerId.id.value ? "region" : void 0,
|
|
182
|
+
hidden: hidden.value ? hiddenUntilFound.value ? "until-found" : "hidden" : void 0,
|
|
183
|
+
"aria-labelledby": triggerId.id.value,
|
|
184
|
+
"data-entry-ui-qwik-accordion-item-panel": "",
|
|
185
|
+
"data-state": state.value,
|
|
186
|
+
"data-disabled": disabled.value ? "" : void 0,
|
|
187
|
+
onBeforematch$: [
|
|
188
|
+
onBeforematch$,
|
|
189
|
+
handleBeforeMatchSync$,
|
|
190
|
+
handleBeforeMatch$
|
|
191
|
+
],
|
|
192
|
+
style: mergedStyles.value,
|
|
193
|
+
...others,
|
|
194
|
+
children: /* @__PURE__ */ jsx(Slot, {})
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
export {
|
|
198
|
+
AccordionItemPanel
|
|
199
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PropsOf, Component, QRL } from '@qwik.dev/core';
|
|
2
|
+
/**
|
|
3
|
+
* Props for the `Accordion.ItemPanel` component.
|
|
4
|
+
* Extends the standard HTML attributes for a `<div>` element.
|
|
5
|
+
*/
|
|
6
|
+
export interface AccordionItemPanelProps 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,7 @@
|
|
|
1
|
+
import type { AccordionItemTriggerProps } from './accordion-item-trigger.types';
|
|
2
|
+
/**
|
|
3
|
+
* A button that opens and closes the corresponding panel.
|
|
4
|
+
*
|
|
5
|
+
* Renders a `<button>` element.
|
|
6
|
+
*/
|
|
7
|
+
export declare const AccordionItemTrigger: import("@qwik.dev/core").Component<AccordionItemTriggerProps>;
|
|
@@ -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 { useAccordionItemContext } from "../../contexts/accordion-item-context/accordion-item-context.qwik.mjs";
|
|
7
|
+
import { AccordionItemTriggerContext } from "../../contexts/accordion-item-trigger-context/accordion-item-trigger-context.qwik.mjs";
|
|
8
|
+
const AccordionItemTrigger = component$((props) => {
|
|
9
|
+
const { as = "button", ref: _ref, id, disabled: _disabled, onClick$, ...others } = props;
|
|
10
|
+
const { open, setOpen$, disabled: itemDisabled, triggerId, panelId } = useAccordionItemContext();
|
|
11
|
+
const ref = useSignal(void 0);
|
|
12
|
+
const disabled = useComputed$(() => _disabled ?? itemDisabled.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(AccordionItemTriggerContext, {
|
|
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-accordion-item-trigger": "",
|
|
39
|
+
"data-state": open.value ? "open" : "closed",
|
|
40
|
+
// Present when the accordion item component is in a disabled state.
|
|
41
|
+
"data-disabled": itemDisabled.value ? "" : void 0,
|
|
42
|
+
onClick$: [
|
|
43
|
+
onClick$,
|
|
44
|
+
handleClick$
|
|
45
|
+
],
|
|
46
|
+
...others,
|
|
47
|
+
children: /* @__PURE__ */ jsx(Slot, {})
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
export {
|
|
51
|
+
AccordionItemTrigger
|
|
52
|
+
};
|
package/lib/components/accordion/parts/accordion-item-trigger/accordion-item-trigger.types.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PropsOf, Component } from '@qwik.dev/core';
|
|
2
|
+
/**
|
|
3
|
+
* Props for the `Accordion.ItemTrigger` component.
|
|
4
|
+
* Extends the standard HTML attributes for a `<button>` element.
|
|
5
|
+
*/
|
|
6
|
+
export interface AccordionItemTriggerProps 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 `Accordion.Item` component.
|
|
19
|
+
*
|
|
20
|
+
* @default undefined
|
|
21
|
+
*/
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
}
|