@design-factory/core 21.1.0-next.1 → 22.0.0-next.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/{accordion-D9ba0XYq.js → accordion-B5RqDwi3.js} +76 -15
- package/alert-Db6cG6JE.js +125 -0
- package/{collapse-Bn8iHKrd.js → collapse-D8Jo56k9.js} +2 -2
- package/{common-DFyZvkII.js → common-CP4amR0Z.js} +2 -2
- package/components/accordion/accordion.d.ts +73 -15
- package/components/accordion/index.js +1 -1
- package/components/alert/alert.d.ts +77 -8
- package/components/alert/common.d.ts +9 -9
- package/components/alert/index.js +2 -3
- package/components/carousel/index.js +2 -2
- package/components/collapse/index.js +1 -1
- package/components/drawer/drawer.d.ts +6 -0
- package/components/drawer/index.js +1 -1
- package/components/dropdown/dropdown.d.ts +110 -0
- package/components/dropdown/index.d.ts +1 -0
- package/components/dropdown/index.js +5 -0
- package/components/modal/index.js +1 -1
- package/components/pagination/index.js +1 -1
- package/components/progressbar/index.js +1 -1
- package/components/rating/index.js +1 -1
- package/components/slider/index.js +1 -1
- package/components/slider/slider.d.ts +23 -4
- package/components/toast/index.js +1 -1
- package/components/tooltip/index.d.ts +1 -0
- package/components/tooltip/index.js +174 -0
- package/components/tooltip/tooltip.d.ts +63 -0
- package/components/tree/index.js +1 -1
- package/{directive-CNNSo5Yn.js → directive-CMT2vEDg.js} +7 -4
- package/{drawer-BIIfJa0F.js → drawer-CpGnS2ln.js} +12 -5
- package/dropdown-Bjj2ql6d.js +246 -0
- package/index.d.ts +3 -1
- package/index.js +44 -37
- package/isFocusable-C2iRr0zh.js +72 -0
- package/{modal-C13G13jV.js → modal-CQWh2Sm5.js} +4 -4
- package/package.json +1 -1
- package/{pagination-BQWusWXN.js → pagination-DIRcpdRE.js} +2 -2
- package/{progressbar-S1pNn5rM.js → progressbar-Bth8r3Qu.js} +2 -2
- package/{promise-D-RZVPuv.js → promise-CkIc0KKt.js} +3 -3
- package/{rating-DWgGgwk3.js → rating-DLsgFSyB.js} +2 -2
- package/{scrollbars-CcxSrnCx.js → scrollbars-ChGk75QR.js} +3 -0
- package/services/extendWidget.d.ts +1 -1
- package/services/focusElement.js +2 -2
- package/services/focustrack.js +2 -2
- package/services/matchMedia.js +1 -1
- package/services/mousetrack.d.ts +34 -0
- package/services/mousetrack.js +41 -0
- package/services/navManager.js +2 -2
- package/services/pointerdownPosition.js +1 -1
- package/services/portal.js +1 -1
- package/services/positioning.d.ts +101 -0
- package/services/positioning.js +104 -0
- package/services/resizeObserver.js +1 -1
- package/services/siblingsInert.js +1 -1
- package/services/transitions/baseTransitions.js +3 -3
- package/services/transitions/collapse.js +4 -7
- package/services/transitions/cssTransitions.js +2 -2
- package/services/transitions/simpleClassTransition.js +1 -1
- package/{slider-Br_Qiopx.js → slider-b9cVFNAL.js} +96 -58
- package/{toaster-BUBzFeJM.js → toaster-BS9qeRLF.js} +3 -3
- package/{tree-vD7ZkV8Z.js → tree-DW6iLxdw.js} +2 -2
- package/types.d.ts +8 -1
- package/utils/debounceSignal.d.ts +11 -0
- package/utils/debounceSignal.js +18 -0
- package/utils/directive.js +1 -1
- package/utils/edgeState.d.ts +23 -0
- package/utils/edgeState.js +43 -0
- package/utils/internal/isFocusable.d.ts +40 -0
- package/utils/stores.d.ts +1 -1
- package/utils/stores.js +4 -1
- package/utils/writables.d.ts +27 -13
- package/utils/writables.js +12 -11
- package/{writables-DYGjj5T3.js → writables-_7BriMb2.js} +37 -12
- package/accordion-B0vs8JWM.cjs +0 -314
- package/alert-AhaliJ17.cjs +0 -9
- package/alert-Cb9FhbFQ.js +0 -10
- package/collapse-BnWw4Hnc.cjs +0 -94
- package/common-B5jS-Ih_.cjs +0 -73
- package/components/accordion/index.cjs +0 -7
- package/components/alert/index.cjs +0 -5
- package/components/carousel/index.cjs +0 -292
- package/components/collapse/index.cjs +0 -5
- package/components/drawer/index.cjs +0 -5
- package/components/modal/index.cjs +0 -8
- package/components/pagination/index.cjs +0 -5
- package/components/progressbar/index.cjs +0 -5
- package/components/rating/index.cjs +0 -5
- package/components/slider/index.cjs +0 -5
- package/components/toast/index.cjs +0 -7
- package/components/tree/index.cjs +0 -5
- package/config.cjs +0 -36
- package/directive-DyTodNPd.cjs +0 -523
- package/drawer-C8ojtwIn.cjs +0 -328
- package/index.cjs +0 -134
- package/isFocusable-Ckwus82R.js +0 -32
- package/isFocusable-DfzDLeAN.cjs +0 -31
- package/modal-DWv0VqiG.cjs +0 -252
- package/pagination-BLVa1UsZ.cjs +0 -254
- package/progressbar-RopgvVeA.cjs +0 -86
- package/promise-CxCD3NYv.cjs +0 -118
- package/rating-DZ3OQgtt.cjs +0 -183
- package/scrollbars-CT87iv_6.cjs +0 -30
- package/services/extendWidget.cjs +0 -41
- package/services/floatingUI.cjs +0 -111
- package/services/floatingUI.d.ts +0 -76
- package/services/floatingUI.js +0 -111
- package/services/focusElement.cjs +0 -46
- package/services/focustrack.cjs +0 -47
- package/services/hash.cjs +0 -15
- package/services/intersection.cjs +0 -53
- package/services/matchMedia.cjs +0 -14
- package/services/navManager.cjs +0 -166
- package/services/pointerdownPosition.cjs +0 -60
- package/services/portal.cjs +0 -42
- package/services/resizeObserver.cjs +0 -54
- package/services/siblingsInert.cjs +0 -44
- package/services/transitions/baseTransitions.cjs +0 -186
- package/services/transitions/collapse.cjs +0 -40
- package/services/transitions/cssTransitions.cjs +0 -32
- package/services/transitions/simpleClassTransition.cjs +0 -37
- package/slider-pgDq1V5r.cjs +0 -807
- package/textDirection-zqcZ5-eK.cjs +0 -3
- package/toaster-Dlube4Ya.cjs +0 -161
- package/tree-Chcy4ulJ.cjs +0 -228
- package/types.cjs +0 -6
- package/utils/directive.cjs +0 -28
- package/utils/func.cjs +0 -7
- package/utils/id.cjs +0 -5
- package/utils/stores.cjs +0 -172
- package/utils/widget.cjs +0 -8
- package/utils/writables.cjs +0 -16
- package/writables-Dt68gADJ.cjs +0 -102
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { type Placement } from '../../services/positioning';
|
|
2
|
+
import { type Directive, type Widget, type WidgetFactory } from '../../types';
|
|
3
|
+
export type DropdownSize = 'sm' | 'md' | 'lg';
|
|
4
|
+
/**
|
|
5
|
+
* Common props and state for the Dropdown component.
|
|
6
|
+
*/
|
|
7
|
+
interface DropdownCommonPropsAndState {
|
|
8
|
+
/**
|
|
9
|
+
* If `true` the dropdown menu is open
|
|
10
|
+
*/
|
|
11
|
+
opened: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Size of the dropdown.
|
|
14
|
+
*
|
|
15
|
+
* @defaultValue `'md'`
|
|
16
|
+
*/
|
|
17
|
+
size: DropdownSize;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Represents the state of a Dropdown component.
|
|
21
|
+
*/
|
|
22
|
+
export interface DropdownState extends DropdownCommonPropsAndState {
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Properties for the Dropdown component.
|
|
26
|
+
*/
|
|
27
|
+
export interface DropdownProps extends DropdownCommonPropsAndState {
|
|
28
|
+
/**
|
|
29
|
+
* Callback called when the open state of the dropdown changes.
|
|
30
|
+
*
|
|
31
|
+
* @defaultValue
|
|
32
|
+
* ```ts
|
|
33
|
+
* () => {}
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
onOpenedChange: (opened: boolean) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Preferred dropdown menu placement.
|
|
39
|
+
*
|
|
40
|
+
* Must be a space-separated list or an array of Placement, where the first value is the main placement and
|
|
41
|
+
* subsequent values are fallback placements.
|
|
42
|
+
*
|
|
43
|
+
* @defaultValue `['bottom-start', 'bottom-end', 'top-start', 'top-end']`
|
|
44
|
+
*/
|
|
45
|
+
placement: Placement[];
|
|
46
|
+
/**
|
|
47
|
+
* Which element should contain the dropdown menu DOM element.
|
|
48
|
+
* - `'body'`: the menu is appended to `document.body` (useful when the toggle is inside an element that clips
|
|
49
|
+
* its content via `overflow` or creates a stacking context).
|
|
50
|
+
* - `null` (default): the menu is rendered inline, where the dropdown is declared.
|
|
51
|
+
*
|
|
52
|
+
* @defaultValue `null`
|
|
53
|
+
*/
|
|
54
|
+
container: 'body' | null;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Interface representing the API for a dropdown component.
|
|
58
|
+
*/
|
|
59
|
+
export interface DropdownApi {
|
|
60
|
+
/**
|
|
61
|
+
* Triggers dropdown closing programmatically.
|
|
62
|
+
*/
|
|
63
|
+
close(): void;
|
|
64
|
+
/**
|
|
65
|
+
* Triggers the dropdown content to be displayed for the user.
|
|
66
|
+
*/
|
|
67
|
+
open(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Toggles the dropdown content visibility.
|
|
70
|
+
* @param open Optional parameter to explicitly set the dropdown state. If not provided, the state will be toggled.
|
|
71
|
+
*/
|
|
72
|
+
toggle(open?: boolean): void;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Interface representing the directives used in a dropdown component.
|
|
76
|
+
*/
|
|
77
|
+
export interface DropdownDirectives {
|
|
78
|
+
/**
|
|
79
|
+
* Directive to apply to the anchor element (the reference point for positioning the dropdown menu)
|
|
80
|
+
*/
|
|
81
|
+
anchorDirective: Directive;
|
|
82
|
+
/**
|
|
83
|
+
* Directive to apply positioned.
|
|
84
|
+
*/
|
|
85
|
+
menuDirective: Directive;
|
|
86
|
+
/**
|
|
87
|
+
* Directive to apply to the dropdown host element (carries the ARIA semantics: `id`, `aria-live`).
|
|
88
|
+
*/
|
|
89
|
+
dropdownDirective: Directive;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Represents a widget for handling dropdown functionality.
|
|
93
|
+
*
|
|
94
|
+
* This type defines the structure of a DropdownWidget, which includes properties, state, API, and directives
|
|
95
|
+
* necessary for managing the dropdown behavior in the UI.
|
|
96
|
+
*
|
|
97
|
+
* @type {Widget<DropdownProps, DropdownState, DropdownApi, DropdownDirectives>}
|
|
98
|
+
*/
|
|
99
|
+
export type DropdownWidget = Widget<DropdownProps, DropdownState, DropdownApi, DropdownDirectives>;
|
|
100
|
+
/**
|
|
101
|
+
* Retrieve a shallow copy of the default dropdown config
|
|
102
|
+
* @returns the default dropdown config
|
|
103
|
+
*/
|
|
104
|
+
export declare function getDropdownDefaultConfig(): DropdownProps;
|
|
105
|
+
/**
|
|
106
|
+
* Create an DropdownWidget factory
|
|
107
|
+
* @returns an DropdownWidget
|
|
108
|
+
*/
|
|
109
|
+
export declare const createDropdown: WidgetFactory<DropdownWidget>;
|
|
110
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dropdown';
|
|
@@ -162,16 +162,22 @@ interface SliderCommonPropsAndState extends WidgetsCommonPropsAndState {
|
|
|
162
162
|
*/
|
|
163
163
|
showTicks: boolean;
|
|
164
164
|
/**
|
|
165
|
-
*
|
|
165
|
+
* If `true`, visually flips the slider direction (both horizontal and vertical).
|
|
166
166
|
*
|
|
167
167
|
* @defaultValue `false`
|
|
168
168
|
*/
|
|
169
|
-
|
|
169
|
+
flip: boolean;
|
|
170
170
|
}
|
|
171
171
|
/**
|
|
172
172
|
* Represents the state of a slider component.
|
|
173
173
|
*/
|
|
174
174
|
export interface SliderState extends SliderCommonPropsAndState {
|
|
175
|
+
/**
|
|
176
|
+
* It `true` slider display is inversed
|
|
177
|
+
*
|
|
178
|
+
* @defaultValue `false`
|
|
179
|
+
*/
|
|
180
|
+
rtl: boolean;
|
|
175
181
|
/**
|
|
176
182
|
* Sorted slider values
|
|
177
183
|
*/
|
|
@@ -221,6 +227,13 @@ export interface SliderState extends SliderCommonPropsAndState {
|
|
|
221
227
|
* Interface representing the properties for the Slider component.
|
|
222
228
|
*/
|
|
223
229
|
export interface SliderProps extends SliderCommonPropsAndState {
|
|
230
|
+
/**
|
|
231
|
+
* If set, overrides the auto-detected RTL direction.
|
|
232
|
+
* When not set (`undefined`), RTL is auto-detected from the element's computed CSS direction.
|
|
233
|
+
*
|
|
234
|
+
* @defaultValue `undefined`
|
|
235
|
+
*/
|
|
236
|
+
rtl: boolean | undefined;
|
|
224
237
|
/**
|
|
225
238
|
* Return the value for the 'aria-label' attribute for the handle
|
|
226
239
|
* @param sortedIndex - index of the handle in the sorted list
|
|
@@ -277,16 +290,22 @@ export interface SliderProps extends SliderCommonPropsAndState {
|
|
|
277
290
|
*/
|
|
278
291
|
showTickValues: boolean;
|
|
279
292
|
/**
|
|
280
|
-
* Minimum distance between two values.
|
|
293
|
+
* Minimum distance between two handle values.
|
|
281
294
|
* When set to 0, no minimum distance constraint is applied.
|
|
282
295
|
*
|
|
296
|
+
* Note: constraints are only enforced when a handle value changes (via user interaction or programmatic update),
|
|
297
|
+
* not on the initial values. If the initial values violate the constraint, they are rendered as-is until a handle moves.
|
|
298
|
+
*
|
|
283
299
|
* @defaultValue `0`
|
|
284
300
|
*/
|
|
285
301
|
minRange: number;
|
|
286
302
|
/**
|
|
287
|
-
* Maximum distance between two values
|
|
303
|
+
* Maximum distance between two handle values.
|
|
288
304
|
* When set to 0, no maximum distance constraint is applied.
|
|
289
305
|
*
|
|
306
|
+
* Note: constraints are only enforced when a handle value changes (via user interaction or programmatic update),
|
|
307
|
+
* not on the initial values. If the initial values violate the constraint, they are rendered as-is until a handle moves.
|
|
308
|
+
*
|
|
290
309
|
* @defaultValue `0`
|
|
291
310
|
*/
|
|
292
311
|
maxRange: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './tooltip';
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { writable, derived, computed, readable } from "@amadeus-it-group/tansu";
|
|
2
|
+
import { createHasFocus, activeElement$ } from "../../services/focustrack.js";
|
|
3
|
+
import { createHasMouseInside } from "../../services/mousetrack.js";
|
|
4
|
+
import { typePlacement, createPositioning } from "../../services/positioning.js";
|
|
5
|
+
import { createTransition } from "../../services/transitions/baseTransitions.js";
|
|
6
|
+
import { createSimpleClassTransition } from "../../services/transitions/simpleClassTransition.js";
|
|
7
|
+
import { debounceSignal } from "../../utils/debounceSignal.js";
|
|
8
|
+
import { w as addEvent, s as mergeDirectives, g as createAttributesDirective, o as directiveSubscribe } from "../../directive-CMT2vEDg.js";
|
|
9
|
+
import { createEdgeState } from "../../utils/edgeState.js";
|
|
10
|
+
import { generateId } from "../../utils/id.js";
|
|
11
|
+
import { writablesForProps, stateStores } from "../../utils/stores.js";
|
|
12
|
+
import { createWidgetFactory } from "../../utils/widget.js";
|
|
13
|
+
import { a as createTypeStringSpacedArray, d as typeBoolean, l as typeStringOrNull, c as createTypeEnum } from "../../writables-_7BriMb2.js";
|
|
14
|
+
const verticalPlacement = ["top", "top-start", "top-end", "bottom", "bottom-start", "bottom-end"];
|
|
15
|
+
const horizontalPlacement = ["end", "end-end", "end-start", "start", "start-end", "start-start"];
|
|
16
|
+
const defaultPlacement = [...verticalPlacement, ...horizontalPlacement];
|
|
17
|
+
const fadeTransition = createSimpleClassTransition({
|
|
18
|
+
animationPendingClasses: ["df-fade"],
|
|
19
|
+
animationPendingShowClasses: ["df-show"],
|
|
20
|
+
showClasses: ["df-show", "df-fade"],
|
|
21
|
+
hideClasses: ["df-hidden", "df-fade"]
|
|
22
|
+
});
|
|
23
|
+
const defaultTooltipConfig = {
|
|
24
|
+
animated: true,
|
|
25
|
+
content: "",
|
|
26
|
+
disabled: false,
|
|
27
|
+
placement: defaultPlacement,
|
|
28
|
+
size: "md"
|
|
29
|
+
};
|
|
30
|
+
const tooltipConfigValidator = {
|
|
31
|
+
animated: typeBoolean,
|
|
32
|
+
content: typeStringOrNull,
|
|
33
|
+
disabled: typeBoolean,
|
|
34
|
+
placement: createTypeStringSpacedArray((placement) => {
|
|
35
|
+
if (placement === "auto") {
|
|
36
|
+
return defaultPlacement;
|
|
37
|
+
} else if (placement === "vertical") {
|
|
38
|
+
return verticalPlacement;
|
|
39
|
+
} else if (placement === "horizontal") {
|
|
40
|
+
return horizontalPlacement;
|
|
41
|
+
}
|
|
42
|
+
return typePlacement.normalizeValue(placement);
|
|
43
|
+
}),
|
|
44
|
+
size: createTypeEnum(["sm", "md", "lg"])
|
|
45
|
+
};
|
|
46
|
+
const DEBOUNCE_DELAY = 200;
|
|
47
|
+
const createTooltip = createWidgetFactory(
|
|
48
|
+
"tooltip",
|
|
49
|
+
(config) => {
|
|
50
|
+
const [{ placement$, animated$, disabled$, content$, ...stateProps }, patch] = writablesForProps(
|
|
51
|
+
defaultTooltipConfig,
|
|
52
|
+
config,
|
|
53
|
+
tooltipConfigValidator
|
|
54
|
+
);
|
|
55
|
+
const floating = createPositioning({
|
|
56
|
+
props: {
|
|
57
|
+
placement: placement$
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
const { directive: hasFocusDirective, hasFocus$ } = createHasFocus();
|
|
61
|
+
const forceVisibleOnFocus$ = writable(false);
|
|
62
|
+
const hasVisibleFocus$ = derived(
|
|
63
|
+
[hasFocus$, activeElement$, forceVisibleOnFocus$],
|
|
64
|
+
([hasFocus, activeElement, forceVisibleOnFocus], set) => {
|
|
65
|
+
if (hasFocus) {
|
|
66
|
+
if (forceVisibleOnFocus || activeElement?.matches(":focus-visible")) {
|
|
67
|
+
set(true);
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
set(false);
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
false
|
|
74
|
+
);
|
|
75
|
+
const debouncedHasVisibleFocus$ = debounceSignal(hasVisibleFocus$, (value) => value ? DEBOUNCE_DELAY : -1);
|
|
76
|
+
const { directive: hasMouseInsideDirective, hasMouseInside$ } = createHasMouseInside();
|
|
77
|
+
const debouncedHasMouseInside$ = debounceSignal(hasMouseInside$, DEBOUNCE_DELAY);
|
|
78
|
+
const visible$ = createEdgeState(
|
|
79
|
+
{
|
|
80
|
+
mouseInside: debouncedHasMouseInside$,
|
|
81
|
+
hasVisibleFocus: debouncedHasVisibleFocus$
|
|
82
|
+
},
|
|
83
|
+
computed(() => disabled$() || !content$() || floating.stores.referenceHidden$())
|
|
84
|
+
);
|
|
85
|
+
const transition = createTransition({
|
|
86
|
+
props: {
|
|
87
|
+
transition: fadeTransition,
|
|
88
|
+
visible: visible$,
|
|
89
|
+
animated: animated$,
|
|
90
|
+
animatedOnInit: true
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
const escDismiss$ = readable(void 0, {
|
|
94
|
+
onUse: () => addEvent(
|
|
95
|
+
document.documentElement,
|
|
96
|
+
"keydown",
|
|
97
|
+
(event) => {
|
|
98
|
+
if (visible$() && event.key === "Escape") {
|
|
99
|
+
visible$.set(false);
|
|
100
|
+
event.preventDefault();
|
|
101
|
+
event.stopPropagation();
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
{ capture: true }
|
|
105
|
+
)
|
|
106
|
+
});
|
|
107
|
+
const id$ = computed(generateId);
|
|
108
|
+
return {
|
|
109
|
+
...stateStores({
|
|
110
|
+
...stateProps,
|
|
111
|
+
content$,
|
|
112
|
+
animated$,
|
|
113
|
+
disabled$,
|
|
114
|
+
placement$,
|
|
115
|
+
visible$: transition.stores.visible$,
|
|
116
|
+
hidden$: transition.stores.hidden$
|
|
117
|
+
}),
|
|
118
|
+
patch,
|
|
119
|
+
api: {},
|
|
120
|
+
directives: {
|
|
121
|
+
referenceDirective: mergeDirectives(
|
|
122
|
+
floating.directives.referenceDirective,
|
|
123
|
+
hasFocusDirective,
|
|
124
|
+
hasMouseInsideDirective,
|
|
125
|
+
createAttributesDirective(() => ({
|
|
126
|
+
attributes: {
|
|
127
|
+
"aria-describedby": computed(() => transition.stores.hidden$() ? void 0 : id$())
|
|
128
|
+
},
|
|
129
|
+
styles: {
|
|
130
|
+
// prevents the trigger element from being selected when long-pressing on touch devices
|
|
131
|
+
userSelect: computed(() => disabled$() ? void 0 : "none")
|
|
132
|
+
},
|
|
133
|
+
events: {
|
|
134
|
+
contextmenu: (event) => {
|
|
135
|
+
if (event.pointerType === "touch" && !disabled$()) {
|
|
136
|
+
event.preventDefault();
|
|
137
|
+
if (hasVisibleFocus$()) {
|
|
138
|
+
visible$.set(true);
|
|
139
|
+
} else {
|
|
140
|
+
forceVisibleOnFocus$.set(true);
|
|
141
|
+
event.currentTarget?.focus?.();
|
|
142
|
+
forceVisibleOnFocus$.set(false);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}))
|
|
148
|
+
),
|
|
149
|
+
floatingDirective: mergeDirectives(
|
|
150
|
+
floating.directives.floatingDirective,
|
|
151
|
+
transition.directives.directive,
|
|
152
|
+
hasMouseInsideDirective,
|
|
153
|
+
directiveSubscribe(escDismiss$),
|
|
154
|
+
createAttributesDirective(() => ({
|
|
155
|
+
attributes: {
|
|
156
|
+
role: readable("tooltip"),
|
|
157
|
+
id: id$
|
|
158
|
+
},
|
|
159
|
+
events: {
|
|
160
|
+
mousedown: (event) => {
|
|
161
|
+
if (hasVisibleFocus$() && debouncedHasMouseInside$() && !event.defaultPrevented) {
|
|
162
|
+
visible$.skipNextSourceValue("hasVisibleFocus", false);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}))
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
export {
|
|
173
|
+
createTooltip
|
|
174
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type Placement } from '../../services/positioning';
|
|
2
|
+
import type { Directive, SSRHTMLElement, Widget, WidgetFactory } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Valid placement values for the tooltip.
|
|
5
|
+
* Includes all individual {@link Placement} values plus `'auto'`, `'vertical'` and `'horizontal'` shortcuts.
|
|
6
|
+
*
|
|
7
|
+
* - `'auto'` expands to `'vertical horizontal'`
|
|
8
|
+
* - `'vertical'` expands to `'top top-start top-end bottom bottom-start bottom-end'`
|
|
9
|
+
* - `'horizontal'` expands to `'end end-end end-start start start-end start-start'`
|
|
10
|
+
*/
|
|
11
|
+
export type TooltipPlacement = Placement | 'auto' | 'vertical' | 'horizontal';
|
|
12
|
+
export type TooltipSize = 'sm' | 'md' | 'lg';
|
|
13
|
+
export interface TooltipCommonPropsAndState {
|
|
14
|
+
/**
|
|
15
|
+
* Text content to be displayed inside the tooltip.
|
|
16
|
+
*/
|
|
17
|
+
content: string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Size of the tooltip.
|
|
20
|
+
*/
|
|
21
|
+
size: TooltipSize;
|
|
22
|
+
/**
|
|
23
|
+
* Whether showing or hiding the tooltip should be animated.
|
|
24
|
+
*/
|
|
25
|
+
animated: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the tooltip is disabled. When `true`, the tooltip will not be displayed, even if the reference element is focused, hovered or long-pressed.
|
|
28
|
+
*/
|
|
29
|
+
disabled: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* List of placements, in order of preference. The first valid placement will be used.
|
|
32
|
+
*/
|
|
33
|
+
placement: Placement[];
|
|
34
|
+
}
|
|
35
|
+
export interface TooltipState extends TooltipCommonPropsAndState {
|
|
36
|
+
/**
|
|
37
|
+
* Whether the tooltip is currently visible.
|
|
38
|
+
*/
|
|
39
|
+
visible: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the tooltip is currently hidden. Note that there can be a delay between when `visible` becomes false and when `hidden` becomes true (while the transition is running if animated is true).
|
|
42
|
+
*/
|
|
43
|
+
hidden: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface TooltipProps extends TooltipCommonPropsAndState {
|
|
46
|
+
}
|
|
47
|
+
export interface TooltipDirectives {
|
|
48
|
+
/**
|
|
49
|
+
* Directive to attach to the reference element
|
|
50
|
+
*/
|
|
51
|
+
referenceDirective: Directive<void, SSRHTMLElement>;
|
|
52
|
+
/**
|
|
53
|
+
* Directive to attach to the floating element
|
|
54
|
+
*/
|
|
55
|
+
floatingDirective: Directive<void, SSRHTMLElement>;
|
|
56
|
+
}
|
|
57
|
+
export type TooltipWidget = Widget<TooltipProps, TooltipState, Record<string, never>, TooltipDirectives>;
|
|
58
|
+
/**
|
|
59
|
+
* Create a TooltipWidget with given config props
|
|
60
|
+
* @param config - an optional tooltip config
|
|
61
|
+
* @returns a TooltipWidget
|
|
62
|
+
*/
|
|
63
|
+
export declare const createTooltip: WidgetFactory<TooltipWidget>;
|
package/components/tree/index.js
CHANGED
|
@@ -221,10 +221,13 @@ function clsx() {
|
|
|
221
221
|
for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
|
|
222
222
|
return n;
|
|
223
223
|
}
|
|
224
|
-
const isBrowserHTMLElement = BROWSER ? (
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
224
|
+
const isBrowserHTMLElement = BROWSER ? (
|
|
225
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
226
|
+
((element) => {
|
|
227
|
+
const contentWindow = element?.ownerDocument?.defaultView ?? window;
|
|
228
|
+
return element instanceof contentWindow.HTMLElement;
|
|
229
|
+
})
|
|
230
|
+
) : (
|
|
228
231
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
229
232
|
((element) => false)
|
|
230
233
|
);
|
|
@@ -4,12 +4,12 @@ import { createPointerdownPositionDirective } from "./services/pointerdownPositi
|
|
|
4
4
|
import { portal } from "./services/portal.js";
|
|
5
5
|
import { siblingsInert } from "./services/siblingsInert.js";
|
|
6
6
|
import { createTransition } from "./services/transitions/baseTransitions.js";
|
|
7
|
-
import { b as bindDirective, i as createBrowserStoreDirective, s as mergeDirectives, g as createAttributesDirective, q as isBrowserHTMLElement, f as conditionalDirective, o as directiveSubscribe } from "./directive-
|
|
7
|
+
import { b as bindDirective, i as createBrowserStoreDirective, s as mergeDirectives, g as createAttributesDirective, q as isBrowserHTMLElement, f as conditionalDirective, o as directiveSubscribe } from "./directive-CMT2vEDg.js";
|
|
8
8
|
import { noop } from "./utils/func.js";
|
|
9
|
-
import { a as revertScrollbars, r as removeScrollbars } from "./scrollbars-
|
|
9
|
+
import { a as revertScrollbars, r as removeScrollbars } from "./scrollbars-ChGk75QR.js";
|
|
10
10
|
import { writablesForProps, bindableProp, stateStores, true$ } from "./utils/stores.js";
|
|
11
11
|
import { createWidgetFactory } from "./utils/widget.js";
|
|
12
|
-
import {
|
|
12
|
+
import { d as typeBoolean, j as typeNumberOrNull, f as typeFunction, g as typeHTMLElementOrNull, k as typeString, c as createTypeEnum } from "./writables-_7BriMb2.js";
|
|
13
13
|
import { g as getTextDirection } from "./textDirection-cNgt24LJ.js";
|
|
14
14
|
function getDrawerDefaultConfig() {
|
|
15
15
|
return {
|
|
@@ -36,6 +36,7 @@ const defaultDrawerConfig = {
|
|
|
36
36
|
onResizingChange: noop,
|
|
37
37
|
resizable: false,
|
|
38
38
|
backdrop: true,
|
|
39
|
+
closeOnBackdropClick: true,
|
|
39
40
|
bodyScroll: false,
|
|
40
41
|
size: null,
|
|
41
42
|
focusOnInit: true,
|
|
@@ -62,6 +63,7 @@ const configValidator = {
|
|
|
62
63
|
onResizingChange: typeFunction,
|
|
63
64
|
resizable: typeBoolean,
|
|
64
65
|
backdrop: typeBoolean,
|
|
66
|
+
closeOnBackdropClick: typeBoolean,
|
|
65
67
|
bodyScroll: typeBoolean,
|
|
66
68
|
size: typeNumberOrNull,
|
|
67
69
|
focusOnInit: typeBoolean,
|
|
@@ -96,6 +98,7 @@ const createDrawer = createWidgetFactory(
|
|
|
96
98
|
focusOnInit$,
|
|
97
99
|
configuration$,
|
|
98
100
|
position$,
|
|
101
|
+
closeOnBackdropClick$,
|
|
99
102
|
...stateProps
|
|
100
103
|
},
|
|
101
104
|
patch
|
|
@@ -189,7 +192,11 @@ const createDrawer = createWidgetFactory(
|
|
|
189
192
|
"data-agnos-ignore-inert": true$
|
|
190
193
|
},
|
|
191
194
|
events: {
|
|
192
|
-
click: () =>
|
|
195
|
+
click: () => {
|
|
196
|
+
if (closeOnBackdropClick$()) {
|
|
197
|
+
void transition.api.hide();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
193
200
|
}
|
|
194
201
|
}));
|
|
195
202
|
const direction$ = computed(() => {
|
|
@@ -222,11 +229,11 @@ const createDrawer = createWidgetFactory(
|
|
|
222
229
|
let isResizing = false;
|
|
223
230
|
return {
|
|
224
231
|
onMove(event2) {
|
|
225
|
-
setSize(startSize + directionFactor * direction * (event2[clientXorY] - startPos));
|
|
226
232
|
if (!isResizing) {
|
|
227
233
|
isResizing = true;
|
|
228
234
|
onResizingChange$()(true);
|
|
229
235
|
}
|
|
236
|
+
setSize(startSize + directionFactor * direction * (event2[clientXorY] - startPos));
|
|
230
237
|
},
|
|
231
238
|
onEnd() {
|
|
232
239
|
drawerElement.style[isVertical ? "height" : "width"] = "";
|