@entry-ui/qwik 0.5.0 → 0.6.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 (68) hide show
  1. package/lib/_internal/hooks/index.d.ts +1 -0
  2. package/lib/_internal/hooks/use-id-manager/index.d.ts +2 -0
  3. package/lib/_internal/hooks/use-id-manager/use-id-manager.d.ts +21 -0
  4. package/lib/_internal/hooks/use-id-manager/use-id-manager.qwik.mjs +25 -0
  5. package/lib/_internal/hooks/use-id-manager/use-id-manager.types.d.ts +56 -0
  6. package/lib/_internal/index.d.ts +1 -0
  7. package/lib/_internal/utilities/error/error.qwik.mjs +10 -0
  8. package/lib/_internal/utilities/warn/warn.qwik.mjs +10 -0
  9. package/lib/components/collapsible/contexts/collapsible-root-context/collapsible-root-context.d.ts +11 -0
  10. package/lib/components/collapsible/contexts/collapsible-root-context/collapsible-root-context.qwik.mjs +10 -0
  11. package/lib/components/collapsible/contexts/collapsible-root-context/collapsible-root-context.types.d.ts +58 -0
  12. package/lib/components/collapsible/contexts/collapsible-root-context/index.d.ts +2 -0
  13. package/lib/components/collapsible/contexts/collapsible-trigger-context/collapsible-trigger-context.d.ts +6 -0
  14. package/lib/components/collapsible/contexts/collapsible-trigger-context/collapsible-trigger-context.qwik.mjs +5 -0
  15. package/lib/components/collapsible/contexts/collapsible-trigger-context/collapsible-trigger-context.types.d.ts +13 -0
  16. package/lib/components/collapsible/contexts/collapsible-trigger-context/index.d.ts +2 -0
  17. package/lib/components/collapsible/contexts/index.d.ts +2 -0
  18. package/lib/components/collapsible/hooks/index.d.ts +2 -0
  19. package/lib/components/collapsible/hooks/use-collapsible-root-context/index.d.ts +2 -0
  20. package/lib/components/collapsible/hooks/use-collapsible-root-context/use-collapsible-root-context.d.ts +7 -0
  21. package/lib/components/collapsible/hooks/use-collapsible-root-context/use-collapsible-root-context.qwik.mjs +13 -0
  22. package/lib/components/collapsible/hooks/use-collapsible-root-context/use-collapsible-root-context.types.d.ts +22 -0
  23. package/lib/components/collapsible/hooks/use-collapsible-trigger-context/index.d.ts +2 -0
  24. package/lib/components/collapsible/hooks/use-collapsible-trigger-context/use-collapsible-trigger-context.d.ts +7 -0
  25. package/lib/components/collapsible/hooks/use-collapsible-trigger-context/use-collapsible-trigger-context.qwik.mjs +11 -0
  26. package/lib/components/collapsible/hooks/use-collapsible-trigger-context/use-collapsible-trigger-context.types.d.ts +13 -0
  27. package/lib/components/collapsible/index.d.ts +2 -0
  28. package/lib/components/collapsible/index.qwik.mjs +8 -0
  29. package/lib/components/collapsible/parts/collapsible-indicator/collapsible-indicator.d.ts +8 -0
  30. package/lib/components/collapsible/parts/collapsible-indicator/collapsible-indicator.qwik.mjs +27 -0
  31. package/lib/components/collapsible/parts/collapsible-indicator/collapsible-indicator.types.d.ts +15 -0
  32. package/lib/components/collapsible/parts/collapsible-indicator/index.d.ts +2 -0
  33. package/lib/components/collapsible/parts/collapsible-panel/collapsible-panel.d.ts +7 -0
  34. package/lib/components/collapsible/parts/collapsible-panel/collapsible-panel.qwik.mjs +169 -0
  35. package/lib/components/collapsible/parts/collapsible-panel/collapsible-panel.types.d.ts +31 -0
  36. package/lib/components/collapsible/parts/collapsible-panel/index.d.ts +2 -0
  37. package/lib/components/collapsible/parts/collapsible-root/collapsible-root.d.ts +7 -0
  38. package/lib/components/collapsible/parts/collapsible-root/collapsible-root.qwik.mjs +56 -0
  39. package/lib/components/collapsible/parts/collapsible-root/collapsible-root.types.d.ts +41 -0
  40. package/lib/components/collapsible/parts/collapsible-root/index.d.ts +2 -0
  41. package/lib/components/collapsible/parts/collapsible-trigger/collapsible-trigger.d.ts +7 -0
  42. package/lib/components/collapsible/parts/collapsible-trigger/collapsible-trigger.qwik.mjs +52 -0
  43. package/lib/components/collapsible/parts/collapsible-trigger/collapsible-trigger.types.d.ts +23 -0
  44. package/lib/components/collapsible/parts/collapsible-trigger/index.d.ts +2 -0
  45. package/lib/components/collapsible/parts/index.d.ts +8 -0
  46. package/lib/components/collapsible/parts/index.qwik.mjs +10 -0
  47. package/lib/components/index.d.ts +1 -0
  48. package/lib/hooks/index.d.ts +2 -0
  49. package/lib/hooks/use-counter/index.d.ts +2 -0
  50. package/lib/hooks/use-counter/index.qwik.mjs +4 -0
  51. package/lib/hooks/use-counter/use-counter.d.ts +15 -0
  52. package/lib/hooks/use-counter/use-counter.qwik.mjs +113 -0
  53. package/lib/hooks/use-counter/use-counter.types.d.ts +73 -0
  54. package/lib/hooks/use-lifecycle/index.d.ts +2 -0
  55. package/lib/hooks/use-lifecycle/index.qwik.mjs +4 -0
  56. package/lib/hooks/use-lifecycle/use-lifecycle.d.ts +21 -0
  57. package/lib/hooks/use-lifecycle/use-lifecycle.qwik.mjs +59 -0
  58. package/lib/hooks/use-lifecycle/use-lifecycle.types.d.ts +33 -0
  59. package/lib/hooks/use-lifecycle/utilities/create-global-unmount-observer/create-global-unmount-observer.d.ts +13 -0
  60. package/lib/hooks/use-lifecycle/utilities/create-global-unmount-observer/create-global-unmount-observer.qwik.mjs +91 -0
  61. package/lib/hooks/use-lifecycle/utilities/create-global-unmount-observer/create-global-unmount-observer.types.d.ts +26 -0
  62. package/lib/hooks/use-lifecycle/utilities/create-global-unmount-observer/index.d.ts +2 -0
  63. package/lib/hooks/use-lifecycle/utilities/index.d.ts +1 -0
  64. package/lib/index.qwik.mjs +14 -4
  65. package/lib/types/index.d.ts +1 -0
  66. package/lib/types/signal-or-readonly-signal/index.d.ts +1 -0
  67. package/lib/types/signal-or-readonly-signal/signal-or-readonly-signal.types.d.ts +12 -0
  68. package/package.json +14 -2
