@entry-ui/qwik 0.2.0 → 0.4.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/components/primitive/primitive.types.d.ts +5 -0
- package/lib/_internal/index.d.ts +1 -0
- package/lib/_internal/utilities/error/error.d.ts +8 -0
- package/lib/_internal/utilities/error/index.d.ts +1 -0
- package/lib/_internal/utilities/fail/fail.d.ts +8 -0
- package/lib/_internal/utilities/fail/fail.qwik.mjs +10 -0
- package/lib/_internal/utilities/fail/index.d.ts +1 -0
- package/lib/_internal/utilities/index.d.ts +3 -0
- package/lib/_internal/utilities/warn/index.d.ts +1 -0
- package/lib/_internal/utilities/warn/warn.d.ts +7 -0
- package/lib/components/alert/index.d.ts +1 -0
- package/lib/components/alert/index.qwik.mjs +4 -0
- package/lib/components/alert/parts/alert-root/alert-root.d.ts +7 -0
- package/lib/components/alert/parts/alert-root/alert-root.qwik.mjs +16 -0
- package/lib/components/alert/parts/alert-root/alert-root.types.d.ts +15 -0
- package/lib/components/alert/parts/alert-root/index.d.ts +2 -0
- package/lib/components/alert/parts/index.d.ts +2 -0
- package/lib/components/alert/parts/index.qwik.mjs +4 -0
- package/lib/components/index.d.ts +1 -0
- package/lib/components/separator/parts/separator-root/separator-root.types.d.ts +4 -0
- package/lib/hooks/index.d.ts +3 -0
- package/lib/hooks/use-boolean/index.d.ts +2 -0
- package/lib/hooks/use-boolean/index.qwik.mjs +4 -0
- package/lib/hooks/use-boolean/use-boolean.d.ts +12 -0
- package/lib/hooks/use-boolean/use-boolean.qwik.mjs +22 -0
- package/lib/hooks/use-boolean/use-boolean.types.d.ts +22 -0
- package/lib/hooks/use-controllable/index.d.ts +2 -0
- package/lib/hooks/use-controllable/index.qwik.mjs +4 -0
- package/lib/hooks/use-controllable/use-controllable.d.ts +14 -0
- package/lib/hooks/use-controllable/use-controllable.qwik.mjs +35 -0
- package/lib/hooks/use-controllable/use-controllable.types.d.ts +52 -0
- package/lib/hooks/use-cycle/index.d.ts +2 -0
- package/lib/hooks/use-cycle/index.qwik.mjs +4 -0
- package/lib/hooks/use-cycle/use-cycle.d.ts +11 -0
- package/lib/hooks/use-cycle/use-cycle.qwik.mjs +54 -0
- package/lib/hooks/use-cycle/use-cycle.types.d.ts +63 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.qwik.mjs +14 -2
- package/lib/utilities/index.d.ts +2 -0
- package/lib/utilities/merge-refs/index.d.ts +2 -0
- package/lib/utilities/merge-refs/index.qwik.mjs +4 -0
- package/lib/utilities/merge-refs/merge-refs.d.ts +15 -0
- package/lib/utilities/merge-refs/merge-refs.qwik.mjs +17 -0
- package/lib/utilities/merge-refs/merge-refs.types.d.ts +14 -0
- package/lib/utilities/merge-styles/index.d.ts +2 -0
- package/lib/utilities/merge-styles/index.qwik.mjs +4 -0
- package/lib/utilities/merge-styles/merge-styles.d.ts +13 -0
- package/lib/utilities/merge-styles/merge-styles.qwik.mjs +7 -0
- package/lib/utilities/merge-styles/merge-styles.types.d.ts +15 -0
- package/package.json +26 -2
|
@@ -4,7 +4,7 @@ import type { Component } from '@qwik.dev/core';
|
|
|
4
4
|
* List of HTML elements that can be created as primitive components.
|
|
5
5
|
* Each node in this array will have a corresponding component in the `Primitive` object.
|
|
6
6
|
*/
|
|
7
|
-
declare const NODES: readonly ["div", "span"];
|
|
7
|
+
declare const NODES: readonly ["button", "div", "span"];
|
|
8
8
|
/**
|
|
9
9
|
* A factory function that creates a polymorphic Qwik component for a specific HTML tag.
|
|
10
10
|
*/
|
|
@@ -20,6 +20,7 @@ export declare const createPrimitive: <Node extends (typeof NODES)[number]>(node
|
|
|
20
20
|
*/
|
|
21
21
|
export declare const Primitive: {
|
|
22
22
|
div: Component<PrimitiveProps<"div">>;
|
|
23
|
+
button: Component<PrimitiveProps<"button">>;
|
|
23
24
|
span: Component<PrimitiveProps<"span">>;
|
|
24
25
|
};
|
|
25
26
|
export {};
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { Component, PropsOf } from '@qwik.dev/core';
|
|
2
|
+
/**
|
|
3
|
+
* Props for polymorphic primitive components.
|
|
4
|
+
* Combines the standard attributes of the specified HTML element (`Node`)
|
|
5
|
+
* with the `as` prop to allow component composition and semantic overrides.
|
|
6
|
+
*/
|
|
2
7
|
export type PrimitiveProps<Node> = {
|
|
3
8
|
/**
|
|
4
9
|
* The element or component this component should render as.
|
package/lib/_internal/index.d.ts
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logs an error message to the console with a standardized `"[Entry UI Qwik]"` prefix.
|
|
3
|
+
*
|
|
4
|
+
* This utility function simplifies error reporting by automatically
|
|
5
|
+
* prepending a consistent prefix to all messages originating
|
|
6
|
+
* from the Entry UI Qwik library.
|
|
7
|
+
*/
|
|
8
|
+
export declare const error: (messages: string[]) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { error } from './error';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throws an error message with a standardized `"[Entry UI Qwik]"` prefix.
|
|
3
|
+
*
|
|
4
|
+
* This utility function simplifies error reporting by automatically
|
|
5
|
+
* prepending a consistent prefix to all messages originating
|
|
6
|
+
* from the Entry UI Qwik library, ensuring immediate execution termination.
|
|
7
|
+
*/
|
|
8
|
+
export declare const fail: (messages: string[]) => never;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { fail } from './fail';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { warn } from './warn';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logs a warning message to the console with a standardized `"[Entry UI Qwik]"` prefix.
|
|
3
|
+
*
|
|
4
|
+
* This utility serves as a wrapper around the core warning function, ensuring that
|
|
5
|
+
* all logs originating from this library are easily identifiable and consistent.
|
|
6
|
+
*/
|
|
7
|
+
export declare const warn: (messages: string[]) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as Alert from './parts';
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
const AlertRoot = component$((props) => {
|
|
5
|
+
const { as = "div", ...others } = props;
|
|
6
|
+
return /* @__PURE__ */ jsx(Primitive.div, {
|
|
7
|
+
as,
|
|
8
|
+
role: "alert",
|
|
9
|
+
"data-entry-ui-qwik-alert-root": "",
|
|
10
|
+
...others,
|
|
11
|
+
children: /* @__PURE__ */ jsx(Slot, {})
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
export {
|
|
15
|
+
AlertRoot
|
|
16
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Component, PropsOf } from '@qwik.dev/core';
|
|
2
|
+
/**
|
|
3
|
+
* Props for the `Alert.Root` component.
|
|
4
|
+
* Extends the standard HTML attributes for a `div` element.
|
|
5
|
+
*/
|
|
6
|
+
export interface AlertRootProps 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
|
+
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { Component, PropsOf } from '@qwik.dev/core';
|
|
2
|
+
/**
|
|
3
|
+
* Props for the `Separator.Root` component.
|
|
4
|
+
* Extends the standard HTML attributes for a `div` element.
|
|
5
|
+
*/
|
|
2
6
|
export interface SeparatorRootProps extends PropsOf<'div'> {
|
|
3
7
|
/**
|
|
4
8
|
* The element or component this component should render as.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { UseBooleanReturnValue } from './use-boolean.types';
|
|
2
|
+
/**
|
|
3
|
+
* A hook that manages a boolean state with common utility methods.
|
|
4
|
+
*
|
|
5
|
+
* The hook accepts a single `initialState` parameter, which defaults to `false`.
|
|
6
|
+
* It simplifies the management of boolean flags (toggles, modals, drawers) by
|
|
7
|
+
* encapsulating a boolean signal and exposing it as a readonly signal.
|
|
8
|
+
*
|
|
9
|
+
* State mutations are performed exclusively through the provided `QRL`
|
|
10
|
+
* functions (`setFalse$` ,`setTrue$`, `toggle$`), promoting a predictable data flow.
|
|
11
|
+
*/
|
|
12
|
+
export declare const useBoolean: (initialState?: boolean) => UseBooleanReturnValue;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useSignal, $ } from "@qwik.dev/core";
|
|
2
|
+
const useBoolean = (initialState = false) => {
|
|
3
|
+
const state = useSignal(initialState);
|
|
4
|
+
const setFalse$ = $(() => {
|
|
5
|
+
state.value = false;
|
|
6
|
+
});
|
|
7
|
+
const setTrue$ = $(() => {
|
|
8
|
+
state.value = true;
|
|
9
|
+
});
|
|
10
|
+
const toggle$ = $(() => {
|
|
11
|
+
state.value = !state.value;
|
|
12
|
+
});
|
|
13
|
+
return {
|
|
14
|
+
state,
|
|
15
|
+
setFalse$,
|
|
16
|
+
setTrue$,
|
|
17
|
+
toggle$
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
useBoolean
|
|
22
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReadonlySignal, QRL } from '@qwik.dev/core';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the object returned by the `useBoolean` hook.
|
|
4
|
+
*/
|
|
5
|
+
export interface UseBooleanReturnValue {
|
|
6
|
+
/**
|
|
7
|
+
* A readonly signal whose value indicates the current boolean state.
|
|
8
|
+
*/
|
|
9
|
+
state: ReadonlySignal<boolean>;
|
|
10
|
+
/**
|
|
11
|
+
* A `QRL` function to set the boolean state to `false`.
|
|
12
|
+
*/
|
|
13
|
+
setFalse$: QRL<() => void>;
|
|
14
|
+
/**
|
|
15
|
+
* A `QRL` function to set the boolean state to `true`.
|
|
16
|
+
*/
|
|
17
|
+
setTrue$: QRL<() => void>;
|
|
18
|
+
/**
|
|
19
|
+
* A `QRL` function to toggle the boolean state.
|
|
20
|
+
*/
|
|
21
|
+
toggle$: QRL<() => void>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { UseControllableParams, UseControllableReturnValue } from './use-controllable.types';
|
|
2
|
+
/**
|
|
3
|
+
* A hook that manages state in either controlled or uncontrolled mode.
|
|
4
|
+
*
|
|
5
|
+
* It provides a unified interface for handling state updates, regardless of whether
|
|
6
|
+
* the data is managed internally or by a parent component. This pattern is essential
|
|
7
|
+
* for building flexible UI components that need to support both "set-and-forget"
|
|
8
|
+
* usage and tight integration with external state.
|
|
9
|
+
*
|
|
10
|
+
* State synchronization is handled automatically:
|
|
11
|
+
* - **Controlled**: Uses the provided `controlledSignal` and requests changes via `onChange$`.
|
|
12
|
+
* - **Uncontrolled**: Manages an internal signal initialized by `defaultValue`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const useControllable: <T>(params?: UseControllableParams<T>) => UseControllableReturnValue<T>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { $, useSignal } from "@qwik.dev/core";
|
|
2
|
+
import { isDev } from "@qwik.dev/core/build";
|
|
3
|
+
import { fail } from "../../_internal/utilities/fail/fail.qwik.mjs";
|
|
4
|
+
const useControllable = (params = {}) => {
|
|
5
|
+
const { defaultValue, controlledSignal, onChange$ } = params;
|
|
6
|
+
if (controlledSignal !== void 0) {
|
|
7
|
+
const handleExternalStateChange$ = $((value) => {
|
|
8
|
+
onChange$?.(value);
|
|
9
|
+
});
|
|
10
|
+
return {
|
|
11
|
+
state: controlledSignal,
|
|
12
|
+
setState$: handleExternalStateChange$,
|
|
13
|
+
controlled: true
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
if (isDev && defaultValue === void 0) {
|
|
17
|
+
fail([
|
|
18
|
+
`The 'defaultValue' parameter in 'useControllable' hook is required when 'controlledSignal' is not provided.`,
|
|
19
|
+
`Either provide a 'defaultValue' for uncontrolled mode, or pass a 'controlledSignal' for controlled mode.`
|
|
20
|
+
]);
|
|
21
|
+
}
|
|
22
|
+
const internalState = useSignal(defaultValue);
|
|
23
|
+
const handleInternalStateChange$ = $((value) => {
|
|
24
|
+
internalState.value = value;
|
|
25
|
+
onChange$?.(value);
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
state: internalState,
|
|
29
|
+
setState$: handleInternalStateChange$,
|
|
30
|
+
controlled: false
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
useControllable
|
|
35
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Signal, QRL, ReadonlySignal } from '@qwik.dev/core';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration parameters for the `useControllable` hook.
|
|
4
|
+
* This interface defines the inputs required to initialize the hook in either
|
|
5
|
+
* controlled or uncontrolled mode, allowing for flexible state management
|
|
6
|
+
* strategies within the same component.
|
|
7
|
+
*/
|
|
8
|
+
export interface UseControllableParams<T> {
|
|
9
|
+
/**
|
|
10
|
+
* The initial value used when the component is in uncontrolled mode.
|
|
11
|
+
* This value is only used to initialize the internal state if `controlledSignal` is not provided.
|
|
12
|
+
*/
|
|
13
|
+
defaultValue?: T;
|
|
14
|
+
/**
|
|
15
|
+
* An optional external signal for controlled state management.
|
|
16
|
+
* If provided, the hook operates in controlled mode, delegating state authority to the parent.
|
|
17
|
+
* If omitted, the hook operates in uncontrolled mode using internal state.
|
|
18
|
+
*/
|
|
19
|
+
controlledSignal?: Signal<T>;
|
|
20
|
+
/**
|
|
21
|
+
* An optional `QRL` callback invoked whenever the state value changes.
|
|
22
|
+
* In controlled mode, it notifies the parent to update the external signal.
|
|
23
|
+
* In uncontrolled mode, it acts as a listener for internal state changes.
|
|
24
|
+
*/
|
|
25
|
+
onChange$?: QRL<(value: T) => void>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The stable interface returned by the `useControllable` hook.
|
|
29
|
+
* It provides a unified way to access the current state and perform updates,
|
|
30
|
+
* abstracting away the complexity of switching between controlled and
|
|
31
|
+
* uncontrolled internal logic.
|
|
32
|
+
*/
|
|
33
|
+
export interface UseControllableReturnValue<T> {
|
|
34
|
+
/**
|
|
35
|
+
* A readonly signal representing the current state.
|
|
36
|
+
* Provides the value from the `controlledSignal` in controlled mode,
|
|
37
|
+
* or the internal signal in uncontrolled mode.
|
|
38
|
+
*/
|
|
39
|
+
state: ReadonlySignal<T>;
|
|
40
|
+
/**
|
|
41
|
+
* A `QRL` function to update the state.
|
|
42
|
+
* In controlled mode, it triggers `onChange$` to request a change from the parent.
|
|
43
|
+
* In uncontrolled mode, it updates the internal signal and then invokes `onChange$`.
|
|
44
|
+
*/
|
|
45
|
+
setState$: QRL<(value: T) => void>;
|
|
46
|
+
/**
|
|
47
|
+
* A boolean flag indicating the current management mode.
|
|
48
|
+
* Returns `true` if the state is managed externally via `controlledSignal`,
|
|
49
|
+
* and `false` if managed internally.
|
|
50
|
+
*/
|
|
51
|
+
controlled: boolean;
|
|
52
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { UseCycleParams, UseCycleReturnValue } from './use-cycle.types';
|
|
2
|
+
/**
|
|
3
|
+
* A hook that manages navigation through a predefined sequence of options.
|
|
4
|
+
*
|
|
5
|
+
* This hook provides a robust way to handle multi-state logic by rotating through an array of values.
|
|
6
|
+
* It features advanced navigation controls, allowing for forward and backward movement,
|
|
7
|
+
* direct jumps to the start or end of the sequence, and configurable looping behavior.
|
|
8
|
+
* It is particularly useful for building components such as carousels, steppers,
|
|
9
|
+
* multi-state switches, or any UI element requiring sequential state transitions.
|
|
10
|
+
*/
|
|
11
|
+
export declare const useCycle: <T>(params: UseCycleParams<T>) => UseCycleReturnValue<T>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { useSignal, $ } from "@qwik.dev/core";
|
|
2
|
+
const useCycle = (params) => {
|
|
3
|
+
const { options, defaultOption, loop = true } = params;
|
|
4
|
+
const option = useSignal(() => {
|
|
5
|
+
if (defaultOption !== void 0 && options.includes(defaultOption)) {
|
|
6
|
+
return defaultOption;
|
|
7
|
+
}
|
|
8
|
+
return options[0];
|
|
9
|
+
});
|
|
10
|
+
const next$ = $(() => {
|
|
11
|
+
const currentIndex = options.indexOf(option.value);
|
|
12
|
+
const nextIndex = currentIndex + 1;
|
|
13
|
+
if (loop) {
|
|
14
|
+
option.value = options[nextIndex % options.length];
|
|
15
|
+
} else {
|
|
16
|
+
if (nextIndex < options.length) {
|
|
17
|
+
option.value = options[nextIndex];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
const previous$ = $(() => {
|
|
22
|
+
const currentIndex = options.indexOf(option.value);
|
|
23
|
+
const prevIndex = currentIndex - 1;
|
|
24
|
+
if (loop) {
|
|
25
|
+
option.value = options[(prevIndex + options.length) % options.length];
|
|
26
|
+
} else {
|
|
27
|
+
if (prevIndex >= 0) {
|
|
28
|
+
option.value = options[prevIndex];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const first$ = $(() => {
|
|
33
|
+
option.value = options[0];
|
|
34
|
+
});
|
|
35
|
+
const last$ = $(() => {
|
|
36
|
+
option.value = options[options.length - 1];
|
|
37
|
+
});
|
|
38
|
+
const set$ = $((value) => {
|
|
39
|
+
if (options.includes(value)) {
|
|
40
|
+
option.value = value;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
option,
|
|
45
|
+
next$,
|
|
46
|
+
previous$,
|
|
47
|
+
first$,
|
|
48
|
+
last$,
|
|
49
|
+
set$
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export {
|
|
53
|
+
useCycle
|
|
54
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ReadonlySignal, QRL } from '@qwik.dev/core';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration parameters for the `useCycle` hook.
|
|
4
|
+
*/
|
|
5
|
+
export interface UseCycleParams<T> {
|
|
6
|
+
/**
|
|
7
|
+
* A readonly array of values to cycle through.
|
|
8
|
+
* This defines the sequence and the scope of all possible states the hook can manage.
|
|
9
|
+
*/
|
|
10
|
+
options: readonly T[];
|
|
11
|
+
/**
|
|
12
|
+
* The initial value to be set when the hook is first initialized.
|
|
13
|
+
* If provided, it must be present in the `options` array.
|
|
14
|
+
* If the provided value is not found within the `options` array,
|
|
15
|
+
* the hook will fall back to the first element of the array.
|
|
16
|
+
*
|
|
17
|
+
* @default options[0]
|
|
18
|
+
*/
|
|
19
|
+
defaultOption?: T;
|
|
20
|
+
/**
|
|
21
|
+
* Determines the behavior when navigating past the boundaries of the `options` array.
|
|
22
|
+
* If set to `true`, the sequence will wrap around (e.g., from last to first).
|
|
23
|
+
* If `false`, navigation will stop at the first or last element.
|
|
24
|
+
*
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
loop?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Represents the object returned by the `useCycle` hook.
|
|
31
|
+
*/
|
|
32
|
+
export interface UseCycleReturnValue<T> {
|
|
33
|
+
/**
|
|
34
|
+
* A readonly signal whose value represents the currently active option from the provided array.
|
|
35
|
+
* This signal is read-only, which means its value can only be changed by calling navigation `QRL` functions
|
|
36
|
+
* like `next$`, `previous$`, or `set$`, ensuring predictable state transitions.
|
|
37
|
+
*/
|
|
38
|
+
option: ReadonlySignal<T>;
|
|
39
|
+
/**
|
|
40
|
+
* A `QRL` function that advances the value to the next option in the sequence.
|
|
41
|
+
* If `loop` is enabled, it cycles back to the first item upon reaching the end.
|
|
42
|
+
*/
|
|
43
|
+
next$: QRL<() => void>;
|
|
44
|
+
/**
|
|
45
|
+
* A `QRL` function that moves the value to the previous option in the sequence.
|
|
46
|
+
* If `loop` is enabled, it cycles back to the last item upon reaching the start.
|
|
47
|
+
*/
|
|
48
|
+
previous$: QRL<() => void>;
|
|
49
|
+
/**
|
|
50
|
+
* A `QRL` function that jumps directly to the first item in the `options` array.
|
|
51
|
+
*/
|
|
52
|
+
first$: QRL<() => void>;
|
|
53
|
+
/**
|
|
54
|
+
* A `QRL` function that jumps directly to the last item in the `options` array.
|
|
55
|
+
*/
|
|
56
|
+
last$: QRL<() => void>;
|
|
57
|
+
/**
|
|
58
|
+
* A `QRL` function that directly sets the `option` to a new value.
|
|
59
|
+
* This function includes a built-in validation check; the value will only be updated
|
|
60
|
+
* if it is present in the original `options` array.
|
|
61
|
+
*/
|
|
62
|
+
set$: QRL<(value: T) => void>;
|
|
63
|
+
}
|
package/lib/index.d.ts
CHANGED
package/lib/index.qwik.mjs
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
import * as index from "./components/
|
|
1
|
+
import * as index from "./components/alert/parts/index.qwik.mjs";
|
|
2
|
+
import * as index$1 from "./components/separator/parts/index.qwik.mjs";
|
|
3
|
+
import { useBoolean } from "./hooks/use-boolean/use-boolean.qwik.mjs";
|
|
4
|
+
import { useControllable } from "./hooks/use-controllable/use-controllable.qwik.mjs";
|
|
5
|
+
import { useCycle } from "./hooks/use-cycle/use-cycle.qwik.mjs";
|
|
6
|
+
import { mergeRefs } from "./utilities/merge-refs/merge-refs.qwik.mjs";
|
|
7
|
+
import { mergeStyles } from "./utilities/merge-styles/merge-styles.qwik.mjs";
|
|
2
8
|
export {
|
|
3
|
-
index as
|
|
9
|
+
index as Alert,
|
|
10
|
+
index$1 as Separator,
|
|
11
|
+
mergeRefs,
|
|
12
|
+
mergeStyles,
|
|
13
|
+
useBoolean,
|
|
14
|
+
useControllable,
|
|
15
|
+
useCycle
|
|
4
16
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PossibleRef } from './merge-refs.types';
|
|
2
|
+
/**
|
|
3
|
+
* Combines multiple references into a single callback ref.
|
|
4
|
+
*
|
|
5
|
+
* This utility function allows you to assign a single DOM element to multiple
|
|
6
|
+
* reference handlers (both Qwik Signals and callback functions). It is particularly
|
|
7
|
+
* useful when a component needs to maintain its own internal reference to an element
|
|
8
|
+
* while also forwarding a reference to a consumer via props.
|
|
9
|
+
*
|
|
10
|
+
* When the returned callback is executed, it iterates through all provided refs and:
|
|
11
|
+
* - Updates the `.value` property if the ref is a `Signal`.
|
|
12
|
+
* - Invokes the function if the `ref` is a callback.
|
|
13
|
+
* - Gracefully ignores `undefined` values.
|
|
14
|
+
*/
|
|
15
|
+
export declare const mergeRefs: <T extends Element>(refs: PossibleRef<T>[]) => import("@qwik.dev/core").QRL<(node: T) => void>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { noSerialize, $, isSignal } from "@qwik.dev/core";
|
|
2
|
+
const mergeRefs = (refs) => {
|
|
3
|
+
const _refs = noSerialize(refs);
|
|
4
|
+
return $((node) => {
|
|
5
|
+
_refs?.forEach((ref) => {
|
|
6
|
+
if (!ref) return;
|
|
7
|
+
if (isSignal(ref)) {
|
|
8
|
+
ref.value = node;
|
|
9
|
+
} else if (typeof ref === "function") {
|
|
10
|
+
ref(node);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
mergeRefs
|
|
17
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Signal } from '@qwik.dev/core';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the various ways a reference can be assigned to a DOM element in Qwik.
|
|
4
|
+
*
|
|
5
|
+
* This type provides flexibility for handling references, supporting:
|
|
6
|
+
*
|
|
7
|
+
* - `Signal<T | undefined>` or `Signal<Element | undefined>`: The standard Qwik approach using `useSignal`.
|
|
8
|
+
* It allows the element to be reactively tracked within the `.value` property.
|
|
9
|
+
*
|
|
10
|
+
* - `(node: T) => void`: A callback ref (ref-callback) that provides direct access to the DOM node upon mounting.
|
|
11
|
+
*
|
|
12
|
+
* - `undefined`: Designed for optional references. This allows you to pass component props directly into the utility without manual null-checks.
|
|
13
|
+
*/
|
|
14
|
+
export type PossibleRef<T> = Signal<Element | undefined> | Signal<T | undefined> | ((node: T) => void) | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PossibleStyle } from './merge-styles.types';
|
|
2
|
+
import type { CSSProperties } from '@qwik.dev/core';
|
|
3
|
+
/**
|
|
4
|
+
* Merges multiple style values into a single, unified style object.
|
|
5
|
+
*
|
|
6
|
+
* This function consolidates a variety of style formats (inline strings, CSS objects,
|
|
7
|
+
* or undefined) into a single `CSSProperties` object. It ensures that all property
|
|
8
|
+
* keys are normalized to camelCase (preserving CSS variables and handling vendor
|
|
9
|
+
* prefixes appropriately) to remain compatible with JavaScript-based styling engines.
|
|
10
|
+
* The merging process follows the CSS cascade principle: styles appearing later in
|
|
11
|
+
* the array will override matching properties from earlier styles.
|
|
12
|
+
*/
|
|
13
|
+
export declare const mergeStyles: (styles: PossibleStyle[]) => CSSProperties;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CSSProperties } from '@qwik.dev/core';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the accepted formats for style declarations.
|
|
4
|
+
*
|
|
5
|
+
* This type allows for flexibility in how styles are defined, supporting:
|
|
6
|
+
*
|
|
7
|
+
* - `string`: Standard inline CSS strings (e.g., `"color: red; padding: 10px"`).
|
|
8
|
+
*
|
|
9
|
+
* - `CSSProperties`: A structured object of CSS declarations (e.g., `{ color: 'red' }`).
|
|
10
|
+
*
|
|
11
|
+
* - `undefined`: Useful for conditional styling where a style might not be present.
|
|
12
|
+
* Since `boolean` is not accepted, use ternary operators or logical OR
|
|
13
|
+
* to ensure a valid type (e.g., `isActive ? "color: red" : undefined`).
|
|
14
|
+
*/
|
|
15
|
+
export type PossibleStyle = string | CSSProperties | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entry-ui/qwik",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://github.com/ZAHON/entry-ui#readme",
|
|
@@ -15,9 +15,33 @@
|
|
|
15
15
|
"types": "./lib/index.d.ts",
|
|
16
16
|
"import": "./lib/index.qwik.mjs"
|
|
17
17
|
},
|
|
18
|
+
"./alert": {
|
|
19
|
+
"types": "./lib/components/alert/index.d.ts",
|
|
20
|
+
"import": "./lib/components/alert/index.qwik.mjs"
|
|
21
|
+
},
|
|
18
22
|
"./separator": {
|
|
19
23
|
"types": "./lib/components/separator/index.d.ts",
|
|
20
24
|
"import": "./lib/components/separator/index.qwik.mjs"
|
|
25
|
+
},
|
|
26
|
+
"./use-boolean": {
|
|
27
|
+
"types": "./lib/hooks/use-boolean/index.d.ts",
|
|
28
|
+
"import": "./lib/hooks/use-boolean/index.qwik.mjs"
|
|
29
|
+
},
|
|
30
|
+
"./use-controllable": {
|
|
31
|
+
"types": "./lib/hooks/use-controllable/index.d.ts",
|
|
32
|
+
"import": "./lib/hooks/use-controllable/index.qwik.mjs"
|
|
33
|
+
},
|
|
34
|
+
"./use-cycle": {
|
|
35
|
+
"types": "./lib/hooks/use-cycle/index.d.ts",
|
|
36
|
+
"import": "./lib/hooks/use-cycle/index.qwik.mjs"
|
|
37
|
+
},
|
|
38
|
+
"./merge-refs": {
|
|
39
|
+
"types": "./lib/utilities/merge-refs/index.d.ts",
|
|
40
|
+
"import": "./lib/utilities/merge-refs/index.qwik.mjs"
|
|
41
|
+
},
|
|
42
|
+
"./merge-styles": {
|
|
43
|
+
"types": "./lib/utilities/merge-styles/index.d.ts",
|
|
44
|
+
"import": "./lib/utilities/merge-styles/index.qwik.mjs"
|
|
21
45
|
}
|
|
22
46
|
},
|
|
23
47
|
"files": [
|
|
@@ -57,7 +81,7 @@
|
|
|
57
81
|
"qwik": "qwik"
|
|
58
82
|
},
|
|
59
83
|
"dependencies": {
|
|
60
|
-
"@entry-ui/utilities": "
|
|
84
|
+
"@entry-ui/utilities": "^0.2.0"
|
|
61
85
|
},
|
|
62
86
|
"devDependencies": {
|
|
63
87
|
"@entry-ui/eslint": "workspace:*",
|