@phila/phila-ui-core 2.4.0 → 3.0.0-beta.3
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/README.md +105 -0
- package/dist/index.d.ts +98 -54
- package/dist/index.js +1 -1
- package/dist/index.mjs +220 -171
- package/dist/styles/utilities/containers.css +3 -0
- package/dist/styles/utilities/text.css +7 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -148,6 +148,111 @@ Essential spacing scale: `2`, `4`, `6` (0.5rem, 1rem, 1.5rem)
|
|
|
148
148
|
|
|
149
149
|
- **Sizes**: base, md
|
|
150
150
|
|
|
151
|
+
### Core Components
|
|
152
|
+
|
|
153
|
+
#### FocusTrap
|
|
154
|
+
|
|
155
|
+
A component that traps focus within its children, ensuring accessibility for modals and dropdowns. It handles keyboard navigation. Optionally, allows escaping to fire custom events when focus leaves.
|
|
156
|
+
|
|
157
|
+
##### Basic Usage
|
|
158
|
+
|
|
159
|
+
```html
|
|
160
|
+
<script lang="ts" setup>
|
|
161
|
+
import { FocusTrap } from "@phila/phila-ui-core";
|
|
162
|
+
</script>
|
|
163
|
+
<template>
|
|
164
|
+
<FocusTrap>
|
|
165
|
+
<div>
|
|
166
|
+
<p>This content is focus-trapped. Press Tab to navigate within this area.</p>
|
|
167
|
+
<button>Button 1</button>
|
|
168
|
+
<button>Button 2</button>
|
|
169
|
+
</div>
|
|
170
|
+
</FocusTrap>
|
|
171
|
+
</template>
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
- When the `FocusTrap` component is mounted, it automatically focuses the first focusable element within its children. If no focusable elements are found, it focuses itself.
|
|
175
|
+
- The component listens for `keydown` events to manage focus. Pressing the Tab key will cycle through the focusable elements within the trap. If the user tries to tab out of the trap, it will loop back to the beginning or end of the focusable elements, depending on the direction of the tabbing.
|
|
176
|
+
- `Shift + Tab` will move focus backward, while `Tab` alone will move focus forward.
|
|
177
|
+
- `PageUp` moves focus to the first focusable element, and `PageDown` moves focus to the last focusable element.
|
|
178
|
+
|
|
179
|
+
| Prop | Type | Description |
|
|
180
|
+
| --------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
181
|
+
| `initialFocusElement` | `string` | An ID of the element to focus initially when the trap is activated. If the element is not focusable (like a div, heading, span, etc.), the element will be given a temporary `tabindex` of 0 to make initially focusable. |
|
|
182
|
+
| `arrowNavigation` | `boolean` | If true, the component will also listen for ArrowUp and ArrowDown keys to navigate through focusable elements. |
|
|
183
|
+
| `allowEscape` | `boolean` | If true, tabbing outside of the focus trap and focusing on an external element will be allowed. An `escape` event will be emitted that can be listened to by the parent component. Useful for closing navbar menus when using keyboard navigation. |
|
|
184
|
+
| `as` | `string` | The HTML element to render as the wrapper for the focus trap. Defaults to `span`. |
|
|
185
|
+
|
|
186
|
+
### Composables
|
|
187
|
+
|
|
188
|
+
#### useVisibility
|
|
189
|
+
|
|
190
|
+
A composable for managing visibility state of components, such as dropdowns and modals. It provides methods to toggle visibility and handles hover interactions.
|
|
191
|
+
|
|
192
|
+
##### Basic Usage
|
|
193
|
+
|
|
194
|
+
```html
|
|
195
|
+
<script lang="ts" setup>
|
|
196
|
+
// Manage visibility state of a single element
|
|
197
|
+
import { useVisibility } from "@phila/phila-ui-core";
|
|
198
|
+
const { isVisible, toggleProps } = useVisibility({
|
|
199
|
+
id: "my-component",
|
|
200
|
+
group: "my-group", //optional, defaults to "global"
|
|
201
|
+
outsideClickHide: true, //optional, defaults to false.
|
|
202
|
+
});
|
|
203
|
+
</script>
|
|
204
|
+
<template>
|
|
205
|
+
<button v-bind="toggleProps">Toggle Visibility</button>
|
|
206
|
+
<div v-if="isVisible">This content is visible when the button is toggled.</div>
|
|
207
|
+
</template>
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
- Including an Id prop when calling useVisibility will initilize the visibility state using that ID.
|
|
211
|
+
- Whenever useVisibility is called with the same ID/group, any settings that are defined will be applied to its visibility state.
|
|
212
|
+
- Toggle props includes the required `data-toggle` attribute with the appropriate ID (`visbility-${id}`) and an optional click handler, though you can import `setVisiblity` from the composable and create your own.
|
|
213
|
+
|
|
214
|
+
```html
|
|
215
|
+
// Accessing visility state across components
|
|
216
|
+
<script lang="ts" setup>
|
|
217
|
+
import { useVisibility } from "@phila/phila-ui-core";
|
|
218
|
+
const { isVisible, setVisibility } = useVisibility({
|
|
219
|
+
group: "my-group",
|
|
220
|
+
});
|
|
221
|
+
const visible = computed(() => isVisible("my-component"));
|
|
222
|
+
const toggleVisibilityExternally = () => {
|
|
223
|
+
setVisibility(!visible.value, "my-component");
|
|
224
|
+
};
|
|
225
|
+
</script>
|
|
226
|
+
<template>
|
|
227
|
+
<button @click="toggleVisibilityExternally">{{ visible ? "Close" : "Open" }} Component</button>
|
|
228
|
+
</template>
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
##### useVisibility options
|
|
232
|
+
|
|
233
|
+
| Option | Type | Default | Description |
|
|
234
|
+
| ------------------ | ------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
235
|
+
| `id` | string | `undefined` | Unique identifier for the visibility state of a component. |
|
|
236
|
+
| `group` | string | `global` | Grouping mechanism for visibility states. Components with the same group will share visibility state. |
|
|
237
|
+
| `blurHide` | boolean | `false` | If true, visbility will be set to false when the component (including focusable children) and its toggle loses focus. |
|
|
238
|
+
| `showSingle` | boolean | `false` | If true, only one component in the same group can be visible at a time. When a component's visibility is set to true, all other components in the same group will have their visibility set to false. |
|
|
239
|
+
| `mouseOverToggle` | boolean | `false` | If true, the exported onMouseEnter and onMouseLeave event handlers will set visibility to true and false, respectively. These event handlers can be applied to a wrapper element to listen for `@onmouseenter` or `@onmouseleave` events. |
|
|
240
|
+
| `outsideClickHide` | boolean | `false` | If true, clicking outside of the component will set its visibility to false. |
|
|
241
|
+
| `escapeKeyHide` | boolean | `false` | If true, pressing the Escape key will set visibility to false. |
|
|
242
|
+
| `visibleOnMount` | boolean | `false` | If true, the component will be visible when it mounts. |
|
|
243
|
+
|
|
244
|
+
##### useVisiblity methods
|
|
245
|
+
|
|
246
|
+
| Method | Type | Description |
|
|
247
|
+
| ----------------- | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
248
|
+
| `isVisible` | `(id?: string) => boolean` | A function that takes an optional ID and returns the visibility state (boolean) of the component. If an ID is provided, it returns the visibility state of the component with that ID. If no ID is provided, it returns the visibility state of the component that called the `useVisibility` hook. If no ID was provided when useVisiblity was called, and no ID is provided to isVisiblle, the default ID and group will be used: id: `default-item`, group: `global`. |
|
|
249
|
+
| `setVisibility` | `(visible: boolean, id?: string) => void` | A function that takes a boolean value and an optional ID to set the initial visibility state and sets up click and mouse event listeners for that component. If an ID is provided, it sets the visibility state of the component with that ID. If no ID is provided, it sets the visibility state of the component that called the `useVisibility` hook. If no ID was provided when useVisiblity was called, and no ID is provided to setVisiblity, the default ID and group will be used: id: `default-item`, group: `global`. |
|
|
250
|
+
| `create` | `(id: string) => void` | A function that takes an ID and initializes a new visibility state for the component with that ID. This is called automatically when ID is provided to useVisibility. |
|
|
251
|
+
| `setState` | `(id: string, visible: boolean) => void` | A function that takes an ID and a visible value to manually set the visibility state for a component. `showSingle` rules are preserved, but no event handlers are added/removed. |
|
|
252
|
+
| `onMouseEnter` | `() => void` | An event handler that sets visibility to true when the mouse enters the component. This is only added if the `mouseOverToggle` option is set to true. |
|
|
253
|
+
| `onMouseLeave` | `() => void` | An event handler that sets visibility to false when the mouse leaves the component. This is only added if the `mouseOverToggle` option is set to true. |
|
|
254
|
+
| `visibilityState` | `VisibilityState` | An object that contains the visibility state for all components, organized by group and ID. This is useful for debugging or advanced use cases where you need to access the visibility state of multiple components. |
|
|
255
|
+
|
|
151
256
|
## TypeScript Support
|
|
152
257
|
|
|
153
258
|
The package includes TypeScript definitions for all utilities and design tokens.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ButtonHTMLAttributes } from 'vue';
|
|
2
1
|
import { ComponentOptionsMixin } from 'vue';
|
|
3
2
|
import { ComponentProvideOptions } from 'vue';
|
|
4
3
|
import { ComputedRef } from 'vue';
|
|
@@ -57,6 +56,12 @@ iconSize: ComponentSize;
|
|
|
57
56
|
|
|
58
57
|
declare const __VLS_component_4: DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, PublicProps>;
|
|
59
58
|
|
|
59
|
+
declare const __VLS_component_5: DefineComponent<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_5<FocusTrapProps>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
60
|
+
escape: () => void;
|
|
61
|
+
}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_5<FocusTrapProps>>> & Readonly<{
|
|
62
|
+
onEscape?: (() => any) | undefined;
|
|
63
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
64
|
+
|
|
60
65
|
declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
61
66
|
|
|
62
67
|
declare type __VLS_NonUndefinedable_2<T> = T extends undefined ? never : T;
|
|
@@ -65,6 +70,8 @@ declare type __VLS_NonUndefinedable_3<T> = T extends undefined ? never : T;
|
|
|
65
70
|
|
|
66
71
|
declare type __VLS_NonUndefinedable_4<T> = T extends undefined ? never : T;
|
|
67
72
|
|
|
73
|
+
declare type __VLS_NonUndefinedable_5<T> = T extends undefined ? never : T;
|
|
74
|
+
|
|
68
75
|
declare type __VLS_Prettify<T> = {
|
|
69
76
|
[K in keyof T]: T[K];
|
|
70
77
|
} & {};
|
|
@@ -94,6 +101,10 @@ declare function __VLS_template_4(): {
|
|
|
94
101
|
default?(_: {}): any;
|
|
95
102
|
};
|
|
96
103
|
|
|
104
|
+
declare function __VLS_template_5(): {
|
|
105
|
+
default?(_: {}): any;
|
|
106
|
+
};
|
|
107
|
+
|
|
97
108
|
declare type __VLS_TypePropsToRuntimeProps<T> = {
|
|
98
109
|
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
99
110
|
type: PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
@@ -130,6 +141,15 @@ declare type __VLS_TypePropsToRuntimeProps_4<T> = {
|
|
|
130
141
|
};
|
|
131
142
|
};
|
|
132
143
|
|
|
144
|
+
declare type __VLS_TypePropsToRuntimeProps_5<T> = {
|
|
145
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
146
|
+
type: PropType<__VLS_NonUndefinedable_5<T[K]>>;
|
|
147
|
+
} : {
|
|
148
|
+
type: PropType<T[K]>;
|
|
149
|
+
required: true;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
|
|
133
153
|
declare type __VLS_WithDefaults<P, D> = {
|
|
134
154
|
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
135
155
|
default: D[K];
|
|
@@ -160,6 +180,12 @@ declare type __VLS_WithTemplateSlots_4<T, S> = T & {
|
|
|
160
180
|
};
|
|
161
181
|
};
|
|
162
182
|
|
|
183
|
+
declare type __VLS_WithTemplateSlots_5<T, S> = T & {
|
|
184
|
+
new (): {
|
|
185
|
+
$slots: S;
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
|
|
163
189
|
/** Accessible icon with required label for screen readers */
|
|
164
190
|
declare type AccessibleIconProps = {
|
|
165
191
|
/** Icon is not decorative */
|
|
@@ -213,14 +239,6 @@ export declare interface BaseProps {
|
|
|
213
239
|
*/
|
|
214
240
|
export declare function cn(...inputs: (string | undefined | null | false)[]): string;
|
|
215
241
|
|
|
216
|
-
export declare interface CollapseItems {
|
|
217
|
-
[id: string]: boolean;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export declare interface CollapseState {
|
|
221
|
-
[group: string]: CollapseItems;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
242
|
export declare type ComponentSize = "extra-large" | "large" | "medium" | "small" | "extra-small" | "xxsmall";
|
|
225
243
|
|
|
226
244
|
export declare function debounce<T extends (...args: unknown[]) => void>(callback: T, wait: number): (...args: Parameters<T>) => void;
|
|
@@ -235,6 +253,19 @@ declare type DecorativeIconProps = {
|
|
|
235
253
|
|
|
236
254
|
export declare const ErrorList: DefineComponent<ExtractPropTypes<__VLS_TypePropsToRuntimeProps<ValidationProps>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps<ValidationProps>>> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
237
255
|
|
|
256
|
+
export declare const FocusTrap: __VLS_WithTemplateSlots_5<typeof __VLS_component_5, ReturnType<typeof __VLS_template_5>>;
|
|
257
|
+
|
|
258
|
+
export declare interface FocusTrapEmits {
|
|
259
|
+
(e: "escape"): void;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export declare interface FocusTrapProps {
|
|
263
|
+
initialFocusElement?: string;
|
|
264
|
+
arrowNavigation?: boolean;
|
|
265
|
+
allowEscape?: boolean;
|
|
266
|
+
as?: string;
|
|
267
|
+
}
|
|
268
|
+
|
|
238
269
|
export declare function generateRandomId(prefix?: string): string;
|
|
239
270
|
|
|
240
271
|
export declare interface HtmlLinkProps extends BaseLinkBaseProps {
|
|
@@ -298,74 +329,75 @@ export declare interface RouterLinkProps extends BaseLinkBaseProps {
|
|
|
298
329
|
rel?: never;
|
|
299
330
|
}
|
|
300
331
|
|
|
301
|
-
export declare function
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
332
|
+
export declare function useInput(): {
|
|
333
|
+
inputValue: Ref<string, string>;
|
|
334
|
+
setInputValue: (value: string) => void;
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
export declare function useRouter(): {
|
|
338
|
+
router: unknown;
|
|
339
|
+
hasRouter: ComputedRef<boolean>;
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
export declare function useValidation(props?: ValidationProps_2, emit?: ReturnType<typeof defineEmits_2>): {
|
|
343
|
+
init: () => void;
|
|
344
|
+
validation: () => void;
|
|
345
|
+
isValid: ComputedRef<boolean>;
|
|
346
|
+
errors: ComputedRef<string[]>;
|
|
315
347
|
};
|
|
316
348
|
|
|
317
|
-
export declare
|
|
349
|
+
export declare function useVisibility(props: UseVisibilityProps): {
|
|
350
|
+
visibilityState: VisibilityState;
|
|
351
|
+
create: (id: string) => void;
|
|
352
|
+
setState: (id: string, visible: boolean) => void;
|
|
353
|
+
isVisible: (id?: string) => boolean;
|
|
354
|
+
onMouseEnter: (id?: string) => void;
|
|
355
|
+
onMouseLeave: (id?: string) => void;
|
|
356
|
+
setVisibility: (visible?: boolean, id?: string) => void;
|
|
357
|
+
toggleProps: ComputedRef< {
|
|
358
|
+
"data-toggle"?: undefined;
|
|
359
|
+
onclick?: undefined;
|
|
360
|
+
} | {
|
|
361
|
+
"data-toggle": string;
|
|
362
|
+
onclick: () => void;
|
|
363
|
+
}>;
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
export declare interface UseVisibilityProps {
|
|
318
367
|
/**
|
|
319
368
|
* Unique identifier for the panel
|
|
320
369
|
*/
|
|
321
|
-
id
|
|
370
|
+
id?: string;
|
|
322
371
|
/**
|
|
323
|
-
* Group identifier to group multiple
|
|
372
|
+
* Group identifier to group multiple elements together
|
|
324
373
|
*/
|
|
325
374
|
group?: string;
|
|
326
375
|
/**
|
|
327
|
-
*
|
|
376
|
+
* Hide element when focus is lost on toggle and itself
|
|
328
377
|
*/
|
|
329
|
-
|
|
378
|
+
blurHide?: boolean;
|
|
330
379
|
/**
|
|
331
|
-
*
|
|
380
|
+
* Hide all others in group when opened
|
|
332
381
|
*/
|
|
333
|
-
|
|
382
|
+
showSingle?: boolean;
|
|
334
383
|
/**
|
|
335
|
-
* Toggle
|
|
384
|
+
* Toggle visibility on mouse over
|
|
336
385
|
*/
|
|
337
386
|
mouseOverToggle?: boolean;
|
|
338
387
|
/**
|
|
339
|
-
*
|
|
388
|
+
* Hide element when clicking outside of it and the toggle
|
|
340
389
|
*/
|
|
341
|
-
|
|
390
|
+
outsideClickHide?: boolean;
|
|
342
391
|
/**
|
|
343
|
-
*
|
|
392
|
+
* Hide element when escape key is pressed
|
|
344
393
|
*/
|
|
345
|
-
|
|
394
|
+
escapeKeyHide?: boolean;
|
|
346
395
|
/**
|
|
347
|
-
*
|
|
396
|
+
* sets the item (id) as visibile when the modal is mounted
|
|
348
397
|
*/
|
|
349
|
-
|
|
398
|
+
visibleOnMount?: boolean;
|
|
350
399
|
}
|
|
351
400
|
|
|
352
|
-
export declare function useInput(): {
|
|
353
|
-
inputValue: Ref<string, string>;
|
|
354
|
-
setInputValue: (value: string) => void;
|
|
355
|
-
};
|
|
356
|
-
|
|
357
|
-
export declare function useRouter(): {
|
|
358
|
-
router: unknown;
|
|
359
|
-
hasRouter: ComputedRef<boolean>;
|
|
360
|
-
};
|
|
361
|
-
|
|
362
|
-
export declare function useValidation(props?: ValidationProps_2, emit?: ReturnType<typeof defineEmits_2>): {
|
|
363
|
-
init: () => void;
|
|
364
|
-
validation: () => void;
|
|
365
|
-
isValid: ComputedRef<boolean>;
|
|
366
|
-
errors: ComputedRef<string[]>;
|
|
367
|
-
};
|
|
368
|
-
|
|
369
401
|
export declare interface ValidationProps {
|
|
370
402
|
errors?: string[];
|
|
371
403
|
validateOnBlur?: boolean;
|
|
@@ -386,4 +418,16 @@ declare interface ValidationProps_2 {
|
|
|
386
418
|
required?: boolean;
|
|
387
419
|
}
|
|
388
420
|
|
|
421
|
+
export declare type VisibilityItem = UseVisibilityProps & {
|
|
422
|
+
visible: boolean;
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
export declare interface VisibilityItems {
|
|
426
|
+
[id: string]: VisibilityItem;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
export declare interface VisibilityState {
|
|
430
|
+
[group: string]: VisibilityItems;
|
|
431
|
+
}
|
|
432
|
+
|
|
389
433
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const e=require("vue"),F=require("@fortawesome/vue-fontawesome");function x(...n){return n.filter(Boolean).join(" ")}function W(n,t){let o;return(...l)=>{o!==void 0&&clearTimeout(o),o=setTimeout(()=>{n(...l)},t)}}function H(n="phila-ui-"){const t=new Uint8Array(16);crypto.getRandomValues(t);const o=Array.from(t,l=>l.toString(36)).join("").substring(0,12);return`${n}-${o}`}const S=e.ref("");function E(){return{inputValue:S,setInputValue:t=>{S.value=t}}}const s=e.reactive({validateOnBlur:!1,validateOnInput:!1,validateOnChange:!1,validateOnMount:!1,required:!1,isValid:!0,errors:[]}),{inputValue:q}=E();function w(n,t){return{init:()=>{n&&(s.validateOnBlur=n.validateOnBlur??!1,s.validateOnInput=n.validateOnInput??!1,s.validateOnChange=n.validateOnChange??!1,s.validateOnMount=n.validateOnMount??!1,s.validate=n.validate,s.required=n.required??!1,s.errors=n.errors||[])},validation:()=>{const a=Object.assign([],n?.errors||[]);if(s.required&&!q.value&&(s.isValid=!1,a.push("This field is required")),s.validate){const i=s.validate(q.value);typeof i=="string"?(s.isValid=!1,a.push(i)):Array.isArray(i)?(s.isValid=!1,a.push(...i)):s.isValid=!0}s.errors=a,a.length>0?(s.isValid=!1,t?.("error",a)):s.isValid=!0},isValid:e.computed(()=>s.isValid),errors:e.computed(()=>s.errors)}}const U={key:0,class:"input-errors"},K=e.defineComponent({__name:"ErrorList",props:{errors:{},validateOnBlur:{type:Boolean},validateOnInput:{type:Boolean},validateOnChange:{type:Boolean},validateOnMount:{type:Boolean},validate:{type:Function},required:{type:Boolean}},setup(n){const{errors:t,isValid:o}=w(),l=n,a=e.computed(()=>Object.assign([],t.value,l.errors||[]));return(i,m)=>!e.unref(o)&&a.value?.length?(e.openBlock(),e.createElementBlock("div",U,[e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(c,d)=>(e.openBlock(),e.createElementBlock("li",{key:d},e.toDisplayString(c),1))),128))])])):e.createCommentVNode("",!0)}}),_=(n,t)=>{const o=n.__vccOpts||n;for(const[l,a]of t)o[l]=a;return o},z=_(K,[["__scopeId","data-v-caba8dd2"]]),G=["for"],J={key:0,class:"required"},Q=e.defineComponent({__name:"InputLabel",props:{id:{},required:{type:Boolean}},setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock("label",{class:"input-label",for:n.id},[e.renderSlot(t.$slots,"default",{},void 0,!0),n.required?(e.openBlock(),e.createElementBlock("span",J,"*")):e.createCommentVNode("",!0)],8,G))}}),M=_(Q,[["__scopeId","data-v-00c91174"]]),X=e.defineComponent({inheritAttrs:!1,__name:"InputWrap",props:{id:{},name:{},placeholder:{},label:{},icon:{},required:{type:Boolean},errors:{},validateOnBlur:{type:Boolean},validateOnInput:{type:Boolean},validateOnChange:{type:Boolean},validateOnMount:{type:Boolean},validate:{type:Function},className:{}},emits:["update:modelValue","input","change","focus","blur","keydown","keyup","keypress","error"],setup(n,{emit:t}){const{setInputValue:o}=E(),l=e.ref(""),a=n,i=t,{init:m,isValid:c,validation:d}=w({validateOnMount:a.validateOnMount??!0,validateOnInput:a.validateOnInput??!0,validateOnBlur:a.validateOnBlur??!0,validateOnChange:a.validateOnChange??!0,required:a.required??!1,errors:a.errors||[],validate:a.validate},i),p=e.computed(()=>({invalid:!c.value})),C=B=>(l.value=B.target.value,i("update:modelValue",l.value),i("input",l.value),o(l.value),a.validateOnInput&&d(),l.value),b=()=>{a.validateOnBlur&&d(),i("blur")},O=()=>{i("focus")};return e.onBeforeMount(()=>{m()}),e.onMounted(()=>{a.validateOnMount&&d()}),(B,T)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["input-wrap",{hasError:!e.unref(c)}])},[a.label?(e.openBlock(),e.createBlock(M,{key:0,id:a.id,required:a.required},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(a.label),1)]),_:1},8,["id","required"])):e.createCommentVNode("",!0),e.renderSlot(B.$slots,"default",e.normalizeProps(e.guardReactiveProps({inputValue:l.value,onBlur:b,onFocus:O,onInput:C,isValid:e.unref(c),inputClasses:p.value})),void 0,!0),e.createVNode(z)],2))}}),Y=_(X,[["__scopeId","data-v-751bf20e"]]),Z=["innerHTML"],ee=["src","alt"],te=e.defineComponent({__name:"Icon",props:{className:{},iconDefinition:{},iconClass:{},src:{},svgRaw:{},variant:{default:"default"},size:{default:"small"},inline:{type:Boolean},shadow:{type:Boolean},decorative:{type:Boolean},ariaLabel:{default:void 0}},setup(n){const t=n,o=e.computed(()=>x("phila-icon",t.size&&`phila-icon--${t.size}`,t.inline&&"phila-icon--inline",t.variant&&t.variant!=="default"&&`phila-icon--${t.variant}`,t.shadow&&"phila-icon--shadow",t.className)),l=e.computed(()=>t.decorative?{"aria-hidden":!0}:{"aria-label":t.ariaLabel,role:"img"});return(a,i)=>(e.openBlock(),e.createElementBlock("span",e.mergeProps({class:o.value},l.value),[t.iconDefinition?(e.openBlock(),e.createBlock(e.unref(F.FontAwesomeIcon),{key:0,icon:t.iconDefinition},null,8,["icon"])):t.iconClass?(e.openBlock(),e.createElementBlock("i",{key:1,class:e.normalizeClass(`fa fa-${t.iconClass}`)},null,2)):t.svgRaw?(e.openBlock(),e.createElementBlock("span",{key:2,class:"phila-icon__svg",innerHTML:t.svgRaw},null,8,Z)):t.src?(e.openBlock(),e.createElementBlock("img",{key:3,src:t.src,alt:t.decorative?"":t.ariaLabel||"Icon"},null,8,ee)):e.createCommentVNode("",!0)],16))}}),V=_(te,[["__scopeId","data-v-1fe4be50"]]),ne={key:1},ae=e.defineComponent({__name:"ActionContent",props:{iconRight:{type:Boolean,default:!1},iconOnly:{type:Boolean,default:!1},inline:{type:Boolean},text:{default:void 0},size:{default:void 0},shadow:{type:Boolean},iconSize:{default:void 0},iconDefinition:{},iconClass:{},src:{},svgRaw:{},variant:{}},setup(n){const t=n,o=e.computed(()=>t.iconDefinition||t.iconClass||t.src||t.svgRaw),l=i=>{if(i.iconOnly)switch(i.size){case"small":return"extra-small";case"extra-small":return"xxsmall";default:return i.size||"medium"}else switch(i.size){case"small":case"extra-small":return"xxsmall";default:return"extra-small"}},a=e.computed(()=>({iconDefinition:t.iconDefinition,iconClass:t.iconClass,src:t.src,svgRaw:t.svgRaw,size:t.iconSize??l(t),decorative:!0,class:"icon",inline:t.inline??!t.iconOnly,shadow:t.shadow}));return(i,m)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[o.value&&!t.iconRight?(e.openBlock(),e.createBlock(V,e.normalizeProps(e.mergeProps({key:0},a.value)),null,16)):e.createCommentVNode("",!0),t.iconOnly?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",ne,[e.renderSlot(i.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(t.text),1)])])),o.value&&t.iconRight?(e.openBlock(),e.createBlock(V,e.normalizeProps(e.mergeProps({key:2},a.value)),null,16)):e.createCommentVNode("",!0)],64))}}),L=n=>"to"in n&&n.to!==void 0;function N(){const n=e.inject("router",null),t=e.computed(()=>n!==null);return{router:n,hasRouter:t}}const oe=e.defineComponent({__name:"BaseLink",props:{to:{},href:{},target:{},rel:{},disabled:{type:Boolean},ariaLabel:{},className:{}},setup(n){const t=n,{hasRouter:o}=N(),l=e.computed(()=>L(t)&&o.value?e.resolveComponent("RouterLink"):"a"),a=e.computed(()=>L(t)?{to:t.disabled?void 0:t.to,...t.disabled&&{"aria-disabled":"true"},...t.ariaLabel&&{"aria-label":t.ariaLabel}}:{href:t.disabled?void 0:t.href,...t.target&&{target:t.target},...t.rel&&{rel:t.rel},...t.disabled&&{"aria-disabled":"true"},...t.ariaLabel&&{"aria-label":t.ariaLabel}});return(i,m)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(l.value),e.mergeProps({class:n.className},a.value),{default:e.withCtx(()=>[e.renderSlot(i.$slots,"default")]),_:3},16,["class"]))}}),v=e.ref({}),f=e.ref(),h=400,I=e.ref(null);function le(n){const t=n?.group??"global",o=(r,u)=>{v.value[t][r]=u},l=(r,u)=>{v.value[t]={[r]:u}},a=r=>v.value[t]?.[r]??!1,i=r=>{o(r,!a(r))},m=r=>{l(r,!a(r))},c=()=>{v.value[t]={}},d=r=>{r.key==="Escape"&&(o(n.id,!1),g())},p=r=>{if(!n)return;const u=r.target,[y]=Object.keys(v.value[t]).filter(j=>v.value[t][j]===!0),k=document.getElementById(y),D=document.querySelector(`[aria-controls="${y}"]`),P=u.getAttribute("aria-controls")===y||D?.contains(r.target);k&&!k.contains(u)&&!P&&(o(n.id,!1),g())},C=()=>{n&&(f.value=setTimeout(()=>{o(n.id,!1),g()},h))},b=()=>{n&&n.mouseOverToggle===!0&&(I.value=n.id,f.value=setTimeout(()=>{$()},h))},O=()=>{n&&n.mouseOverToggle===!0&&(I.value=null,clearTimeout(f.value),f.value=setTimeout(()=>{I.value!==n.id&&(o(n.id,!1),g())},h))},B=r=>{if(!n)return;const{relatedTarget:u}=r;if(!u||u.getAttribute("aria-controls")===n.id)return;const k=document.getElementById(n.id);k&&k.contains(u)||(clearTimeout(f.value),f.value=setTimeout(()=>{n.openSingle?l(n.id,!1):o(n.id,!1),g()},h))},T=()=>{n&&(n.outsideClickClose&&(document.addEventListener("click",p),document.addEventListener("touchend",p)),n.escapeKeyClose&&document.addEventListener("keydown",d))},g=()=>{document.removeEventListener("click",p),document.removeEventListener("touchend",p),document.removeEventListener("keydown",d),document.removeEventListener("scroll",C)},R=r=>{n&&(r?.preventDefault(),clearTimeout(f.value),T())},A=r=>{n&&(R(r),n.openSingle?m(n.id):i(n.id))},$=r=>{n&&(R(r),n.openSingle?l(n.id,!0):o(n.id,!0))};return e.onBeforeMount(()=>{v.value[t]||c()}),e.onUnmounted(()=>{g()}),{state:v,timeout:f,toggle:i,toggleSingle:m,setCollapsed:o,setSingleCollapsed:l,isCollapsed:a,reset:c,onMouseEnter:b,onMouseLeave:O,focusChange:B,onClickToggle:A,onClickOpen:$}}exports.ActionContent=ae;exports.BaseLink=oe;exports.ErrorList=z;exports.Icon=V;exports.InputLabel=M;exports.InputWrap=Y;exports.cn=x;exports.debounce=W;exports.generateRandomId=H;exports.isRouterLink=L;exports.useCollapse=le;exports.useInput=E;exports.useRouter=N;exports.useValidation=w;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const e=require("vue"),N=require("@fortawesome/vue-fontawesome");function S(...n){return n.filter(Boolean).join(" ")}function z(n,t){let i;return(...r)=>{i!==void 0&&clearTimeout(i),i=setTimeout(()=>{n(...r)},t)}}function P(n="phila-ui-"){const t=new Uint8Array(16);crypto.getRandomValues(t);const i=Array.from(t,r=>r.toString(36)).join("").substring(0,12);return`${n}-${i}`}const L=e.ref("");function I(){return{inputValue:L,setInputValue:t=>{L.value=t}}}const d=e.reactive({validateOnBlur:!1,validateOnInput:!1,validateOnChange:!1,validateOnMount:!1,required:!1,isValid:!0,errors:[]}),{inputValue:x}=I();function w(n,t){return{init:()=>{n&&(d.validateOnBlur=n.validateOnBlur??!1,d.validateOnInput=n.validateOnInput??!1,d.validateOnChange=n.validateOnChange??!1,d.validateOnMount=n.validateOnMount??!1,d.validate=n.validate,d.required=n.required??!1,d.errors=n.errors||[])},validation:()=>{const o=Object.assign([],n?.errors||[]);if(d.required&&!x.value&&(d.isValid=!1,o.push("This field is required")),d.validate){const s=d.validate(x.value);typeof s=="string"?(d.isValid=!1,o.push(s)):Array.isArray(s)?(d.isValid=!1,o.push(...s)):d.isValid=!0}d.errors=o,o.length>0?(d.isValid=!1,t?.("error",o)):d.isValid=!0},isValid:e.computed(()=>d.isValid),errors:e.computed(()=>d.errors)}}const F={key:0,class:"input-errors"},H=e.defineComponent({__name:"ErrorList",props:{errors:{},validateOnBlur:{type:Boolean},validateOnInput:{type:Boolean},validateOnChange:{type:Boolean},validateOnMount:{type:Boolean},validate:{type:Function},required:{type:Boolean}},setup(n){const{errors:t,isValid:i}=w(),r=n,o=e.computed(()=>Object.assign([],t.value,r.errors||[]));return(s,y)=>!e.unref(i)&&o.value?.length?(e.openBlock(),e.createElementBlock("div",F,[e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,(p,m)=>(e.openBlock(),e.createElementBlock("li",{key:m},e.toDisplayString(p),1))),128))])])):e.createCommentVNode("",!0)}}),_=(n,t)=>{const i=n.__vccOpts||n;for(const[r,o]of t)i[r]=o;return i},$=_(H,[["__scopeId","data-v-caba8dd2"]]),j=["for"],K={key:0,class:"required"},U=e.defineComponent({__name:"InputLabel",props:{id:{},required:{type:Boolean}},setup(n){return(t,i)=>(e.openBlock(),e.createElementBlock("label",{class:"input-label",for:n.id},[e.renderSlot(t.$slots,"default",{},void 0,!0),n.required?(e.openBlock(),e.createElementBlock("span",K,"*")):e.createCommentVNode("",!0)],8,j))}}),q=_(U,[["__scopeId","data-v-00c91174"]]),W=e.defineComponent({inheritAttrs:!1,__name:"InputWrap",props:{id:{},name:{},placeholder:{},label:{},icon:{},required:{type:Boolean},errors:{},validateOnBlur:{type:Boolean},validateOnInput:{type:Boolean},validateOnChange:{type:Boolean},validateOnMount:{type:Boolean},validate:{type:Function},className:{}},emits:["update:modelValue","input","change","focus","blur","keydown","keyup","keypress","error"],setup(n,{emit:t}){const{setInputValue:i}=I(),r=e.ref(""),o=n,s=t,{init:y,isValid:p,validation:m}=w({validateOnMount:o.validateOnMount??!0,validateOnInput:o.validateOnInput??!0,validateOnBlur:o.validateOnBlur??!0,validateOnChange:o.validateOnChange??!0,required:o.required??!1,errors:o.errors||[],validate:o.validate},s),l=e.computed(()=>({invalid:!p.value})),c=k=>(r.value=k.target.value,s("update:modelValue",r.value),s("input",r.value),i(r.value),o.validateOnInput&&m(),r.value),v=()=>{o.validateOnBlur&&m(),s("blur")},g=()=>{s("focus")};return e.onBeforeMount(()=>{y()}),e.onMounted(()=>{o.validateOnMount&&m()}),(k,a)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["input-wrap",{hasError:!e.unref(p)}])},[o.label?(e.openBlock(),e.createBlock(q,{key:0,id:o.id,required:o.required},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.label),1)]),_:1},8,["id","required"])):e.createCommentVNode("",!0),e.renderSlot(k.$slots,"default",e.normalizeProps(e.guardReactiveProps({inputValue:r.value,onBlur:v,onFocus:g,onInput:c,isValid:e.unref(p),inputClasses:l.value})),void 0,!0),e.createVNode($)],2))}}),G=_(W,[["__scopeId","data-v-751bf20e"]]),J=["innerHTML"],Q=["src","alt"],X=e.defineComponent({__name:"Icon",props:{className:{},iconDefinition:{},iconClass:{},src:{},svgRaw:{},variant:{default:"default"},size:{default:"small"},inline:{type:Boolean},shadow:{type:Boolean},decorative:{type:Boolean},ariaLabel:{default:void 0}},setup(n){const t=n,i=e.computed(()=>S("phila-icon",t.size&&`phila-icon--${t.size}`,t.inline&&"phila-icon--inline",t.variant&&t.variant!=="default"&&`phila-icon--${t.variant}`,t.shadow&&"phila-icon--shadow",t.className)),r=e.computed(()=>t.decorative?{"aria-hidden":!0}:{"aria-label":t.ariaLabel,role:"img"});return(o,s)=>(e.openBlock(),e.createElementBlock("span",e.mergeProps({class:i.value},r.value),[t.iconDefinition?(e.openBlock(),e.createBlock(e.unref(N.FontAwesomeIcon),{key:0,icon:t.iconDefinition},null,8,["icon"])):t.iconClass?(e.openBlock(),e.createElementBlock("i",{key:1,class:e.normalizeClass(`fa fa-${t.iconClass}`)},null,2)):t.svgRaw?(e.openBlock(),e.createElementBlock("span",{key:2,class:"phila-icon__svg",innerHTML:t.svgRaw},null,8,J)):t.src?(e.openBlock(),e.createElementBlock("img",{key:3,src:t.src,alt:t.decorative?"":t.ariaLabel||"Icon"},null,8,Q)):e.createCommentVNode("",!0)],16))}}),O=_(X,[["__scopeId","data-v-1fe4be50"]]),Y={key:1},Z=e.defineComponent({__name:"ActionContent",props:{iconRight:{type:Boolean,default:!1},iconOnly:{type:Boolean,default:!1},inline:{type:Boolean},text:{default:void 0},size:{default:void 0},shadow:{type:Boolean},iconSize:{default:void 0},iconDefinition:{},iconClass:{},src:{},svgRaw:{},variant:{}},setup(n){const t=n,i=e.computed(()=>t.iconDefinition||t.iconClass||t.src||t.svgRaw),r=s=>{if(s.iconOnly)switch(s.size){case"small":return"extra-small";case"extra-small":return"xxsmall";default:return s.size||"medium"}else switch(s.size){case"small":case"extra-small":return"xxsmall";default:return"extra-small"}},o=e.computed(()=>({iconDefinition:t.iconDefinition,iconClass:t.iconClass,src:t.src,svgRaw:t.svgRaw,size:t.iconSize??r(t),decorative:!0,class:"icon",inline:t.inline??!t.iconOnly,shadow:t.shadow}));return(s,y)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[i.value&&!t.iconRight?(e.openBlock(),e.createBlock(O,e.normalizeProps(e.mergeProps({key:0},o.value)),null,16)):e.createCommentVNode("",!0),t.iconOnly?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",Y,[e.renderSlot(s.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(t.text),1)])])),i.value&&t.iconRight?(e.openBlock(),e.createBlock(O,e.normalizeProps(e.mergeProps({key:2},o.value)),null,16)):e.createCommentVNode("",!0)],64))}}),C=n=>"to"in n&&n.to!==void 0;function D(){const n=e.inject("router",null),t=e.computed(()=>n!==null);return{router:n,hasRouter:t}}const ee=e.defineComponent({__name:"BaseLink",props:{to:{},href:{},target:{},rel:{},disabled:{type:Boolean},ariaLabel:{},className:{}},setup(n){const t=n,{hasRouter:i}=D(),r=e.computed(()=>C(t)&&i.value?e.resolveComponent("RouterLink"):"a"),o=e.computed(()=>C(t)?{to:t.disabled?void 0:t.to,...t.disabled&&{"aria-disabled":"true"},...t.ariaLabel&&{"aria-label":t.ariaLabel}}:{href:t.disabled?void 0:t.href,...t.target&&{target:t.target},...t.rel&&{rel:t.rel},...t.disabled&&{"aria-disabled":"true"},...t.ariaLabel&&{"aria-label":t.ariaLabel}});return(s,y)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.value),e.mergeProps({class:n.className},o.value),{default:e.withCtx(()=>[e.renderSlot(s.$slots,"default")]),_:3},16,["class"]))}}),te='a,area,button,iframe,input,object,textarea,select,details,[tabindex]:not([tabindex="-1"])',ne=e.defineComponent({__name:"FocusTrap",props:{initialFocusElement:{},arrowNavigation:{type:Boolean},allowEscape:{type:Boolean},as:{}},emits:["escape"],setup(n,{emit:t}){const i=e.useTemplateRef("focusTrap"),r=e.ref([]),o=n,s=t,y=e.useAttrs(),p=l=>{const c=r.value;if(c.length===0)return;const v=c[0],g=c[c.length-1];if(l.key==="Tab"&&(l.shiftKey?document.activeElement===v&&(o.allowEscape?s("escape"):(l.preventDefault(),g.focus())):document.activeElement===g&&(o.allowEscape?s("escape"):(l.preventDefault(),v.focus()))),l.key==="PageUp"&&(l.preventDefault(),v.focus()),l.key==="PageDown"&&(l.preventDefault(),g.focus()),o.arrowNavigation){const k=c.indexOf(document.activeElement);if(l.key==="ArrowDown"||l.key==="ArrowRight"){l.preventDefault();const a=(k+1)%c.length;c[a].focus()}if(l.key==="ArrowUp"||l.key==="ArrowLeft"){l.preventDefault();const a=(k-1+c.length)%c.length;c[a].focus()}}},m=l=>{l.target.removeAttribute("tabindex")};return e.onMounted(()=>{const l=i.value?.querySelectorAll(te);if(l){l.forEach(v=>{v.addEventListener("keydown",p)}),r.value=Array.from(l);let c=r.value[0];if(o.initialFocusElement){const v=i.value?.querySelector(`${o.initialFocusElement}`);v&&(v.tabIndex===-1&&(v.tabIndex=0,v.addEventListener("blur",m,{once:!0})),c=v)}else c||(c=i.value,c.tabIndex=0,c.addEventListener("blur",m,{once:!0}));c.focus()}}),e.onBeforeUnmount(()=>{r.value.forEach(l=>{l.removeEventListener("keydown",p),l.removeEventListener("blur",m)})}),(l,c)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.as||"span"),e.mergeProps({ref_key:"focusTrap",ref:i},e.unref(y)),{default:e.withCtx(()=>[e.renderSlot(l.$slots,"default")]),_:3},16))}}),u=e.reactive({}),B=e.ref(),T=400,E=e.ref(null),R={id:"default-item",group:"global"};function oe(n){const t=n.group||R.group,i=n.id||R.id,r=(a,f)=>{const b=u[t]?.[a];b&&(b.showSingle?Object.keys(u[t]).forEach(h=>{u[t][h].visible=h===a?f:!1}):u[t][a].visible=f)},o=(a=!0,f)=>{clearTimeout(B.value),r(f??i,a),a&&v(f??i)},s=a=>u[t]?.[a??i]?.visible??!1,y=a=>{u[t]||(u[t]={}),u[t][a]||(u[t][a]={group:t,visible:!1}),n.blurHide!==void 0&&(u[t][a].blurHide=n.blurHide),n.showSingle!==void 0&&(u[t][a].showSingle=n.showSingle),n.mouseOverToggle!==void 0&&(u[t][a].mouseOverToggle=n.mouseOverToggle),n.outsideClickHide!==void 0&&(u[t][a].outsideClickHide=n.outsideClickHide),n.escapeKeyHide!==void 0&&(u[t][a].escapeKeyHide=n.escapeKeyHide)},p=a=>f=>{f.key==="Escape"&&(r(a,!1),g())},m=a=>f=>{if(!u[t])return;const b=f.target,[h]=Object.keys(u[t]).filter(M=>u[t][M].visible===!0),V=document.getElementById(h),A=document.querySelector(`[data-toggle="visibility-${h}"]`)?.contains(f.target);V&&!V.contains(b)&&!A&&(r(a??i,!1),g())},l=a=>{(u[t]?.[a??i]).mouseOverToggle===!0&&(E.value=a??i,B.value=setTimeout(()=>{o(!0,a)},T))},c=a=>{(u[t]?.[a??i]).mouseOverToggle===!0&&(E.value=null,clearTimeout(B.value),B.value=setTimeout(()=>{E.value!==(a??i)&&(r(a??i,!1),g())},T))},v=a=>{const f=u[t]?.[a];f?.outsideClickHide&&(document.addEventListener("click",m(a)),document.addEventListener("touchend",m(a))),f?.escapeKeyHide&&document.addEventListener("keydown",p(a))},g=()=>{u[t]&&Object.keys(u[t]).forEach(a=>{document.removeEventListener("click",m(a)),document.removeEventListener("touchend",m(a)),document.removeEventListener("keydown",p(a))})};e.onBeforeMount(()=>{n.id!==void 0&&(y(n.id),e.nextTick(()=>{n.visibleOnMount&&o(!0)}))}),e.onUnmounted(()=>{g()});const k=e.computed(()=>n.id?{"data-toggle":`visibility-${i}`,onclick:()=>o(!s(i))}:{});return{visibilityState:u,create:y,setState:r,isVisible:s,onMouseEnter:l,onMouseLeave:c,setVisibility:o,toggleProps:k}}exports.ActionContent=Z;exports.BaseLink=ee;exports.ErrorList=$;exports.FocusTrap=ne;exports.Icon=O;exports.InputLabel=q;exports.InputWrap=G;exports.cn=S;exports.debounce=z;exports.generateRandomId=P;exports.isRouterLink=C;exports.useInput=I;exports.useRouter=D;exports.useValidation=w;exports.useVisibility=oe;
|
package/dist/index.mjs
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { ref as
|
|
1
|
+
import { ref as L, reactive as j, computed as g, defineComponent as k, createElementBlock as p, createCommentVNode as O, unref as B, openBlock as d, createElementVNode as ee, Fragment as P, renderList as te, toDisplayString as A, renderSlot as V, onBeforeMount as K, onMounted as U, normalizeClass as G, createBlock as E, createVNode as ne, withCtx as q, createTextVNode as W, normalizeProps as R, guardReactiveProps as ae, mergeProps as I, inject as ie, resolveComponent as oe, resolveDynamicComponent as J, useTemplateRef as se, useAttrs as re, onBeforeUnmount as le, nextTick as ue, onUnmounted as ce } from "vue";
|
|
2
2
|
import { FontAwesomeIcon as de } from "@fortawesome/vue-fontawesome";
|
|
3
|
-
import './index.css';function
|
|
3
|
+
import './index.css';function fe(...t) {
|
|
4
4
|
return t.filter(Boolean).join(" ");
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
let
|
|
8
|
-
return (...
|
|
9
|
-
|
|
10
|
-
t(...
|
|
6
|
+
function Ce(t, e) {
|
|
7
|
+
let i;
|
|
8
|
+
return (...o) => {
|
|
9
|
+
i !== void 0 && clearTimeout(i), i = setTimeout(() => {
|
|
10
|
+
t(...o);
|
|
11
11
|
}, e);
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
function Te(t = "phila-ui-") {
|
|
15
15
|
const e = new Uint8Array(16);
|
|
16
16
|
crypto.getRandomValues(e);
|
|
17
|
-
const
|
|
18
|
-
return `${t}-${
|
|
17
|
+
const i = Array.from(e, (o) => o.toString(36)).join("").substring(0, 12);
|
|
18
|
+
return `${t}-${i}`;
|
|
19
19
|
}
|
|
20
|
-
const
|
|
21
|
-
function
|
|
20
|
+
const S = L("");
|
|
21
|
+
function Q() {
|
|
22
22
|
return {
|
|
23
|
-
inputValue:
|
|
23
|
+
inputValue: S,
|
|
24
24
|
setInputValue: (e) => {
|
|
25
|
-
|
|
25
|
+
S.value = e;
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
const
|
|
29
|
+
const c = j({
|
|
30
30
|
validateOnBlur: !1,
|
|
31
31
|
validateOnInput: !1,
|
|
32
32
|
validateOnChange: !1,
|
|
@@ -34,28 +34,28 @@ const o = te({
|
|
|
34
34
|
required: !1,
|
|
35
35
|
isValid: !0,
|
|
36
36
|
errors: []
|
|
37
|
-
}), { inputValue:
|
|
38
|
-
function
|
|
37
|
+
}), { inputValue: M } = Q();
|
|
38
|
+
function X(t, e) {
|
|
39
39
|
return {
|
|
40
40
|
init: () => {
|
|
41
|
-
t && (
|
|
41
|
+
t && (c.validateOnBlur = t.validateOnBlur ?? !1, c.validateOnInput = t.validateOnInput ?? !1, c.validateOnChange = t.validateOnChange ?? !1, c.validateOnMount = t.validateOnMount ?? !1, c.validate = t.validate, c.required = t.required ?? !1, c.errors = t.errors || []);
|
|
42
42
|
},
|
|
43
43
|
validation: () => {
|
|
44
44
|
const n = Object.assign([], t?.errors || []);
|
|
45
|
-
if (
|
|
46
|
-
const
|
|
47
|
-
typeof
|
|
45
|
+
if (c.required && !M.value && (c.isValid = !1, n.push("This field is required")), c.validate) {
|
|
46
|
+
const r = c.validate(M.value);
|
|
47
|
+
typeof r == "string" ? (c.isValid = !1, n.push(r)) : Array.isArray(r) ? (c.isValid = !1, n.push(...r)) : c.isValid = !0;
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
c.errors = n, n.length > 0 ? (c.isValid = !1, e?.("error", n)) : c.isValid = !0;
|
|
50
50
|
},
|
|
51
|
-
isValid:
|
|
52
|
-
errors:
|
|
51
|
+
isValid: g(() => c.isValid),
|
|
52
|
+
errors: g(() => c.errors)
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
|
-
const
|
|
55
|
+
const ve = {
|
|
56
56
|
key: 0,
|
|
57
57
|
class: "input-errors"
|
|
58
|
-
}, me = /* @__PURE__ */
|
|
58
|
+
}, me = /* @__PURE__ */ k({
|
|
59
59
|
__name: "ErrorList",
|
|
60
60
|
props: {
|
|
61
61
|
errors: {},
|
|
@@ -67,37 +67,37 @@ const fe = {
|
|
|
67
67
|
required: { type: Boolean }
|
|
68
68
|
},
|
|
69
69
|
setup(t) {
|
|
70
|
-
const { errors: e, isValid:
|
|
71
|
-
return (
|
|
72
|
-
|
|
73
|
-
(
|
|
70
|
+
const { errors: e, isValid: i } = X(), o = t, n = g(() => Object.assign([], e.value, o.errors || []));
|
|
71
|
+
return (r, b) => !B(i) && n.value?.length ? (d(), p("div", ve, [
|
|
72
|
+
ee("ul", null, [
|
|
73
|
+
(d(!0), p(P, null, te(n.value, (y, m) => (d(), p("li", { key: m }, A(y), 1))), 128))
|
|
74
74
|
])
|
|
75
|
-
])) :
|
|
75
|
+
])) : O("", !0);
|
|
76
76
|
}
|
|
77
|
-
}),
|
|
78
|
-
const
|
|
79
|
-
for (const [
|
|
80
|
-
|
|
81
|
-
return
|
|
82
|
-
},
|
|
77
|
+
}), T = (t, e) => {
|
|
78
|
+
const i = t.__vccOpts || t;
|
|
79
|
+
for (const [o, n] of e)
|
|
80
|
+
i[o] = n;
|
|
81
|
+
return i;
|
|
82
|
+
}, pe = /* @__PURE__ */ T(me, [["__scopeId", "data-v-caba8dd2"]]), ge = ["for"], ye = {
|
|
83
83
|
key: 0,
|
|
84
84
|
class: "required"
|
|
85
|
-
},
|
|
85
|
+
}, he = /* @__PURE__ */ k({
|
|
86
86
|
__name: "InputLabel",
|
|
87
87
|
props: {
|
|
88
88
|
id: {},
|
|
89
89
|
required: { type: Boolean }
|
|
90
90
|
},
|
|
91
91
|
setup(t) {
|
|
92
|
-
return (e,
|
|
92
|
+
return (e, i) => (d(), p("label", {
|
|
93
93
|
class: "input-label",
|
|
94
94
|
for: t.id
|
|
95
95
|
}, [
|
|
96
|
-
|
|
97
|
-
t.required ? (
|
|
98
|
-
], 8,
|
|
96
|
+
V(e.$slots, "default", {}, void 0, !0),
|
|
97
|
+
t.required ? (d(), p("span", ye, "*")) : O("", !0)
|
|
98
|
+
], 8, ge));
|
|
99
99
|
}
|
|
100
|
-
}),
|
|
100
|
+
}), be = /* @__PURE__ */ T(he, [["__scopeId", "data-v-00c91174"]]), _e = /* @__PURE__ */ k({
|
|
101
101
|
inheritAttrs: !1,
|
|
102
102
|
__name: "InputWrap",
|
|
103
103
|
props: {
|
|
@@ -117,7 +117,7 @@ const fe = {
|
|
|
117
117
|
},
|
|
118
118
|
emits: ["update:modelValue", "input", "change", "focus", "blur", "keydown", "keyup", "keypress", "error"],
|
|
119
119
|
setup(t, { emit: e }) {
|
|
120
|
-
const { setInputValue:
|
|
120
|
+
const { setInputValue: i } = Q(), o = L(""), n = t, r = e, { init: b, isValid: y, validation: m } = X(
|
|
121
121
|
{
|
|
122
122
|
validateOnMount: n.validateOnMount ?? !0,
|
|
123
123
|
validateOnInput: n.validateOnInput ?? !0,
|
|
@@ -127,36 +127,36 @@ const fe = {
|
|
|
127
127
|
errors: n.errors || [],
|
|
128
128
|
validate: n.validate
|
|
129
129
|
},
|
|
130
|
-
|
|
131
|
-
),
|
|
132
|
-
invalid: !
|
|
133
|
-
})),
|
|
134
|
-
n.validateOnBlur &&
|
|
135
|
-
},
|
|
136
|
-
|
|
130
|
+
r
|
|
131
|
+
), s = g(() => ({
|
|
132
|
+
invalid: !y.value
|
|
133
|
+
})), l = (_) => (o.value = _.target.value, r("update:modelValue", o.value), r("input", o.value), i(o.value), n.validateOnInput && m(), o.value), v = () => {
|
|
134
|
+
n.validateOnBlur && m(), r("blur");
|
|
135
|
+
}, h = () => {
|
|
136
|
+
r("focus");
|
|
137
137
|
};
|
|
138
|
-
return
|
|
139
|
-
|
|
140
|
-
}),
|
|
141
|
-
n.validateOnMount &&
|
|
142
|
-
}), (
|
|
143
|
-
class:
|
|
138
|
+
return K(() => {
|
|
139
|
+
b();
|
|
140
|
+
}), U(() => {
|
|
141
|
+
n.validateOnMount && m();
|
|
142
|
+
}), (_, a) => (d(), p("div", {
|
|
143
|
+
class: G(["input-wrap", { hasError: !B(y) }])
|
|
144
144
|
}, [
|
|
145
|
-
n.label ? (
|
|
145
|
+
n.label ? (d(), E(be, {
|
|
146
146
|
key: 0,
|
|
147
147
|
id: n.id,
|
|
148
148
|
required: n.required
|
|
149
149
|
}, {
|
|
150
|
-
default:
|
|
151
|
-
|
|
150
|
+
default: q(() => [
|
|
151
|
+
W(A(n.label), 1)
|
|
152
152
|
]),
|
|
153
153
|
_: 1
|
|
154
|
-
}, 8, ["id", "required"])) :
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
}, 8, ["id", "required"])) : O("", !0),
|
|
155
|
+
V(_.$slots, "default", R(ae({ inputValue: o.value, onBlur: v, onFocus: h, onInput: l, isValid: B(y), inputClasses: s.value })), void 0, !0),
|
|
156
|
+
ne(pe)
|
|
157
157
|
], 2));
|
|
158
158
|
}
|
|
159
|
-
}), $e = /* @__PURE__ */
|
|
159
|
+
}), $e = /* @__PURE__ */ T(_e, [["__scopeId", "data-v-751bf20e"]]), Oe = ["innerHTML"], ke = ["src", "alt"], Ee = /* @__PURE__ */ k({
|
|
160
160
|
__name: "Icon",
|
|
161
161
|
props: {
|
|
162
162
|
className: {},
|
|
@@ -172,38 +172,38 @@ const fe = {
|
|
|
172
172
|
ariaLabel: { default: void 0 }
|
|
173
173
|
},
|
|
174
174
|
setup(t) {
|
|
175
|
-
const e = t,
|
|
175
|
+
const e = t, i = g(() => fe(
|
|
176
176
|
"phila-icon",
|
|
177
177
|
e.size && `phila-icon--${e.size}`,
|
|
178
178
|
e.inline && "phila-icon--inline",
|
|
179
179
|
e.variant && e.variant !== "default" && `phila-icon--${e.variant}`,
|
|
180
180
|
e.shadow && "phila-icon--shadow",
|
|
181
181
|
e.className
|
|
182
|
-
)),
|
|
182
|
+
)), o = g(() => e.decorative ? {
|
|
183
183
|
"aria-hidden": !0
|
|
184
184
|
} : {
|
|
185
185
|
"aria-label": e.ariaLabel,
|
|
186
186
|
role: "img"
|
|
187
187
|
});
|
|
188
|
-
return (n,
|
|
189
|
-
e.iconDefinition ? (
|
|
188
|
+
return (n, r) => (d(), p("span", I({ class: i.value }, o.value), [
|
|
189
|
+
e.iconDefinition ? (d(), E(B(de), {
|
|
190
190
|
key: 0,
|
|
191
191
|
icon: e.iconDefinition
|
|
192
|
-
}, null, 8, ["icon"])) : e.iconClass ? (
|
|
192
|
+
}, null, 8, ["icon"])) : e.iconClass ? (d(), p("i", {
|
|
193
193
|
key: 1,
|
|
194
|
-
class:
|
|
195
|
-
}, null, 2)) : e.svgRaw ? (
|
|
194
|
+
class: G(`fa fa-${e.iconClass}`)
|
|
195
|
+
}, null, 2)) : e.svgRaw ? (d(), p("span", {
|
|
196
196
|
key: 2,
|
|
197
197
|
class: "phila-icon__svg",
|
|
198
198
|
innerHTML: e.svgRaw
|
|
199
|
-
}, null, 8,
|
|
199
|
+
}, null, 8, Oe)) : e.src ? (d(), p("img", {
|
|
200
200
|
key: 3,
|
|
201
201
|
src: e.src,
|
|
202
202
|
alt: e.decorative ? "" : e.ariaLabel || "Icon"
|
|
203
|
-
}, null, 8,
|
|
203
|
+
}, null, 8, ke)) : O("", !0)
|
|
204
204
|
], 16));
|
|
205
205
|
}
|
|
206
|
-
}),
|
|
206
|
+
}), z = /* @__PURE__ */ T(Ee, [["__scopeId", "data-v-1fe4be50"]]), we = { key: 1 }, Re = /* @__PURE__ */ k({
|
|
207
207
|
__name: "ActionContent",
|
|
208
208
|
props: {
|
|
209
209
|
iconRight: { type: Boolean, default: !1 },
|
|
@@ -220,56 +220,56 @@ const fe = {
|
|
|
220
220
|
variant: {}
|
|
221
221
|
},
|
|
222
222
|
setup(t) {
|
|
223
|
-
const e = t,
|
|
224
|
-
if (
|
|
225
|
-
switch (
|
|
223
|
+
const e = t, i = g(() => e.iconDefinition || e.iconClass || e.src || e.svgRaw), o = (r) => {
|
|
224
|
+
if (r.iconOnly)
|
|
225
|
+
switch (r.size) {
|
|
226
226
|
case "small":
|
|
227
227
|
return "extra-small";
|
|
228
228
|
case "extra-small":
|
|
229
229
|
return "xxsmall";
|
|
230
230
|
default:
|
|
231
|
-
return
|
|
231
|
+
return r.size || "medium";
|
|
232
232
|
}
|
|
233
233
|
else
|
|
234
|
-
switch (
|
|
234
|
+
switch (r.size) {
|
|
235
235
|
case "small":
|
|
236
236
|
case "extra-small":
|
|
237
237
|
return "xxsmall";
|
|
238
238
|
default:
|
|
239
239
|
return "extra-small";
|
|
240
240
|
}
|
|
241
|
-
}, n =
|
|
241
|
+
}, n = g(
|
|
242
242
|
() => ({
|
|
243
243
|
iconDefinition: e.iconDefinition,
|
|
244
244
|
iconClass: e.iconClass,
|
|
245
245
|
src: e.src,
|
|
246
246
|
svgRaw: e.svgRaw,
|
|
247
|
-
size: e.iconSize ??
|
|
247
|
+
size: e.iconSize ?? o(e),
|
|
248
248
|
decorative: !0,
|
|
249
249
|
class: "icon",
|
|
250
250
|
inline: e.inline ?? !e.iconOnly,
|
|
251
251
|
shadow: e.shadow
|
|
252
252
|
})
|
|
253
253
|
);
|
|
254
|
-
return (
|
|
255
|
-
|
|
256
|
-
e.iconOnly ?
|
|
257
|
-
|
|
258
|
-
|
|
254
|
+
return (r, b) => (d(), p(P, null, [
|
|
255
|
+
i.value && !e.iconRight ? (d(), E(z, R(I({ key: 0 }, n.value)), null, 16)) : O("", !0),
|
|
256
|
+
e.iconOnly ? O("", !0) : (d(), p("span", we, [
|
|
257
|
+
V(r.$slots, "default", {}, () => [
|
|
258
|
+
W(A(e.text), 1)
|
|
259
259
|
])
|
|
260
260
|
])),
|
|
261
|
-
|
|
261
|
+
i.value && e.iconRight ? (d(), E(z, R(I({ key: 2 }, n.value)), null, 16)) : O("", !0)
|
|
262
262
|
], 64));
|
|
263
263
|
}
|
|
264
|
-
}),
|
|
265
|
-
function
|
|
266
|
-
const t =
|
|
264
|
+
}), H = (t) => "to" in t && t.to !== void 0;
|
|
265
|
+
function Be() {
|
|
266
|
+
const t = ie("router", null), e = g(() => t !== null);
|
|
267
267
|
return {
|
|
268
268
|
router: t,
|
|
269
269
|
hasRouter: e
|
|
270
270
|
};
|
|
271
271
|
}
|
|
272
|
-
const
|
|
272
|
+
const Ae = /* @__PURE__ */ k({
|
|
273
273
|
__name: "BaseLink",
|
|
274
274
|
props: {
|
|
275
275
|
to: {},
|
|
@@ -281,7 +281,7 @@ const Ee = /* @__PURE__ */ O({
|
|
|
281
281
|
className: {}
|
|
282
282
|
},
|
|
283
283
|
setup(t) {
|
|
284
|
-
const e = t, { hasRouter:
|
|
284
|
+
const e = t, { hasRouter: i } = Be(), o = g(() => H(e) && i.value ? oe("RouterLink") : "a"), n = g(() => H(e) ? {
|
|
285
285
|
to: e.disabled ? void 0 : e.to,
|
|
286
286
|
...e.disabled && { "aria-disabled": "true" },
|
|
287
287
|
...e.ariaLabel && { "aria-label": e.ariaLabel }
|
|
@@ -292,96 +292,145 @@ const Ee = /* @__PURE__ */ O({
|
|
|
292
292
|
...e.disabled && { "aria-disabled": "true" },
|
|
293
293
|
...e.ariaLabel && { "aria-label": e.ariaLabel }
|
|
294
294
|
});
|
|
295
|
-
return (
|
|
296
|
-
default:
|
|
297
|
-
|
|
295
|
+
return (r, b) => (d(), E(J(o.value), I({ class: t.className }, n.value), {
|
|
296
|
+
default: q(() => [
|
|
297
|
+
V(r.$slots, "default")
|
|
298
298
|
]),
|
|
299
299
|
_: 3
|
|
300
300
|
}, 16, ["class"]));
|
|
301
301
|
}
|
|
302
|
-
}),
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
302
|
+
}), Ie = 'a,area,button,iframe,input,object,textarea,select,details,[tabindex]:not([tabindex="-1"])', qe = /* @__PURE__ */ k({
|
|
303
|
+
__name: "FocusTrap",
|
|
304
|
+
props: {
|
|
305
|
+
initialFocusElement: {},
|
|
306
|
+
arrowNavigation: { type: Boolean },
|
|
307
|
+
allowEscape: { type: Boolean },
|
|
308
|
+
as: {}
|
|
309
|
+
},
|
|
310
|
+
emits: ["escape"],
|
|
311
|
+
setup(t, { emit: e }) {
|
|
312
|
+
const i = se("focusTrap"), o = L([]), n = t, r = e, b = re(), y = (s) => {
|
|
313
|
+
const l = o.value;
|
|
314
|
+
if (l.length === 0) return;
|
|
315
|
+
const v = l[0], h = l[l.length - 1];
|
|
316
|
+
if (s.key === "Tab" && (s.shiftKey ? document.activeElement === v && (n.allowEscape ? r("escape") : (s.preventDefault(), h.focus())) : document.activeElement === h && (n.allowEscape ? r("escape") : (s.preventDefault(), v.focus()))), s.key === "PageUp" && (s.preventDefault(), v.focus()), s.key === "PageDown" && (s.preventDefault(), h.focus()), n.arrowNavigation) {
|
|
317
|
+
const _ = l.indexOf(document.activeElement);
|
|
318
|
+
if (s.key === "ArrowDown" || s.key === "ArrowRight") {
|
|
319
|
+
s.preventDefault();
|
|
320
|
+
const a = (_ + 1) % l.length;
|
|
321
|
+
l[a].focus();
|
|
322
|
+
}
|
|
323
|
+
if (s.key === "ArrowUp" || s.key === "ArrowLeft") {
|
|
324
|
+
s.preventDefault();
|
|
325
|
+
const a = (_ - 1 + l.length) % l.length;
|
|
326
|
+
l[a].focus();
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}, m = (s) => {
|
|
330
|
+
s.target.removeAttribute("tabindex");
|
|
331
|
+
};
|
|
332
|
+
return U(() => {
|
|
333
|
+
const s = i.value?.querySelectorAll(Ie);
|
|
334
|
+
if (s) {
|
|
335
|
+
s.forEach((v) => {
|
|
336
|
+
v.addEventListener("keydown", y);
|
|
337
|
+
}), o.value = Array.from(s);
|
|
338
|
+
let l = o.value[0];
|
|
339
|
+
if (n.initialFocusElement) {
|
|
340
|
+
const v = i.value?.querySelector(`${n.initialFocusElement}`);
|
|
341
|
+
v && (v.tabIndex === -1 && (v.tabIndex = 0, v.addEventListener("blur", m, { once: !0 })), l = v);
|
|
342
|
+
} else l || (l = i.value, l.tabIndex = 0, l.addEventListener("blur", m, { once: !0 }));
|
|
343
|
+
l.focus();
|
|
344
|
+
}
|
|
345
|
+
}), le(() => {
|
|
346
|
+
o.value.forEach((s) => {
|
|
347
|
+
s.removeEventListener("keydown", y), s.removeEventListener("blur", m);
|
|
348
|
+
});
|
|
349
|
+
}), (s, l) => (d(), E(J(n.as || "span"), I({
|
|
350
|
+
ref_key: "focusTrap",
|
|
351
|
+
ref: i
|
|
352
|
+
}, B(b)), {
|
|
353
|
+
default: q(() => [
|
|
354
|
+
V(s.$slots, "default")
|
|
355
|
+
]),
|
|
356
|
+
_: 3
|
|
357
|
+
}, 16));
|
|
358
|
+
}
|
|
359
|
+
}), u = j({}), C = L(), F = 400, $ = L(null), N = {
|
|
360
|
+
id: "default-item",
|
|
361
|
+
group: "global"
|
|
362
|
+
};
|
|
363
|
+
function De(t) {
|
|
364
|
+
const e = t.group || N.group, i = t.id || N.id, o = (a, f) => {
|
|
365
|
+
const x = u[e]?.[a];
|
|
366
|
+
x && (x.showSingle ? Object.keys(u[e]).forEach((w) => {
|
|
367
|
+
u[e][w].visible = w === a ? f : !1;
|
|
368
|
+
}) : u[e][a].visible = f);
|
|
369
|
+
}, n = (a = !0, f) => {
|
|
370
|
+
clearTimeout(C.value), o(f ?? i, a), a && v(f ?? i);
|
|
371
|
+
}, r = (a) => u[e]?.[a ?? i]?.visible ?? !1, b = (a) => {
|
|
372
|
+
u[e] || (u[e] = {}), u[e][a] || (u[e][a] = {
|
|
373
|
+
group: e,
|
|
374
|
+
visible: !1
|
|
375
|
+
}), t.blurHide !== void 0 && (u[e][a].blurHide = t.blurHide), t.showSingle !== void 0 && (u[e][a].showSingle = t.showSingle), t.mouseOverToggle !== void 0 && (u[e][a].mouseOverToggle = t.mouseOverToggle), t.outsideClickHide !== void 0 && (u[e][a].outsideClickHide = t.outsideClickHide), t.escapeKeyHide !== void 0 && (u[e][a].escapeKeyHide = t.escapeKeyHide);
|
|
376
|
+
}, y = (a) => (f) => {
|
|
377
|
+
f.key === "Escape" && (o(a, !1), h());
|
|
378
|
+
}, m = (a) => (f) => {
|
|
379
|
+
if (!u[e]) return;
|
|
380
|
+
const x = f.target, [w] = Object.keys(u[e]).filter((Z) => u[e][Z].visible === !0), D = document.getElementById(w), Y = document.querySelector(`[data-toggle="visibility-${w}"]`)?.contains(f.target);
|
|
381
|
+
D && !D.contains(x) && !Y && (o(a ?? i, !1), h());
|
|
382
|
+
}, s = (a) => {
|
|
383
|
+
(u[e]?.[a ?? i]).mouseOverToggle === !0 && ($.value = a ?? i, C.value = setTimeout(() => {
|
|
384
|
+
n(!0, a);
|
|
385
|
+
}, F));
|
|
386
|
+
}, l = (a) => {
|
|
387
|
+
(u[e]?.[a ?? i]).mouseOverToggle === !0 && ($.value = null, clearTimeout(C.value), C.value = setTimeout(() => {
|
|
388
|
+
$.value !== (a ?? i) && (o(a ?? i, !1), h());
|
|
389
|
+
}, F));
|
|
390
|
+
}, v = (a) => {
|
|
391
|
+
const f = u[e]?.[a];
|
|
392
|
+
f?.outsideClickHide && (document.addEventListener("click", m(a)), document.addEventListener("touchend", m(a))), f?.escapeKeyHide && document.addEventListener("keydown", y(a));
|
|
393
|
+
}, h = () => {
|
|
394
|
+
u[e] && Object.keys(u[e]).forEach((a) => {
|
|
395
|
+
document.removeEventListener("click", m(a)), document.removeEventListener("touchend", m(a)), document.removeEventListener("keydown", y(a));
|
|
396
|
+
});
|
|
351
397
|
};
|
|
352
|
-
|
|
353
|
-
|
|
398
|
+
K(() => {
|
|
399
|
+
t.id !== void 0 && (b(t.id), ue(() => {
|
|
400
|
+
t.visibleOnMount && n(!0);
|
|
401
|
+
}));
|
|
354
402
|
}), ce(() => {
|
|
355
|
-
|
|
356
|
-
})
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
403
|
+
h();
|
|
404
|
+
});
|
|
405
|
+
const _ = g(() => t.id ? {
|
|
406
|
+
"data-toggle": `visibility-${i}`,
|
|
407
|
+
onclick: () => n(!r(i))
|
|
408
|
+
} : {});
|
|
409
|
+
return {
|
|
410
|
+
visibilityState: u,
|
|
411
|
+
create: b,
|
|
412
|
+
setState: o,
|
|
413
|
+
isVisible: r,
|
|
414
|
+
onMouseEnter: s,
|
|
415
|
+
onMouseLeave: l,
|
|
416
|
+
setVisibility: n,
|
|
417
|
+
toggleProps: _
|
|
370
418
|
};
|
|
371
419
|
}
|
|
372
420
|
export {
|
|
373
421
|
Re as ActionContent,
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
422
|
+
Ae as BaseLink,
|
|
423
|
+
pe as ErrorList,
|
|
424
|
+
qe as FocusTrap,
|
|
425
|
+
z as Icon,
|
|
426
|
+
be as InputLabel,
|
|
378
427
|
$e as InputWrap,
|
|
379
|
-
|
|
380
|
-
|
|
428
|
+
fe as cn,
|
|
429
|
+
Ce as debounce,
|
|
381
430
|
Te as generateRandomId,
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
431
|
+
H as isRouterLink,
|
|
432
|
+
Q as useInput,
|
|
433
|
+
Be as useRouter,
|
|
434
|
+
X as useValidation,
|
|
435
|
+
De as useVisibility
|
|
387
436
|
};
|
|
@@ -25,6 +25,13 @@
|
|
|
25
25
|
.has-text-center {
|
|
26
26
|
text-align: center !important;
|
|
27
27
|
}
|
|
28
|
+
.has-text-label-3xl {
|
|
29
|
+
font-family: var(--Label-3XL-font-label-3xl-family) !important;
|
|
30
|
+
font-size: var(--Label-3XL-font-label-3xl-size) !important;
|
|
31
|
+
font-style: normal;
|
|
32
|
+
font-weight: 600;
|
|
33
|
+
line-height: var(--Label-3XL-font-label-3xl-lineheight) !important;
|
|
34
|
+
}
|
|
28
35
|
.has-text-label-small {
|
|
29
36
|
font-family: var(--Label-ExtraSmall-font-label-xs-family) !important;
|
|
30
37
|
font-size: var(--Label-ExtraSmall-font-label-xs-size) !important;
|