@@ -0,0 +1 @@
1
+ export * from './use-id-manager';
@@ -0,0 +1,2 @@
1
+ export type { UseIdManagerParams, UseIdManagerReturnValue } from './use-id-manager.types';
2
+ export { useIdManager } from './use-id-manager';
@@ -0,0 +1,21 @@
1
+ import type { UseIdManagerParams, UseIdManagerReturnValue } from './use-id-manager.types';
2
+ /**
3
+ * A hook that manages unique identifiers with support for prefixes and manual state control.
4
+ *
5
+ * This hook provides a flexible way to handle DOM identifiers, ensuring
6
+ * accessibility and consistency across components. It encapsulates the
7
+ * complexity of generating unique IDs while offering granular control
8
+ * through dedicated `QRL` functions.
9
+ *
10
+ * The generated identifier follows a specific structure:
11
+ * `[prefix][baseId]`
12
+ * - prefix: A string prepended to the ID (defaults to `entry-ui-qwik-`).
13
+ * - baseId: Either a custom string provided via `generatedId` or a unique
14
+ * sequence generated by the Qwik's `useId` hook.
15
+ *
16
+ * Example Outputs:
17
+ * - Default: `"entry-ui-qwik-rs7mG5255s"` (where `"rs7mG5255s"` is the `autoId`)
18
+ * - Custom prefix: `"my-app-header-rs7mG5255s"`
19
+ * - Custom base: `"entry-ui-qwik-custom-id"`
20
+ */
21
+ export declare const useIdManager: (params?: UseIdManagerParams) => UseIdManagerReturnValue;
@@ -0,0 +1,25 @@
1
+ import { useId, useConstant, useSignal, $ } from "@qwik.dev/core";
2
+ const useIdManager = (params = {}) => {
3
+ const { prefix = "entry-ui-qwik-", generatedId, shouldInitialize = false } = params;
4
+ const autoId = useId();
5
+ const baseId = useConstant(() => generatedId ? generatedId.trim() : autoId);
6
+ const id = useSignal(shouldInitialize ? `${prefix.trim()}${baseId}` : void 0);
7
+ const set$ = $((value) => {
8
+ if (value && value.trim() !== "") {
9
+ id.value = value;
10
+ } else {
11
+ id.value = `${prefix}${baseId}`;
12
+ }
13
+ });
14
+ const delete$ = $(() => {
15
+ id.value = void 0;
16
+ });
17
+ return {
18
+ id,
19
+ set$,
20
+ delete$
21
+ };
22
+ };
23
+ export {
24
+ useIdManager
25
+ };
@@ -0,0 +1,56 @@
1
+ import { ReadonlySignal, QRL } from '@qwik.dev/core';
2
+ /**
3
+ * Configuration parameters for the `useIdManager` hook.
4
+ */
5
+ export interface UseIdManagerParams {
6
+ /**
7
+ * An optional prefix to prepend to the generated or provided identifier.
8
+ * This is useful for namespacing IDs to avoid collisions in the DOM,
9
+ * especially when multiple instances of the same component are present.
10
+ *
11
+ * @default "entry-ui-qwik-"
12
+ */
13
+ prefix?: string;
14
+ /**
15
+ * An optional value to override the internal identifier.
16
+ * When provided, this value will be used as the base for the identifier.
17
+ * If omitted, the hook will fall back to a unique ID automatically
18
+ * generated by the Qwik's `useId` hook.
19
+ *
20
+ * @default undefined
21
+ */
22
+ generatedId?: string;
23
+ /**
24
+ * Determines whether the identifier should be initialized immediately upon hook creation.
25
+ * If set to `true`, the `id` readonly signal will be populated with the combined prefix and base ID on mount.
26
+ * If `false`, the `id` readonly signal remains `undefined` until manually set via `set$`.
27
+ *
28
+ * @default false
29
+ */
30
+ shouldInitialize?: boolean;
31
+ }
32
+ /**
33
+ * Represents the object returned by the `useIdManager` hook.
34
+ */
35
+ export interface UseIdManagerReturnValue {
36
+ /**
37
+ * A readonly signal representing the current state of the identifier.
38
+ * This signal is read-only, meaning its value can only be modified by calling
39
+ * specific `QRL` functions like `set$` or `delete$`, ensuring consistent
40
+ * and predictable state updates across the component tree.
41
+ */
42
+ id: ReadonlySignal<string | undefined>;
43
+ /**
44
+ * A `QRL` function that directly sets the identifier to a specific string value.
45
+ * If a non-empty string is provided, it will be used as the new ID.
46
+ * If the provided value is empty or undefined, the function will fall back
47
+ * to the default format, combining the defined prefix and the base ID.
48
+ */
49
+ set$: QRL<(value: string | undefined) => void>;
50
+ /**
51
+ * A `QRL` function that clears the current identifier by setting its value to `undefined`.
52
+ * This is particularly useful for resetting the state during component unmounting
53
+ * or when the identifier is no longer required in the DOM.
54
+ */
55
+ delete$: QRL<() => void>;
56
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './components';
2
+ export * from './hooks';
2
3
  export * from './utilities';
@@ -0,0 +1,10 @@
1
+ import { error as error$1 } from "@entry-ui/utilities/error";
2
+ const error = (messages) => {
3
+ error$1({
4
+ prefix: "[Entry UI Qwik]",
5
+ messages
6
+ });
7
+ };
8
+ export {
9
+ error
10
+ };
@@ -0,0 +1,10 @@
1
+ import { warn as warn$1 } from "@entry-ui/utilities/warn";
2
+ const warn = (messages) => {
3
+ warn$1({
4
+ prefix: "[Entry UI Qwik]",
5
+ messages
6
+ });
7
+ };
8
+ export {
9
+ warn
10
+ };
@@ -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,2 @@
1
+ export type { CollapsibleRootContextValue } from './collapsible-root-context.types';
2
+ export { CollapsibleRootContext, useCollapsibleRootContext } from './collapsible-root-context';
@@ -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,5 @@
1
+ import { createContextId } from "@qwik.dev/core";
2
+ const CollapsibleTriggerContext = createContextId("entry-ui-qwik-collapsible-trigger-context");
3
+ export {
4
+ CollapsibleTriggerContext
5
+ };
@@ -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,2 @@
1
+ export type { CollapsibleTriggerContextValue } from './collapsible-trigger-context.types';
2
+ export { CollapsibleTriggerContext } from './collapsible-trigger-context';
@@ -0,0 +1,2 @@
1
+ export * from './collapsible-root-context';
2
+ export * from './collapsible-trigger-context';
@@ -0,0 +1,2 @@
1
+ export * from './use-collapsible-root-context';
2
+ export * from './use-collapsible-trigger-context';
@@ -0,0 +1,2 @@
1
+ export type { UseCollapsibleRootContextReturnValue } from './use-collapsible-root-context.types';
2
+ export { useCollapsibleRootContext } from './use-collapsible-root-context';
@@ -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,2 @@
1
+ export type { UseCollapsibleTriggerContextReturnValue } from './use-collapsible-trigger-context.types';
2
+ export { useCollapsibleTriggerContext } from './use-collapsible-trigger-context';
@@ -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,2 @@
1
+ export * as Collapsible from './parts';
2
+ export * from './hooks';
@@ -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
+ };
@@ -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
+ }
@@ -0,0 +1,2 @@
1
+ export type { CollapsibleIndicatorProps } from './collapsible-indicator.types';
2
+ export { CollapsibleIndicator } from './collapsible-indicator';
@@ -0,0 +1,7 @@
1
+ import type { CollapsiblePanelProps } from './collapsible-panel.types';
2
+ /**
3
+ * A panel with the collapsible contents.
4
+ *
5
+ * Renders a `<div>` element.
6
+ */
7
+ export declare const CollapsiblePanel: import("@qwik.dev/core").Component<CollapsiblePanelProps>;
@@ -0,0 +1,169 @@
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 = 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" : "0px");
19
+ const preventInitialAnimation = useSignal(true);
20
+ const mergedStyles = useComputed$(() => mergeStyles([
21
+ {
22
+ display: hidden.value ? hiddenUntilFound ? void 0 : "none" : void 0,
23
+ contentVisibility: hidden.value ? hiddenUntilFound ? "hidden" : void 0 : void 0,
24
+ // When using hidden="until-found", the panel automatically opens when a search
25
+ // match occurs. However, Chromium-based browsers (like Chrome) will fail to
26
+ // highlight the matched text if the element has an overflow value other than
27
+ // "visible". Firefox handles this regardless of the overflow setting, but we force
28
+ // visible here to ensure cross-browser consistency for the "Find-in-page" feature.
29
+ overflow: hidden.value ? hiddenUntilFound ? "visible" : void 0 : void 0,
30
+ transitionDuration: preventInitialAnimation.value ? "0s" : void 0,
31
+ animationDuration: preventInitialAnimation.value ? "0s" : void 0,
32
+ "--entry-ui-qwik-collapsible-panel-height": height.value
33
+ },
34
+ style
35
+ ]));
36
+ useLifecycle({
37
+ element: ref,
38
+ onMount$: $(() => panelId.set$(id)),
39
+ onUnmount$: $(() => panelId.delete$())
40
+ });
41
+ useTask$(({ track, cleanup }) => {
42
+ const isOpen = track(() => open.value);
43
+ const panelRef = ref.value;
44
+ if (isBrowser && panelRef) {
45
+ if (preventInitialAnimation.value) {
46
+ preventInitialAnimation.value = false;
47
+ panelRef.style.removeProperty("transition-duration");
48
+ panelRef.style.removeProperty("animation-duration");
49
+ }
50
+ if (isOpen) {
51
+ hidden.value = false;
52
+ panelRef.removeAttribute("hidden");
53
+ if (hiddenUntilFound) {
54
+ panelRef.style.removeProperty("content-visibility");
55
+ panelRef.style.removeProperty("overflow");
56
+ } else {
57
+ panelRef.style.removeProperty("display");
58
+ }
59
+ state.value = "open";
60
+ panelRef.setAttribute("data-state", "open");
61
+ const panelHeight = getHiddenElementHeight(panelRef);
62
+ height.value = `${panelHeight}px`;
63
+ panelRef.style.setProperty("--entry-ui-qwik-collapsible-panel-height", `${panelHeight}px`);
64
+ } else {
65
+ state.value = "closed";
66
+ panelRef.setAttribute("data-state", "closed");
67
+ const { animationDuration: animationDuration2, transitionDuration: transitionDuration2 } = getComputedStyle(panelRef);
68
+ const panelHeight = getHiddenElementHeight(panelRef);
69
+ if (animationDuration2 === "0s" && transitionDuration2 !== "0s") {
70
+ if (height.value === "auto") {
71
+ height.value = `${panelHeight}px`;
72
+ panelRef.style.setProperty("--entry-ui-qwik-collapsible-panel-height", `${panelHeight}px`);
73
+ setTimeout(() => {
74
+ height.value = "0px";
75
+ panelRef.style.setProperty("--entry-ui-qwik-collapsible-panel-height", "0px");
76
+ }, 0);
77
+ } else {
78
+ height.value = "0px";
79
+ panelRef.style.setProperty("--entry-ui-qwik-collapsible-panel-height", "0px");
80
+ }
81
+ } else {
82
+ height.value = `${panelHeight}px`;
83
+ panelRef.style.setProperty("--entry-ui-qwik-collapsible-panel-height", `${panelHeight}px`);
84
+ }
85
+ }
86
+ const applyFinalState = () => {
87
+ if (isOpen) {
88
+ height.value = "auto";
89
+ panelRef.style.setProperty("--entry-ui-qwik-collapsible-panel-height", "auto");
90
+ } else {
91
+ hidden.value = true;
92
+ height.value = "0px";
93
+ panelRef.style.setProperty("--entry-ui-qwik-collapsible-panel-height", "0px");
94
+ }
95
+ if (onOpenChangeComplete$) {
96
+ onOpenChangeComplete$(isOpen);
97
+ }
98
+ };
99
+ const { transitionDuration, animationDuration } = getComputedStyle(panelRef);
100
+ if (isDev && transitionDuration !== "0s" && animationDuration !== "0s") {
101
+ warn([
102
+ `Both CSS transitions and CSS animations are detected on 'Collapsible.Panel' component.`,
103
+ `Using both at the same time may cause unpredictable behavior.`,
104
+ `Please use only one animation method.`
105
+ ]);
106
+ applyFinalState();
107
+ } else if (transitionDuration !== "0s") {
108
+ const removeTransitionEndListener = addEventListenerOnce({
109
+ target: panelRef,
110
+ type: "transitionend",
111
+ listener: applyFinalState
112
+ });
113
+ cleanup(() => {
114
+ removeTransitionEndListener();
115
+ });
116
+ } else if (animationDuration !== "0s") {
117
+ const removeAnimationEndListener = addEventListenerOnce({
118
+ target: panelRef,
119
+ type: "animationend",
120
+ listener: applyFinalState
121
+ });
122
+ cleanup(() => {
123
+ removeAnimationEndListener();
124
+ });
125
+ } else {
126
+ applyFinalState();
127
+ }
128
+ }
129
+ });
130
+ const handleBeforeMatchSync$ = sync$((event) => {
131
+ event.preventDefault();
132
+ });
133
+ const handleBeforeMatch$ = $((_, currentTarget) => {
134
+ setOpen$(true);
135
+ if ("scrollIntoViewIfNeeded" in currentTarget) {
136
+ currentTarget.scrollIntoViewIfNeeded(true);
137
+ } else {
138
+ currentTarget.scrollIntoView({
139
+ behavior: "auto",
140
+ block: "center",
141
+ inline: "nearest"
142
+ });
143
+ }
144
+ });
145
+ return /* @__PURE__ */ jsx(Primitive.div, {
146
+ as,
147
+ ref: mergeRefs([
148
+ _ref,
149
+ ref
150
+ ]),
151
+ id: panelId.id.value,
152
+ hidden: hidden.value ? hiddenUntilFound ? "until-found" : "hidden" : void 0,
153
+ "aria-labelledby": triggerId.id.value,
154
+ "data-entry-ui-qwik-collapsible-panel": "",
155
+ "data-state": state.value,
156
+ "data-disabled": disabled.value ? "" : void 0,
157
+ onBeforematch$: [
158
+ onBeforematch$,
159
+ handleBeforeMatchSync$,
160
+ handleBeforeMatch$
161
+ ],
162
+ style: mergedStyles.value,
163
+ ...others,
164
+ children: /* @__PURE__ */ jsx(Slot, {})
165
+ });
166
+ });
167
+ export {
168
+ CollapsiblePanel
169
+ };
@@ -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';