@design-factory/core 21.1.0 → 22.0.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/{accordion-D9ba0XYq.js → accordion-DUFLBQkV.js} +90 -28
  2. package/alert-Db6cG6JE.js +125 -0
  3. package/{collapse-Bn8iHKrd.js → collapse-D8Jo56k9.js} +2 -2
  4. package/{common-DFyZvkII.js → common-CP4amR0Z.js} +2 -2
  5. package/components/accordion/accordion.d.ts +80 -22
  6. package/components/accordion/index.js +1 -1
  7. package/components/alert/alert.d.ts +77 -8
  8. package/components/alert/common.d.ts +9 -9
  9. package/components/alert/index.js +2 -3
  10. package/components/carousel/index.js +2 -2
  11. package/components/collapse/index.js +1 -1
  12. package/components/drawer/drawer.d.ts +13 -0
  13. package/components/drawer/index.js +1 -1
  14. package/components/dropdown/dropdown.d.ts +110 -0
  15. package/components/dropdown/index.d.ts +1 -0
  16. package/components/dropdown/index.js +5 -0
  17. package/components/modal/index.js +1 -1
  18. package/components/pagination/index.js +1 -1
  19. package/components/progressbar/index.js +1 -1
  20. package/components/rating/index.js +1 -1
  21. package/components/slider/index.js +1 -1
  22. package/components/slider/slider.d.ts +23 -4
  23. package/components/toast/index.js +1 -1
  24. package/components/tooltip/index.d.ts +1 -0
  25. package/components/tooltip/index.js +174 -0
  26. package/components/tooltip/tooltip.d.ts +63 -0
  27. package/components/tree/index.js +1 -1
  28. package/{directive-CNNSo5Yn.js → directive-CMT2vEDg.js} +7 -4
  29. package/{drawer-CoBXUPyv.js → drawer-D4xSbhcT.js} +19 -5
  30. package/dropdown-Bjj2ql6d.js +246 -0
  31. package/index.d.ts +3 -1
  32. package/index.js +45 -39
  33. package/isFocusable-C2iRr0zh.js +72 -0
  34. package/{modal-BH9nrwVz.js → modal-CQWh2Sm5.js} +3 -3
  35. package/package.json +1 -1
  36. package/{pagination-BQWusWXN.js → pagination-DIRcpdRE.js} +2 -2
  37. package/{progressbar-S1pNn5rM.js → progressbar-Bth8r3Qu.js} +2 -2
  38. package/{promise-D-RZVPuv.js → promise-CkIc0KKt.js} +3 -3
  39. package/{rating-DWgGgwk3.js → rating-DLsgFSyB.js} +2 -2
  40. package/services/extendWidget.d.ts +1 -1
  41. package/services/focusElement.js +2 -2
  42. package/services/focustrack.js +2 -2
  43. package/services/matchMedia.js +1 -1
  44. package/services/mousetrack.d.ts +34 -0
  45. package/services/mousetrack.js +41 -0
  46. package/services/navManager.js +2 -2
  47. package/services/pointerdownPosition.js +1 -1
  48. package/services/portal.js +1 -1
  49. package/services/positioning.d.ts +101 -0
  50. package/services/positioning.js +104 -0
  51. package/services/resizeObserver.js +1 -1
  52. package/services/siblingsInert.js +1 -1
  53. package/services/transitions/baseTransitions.js +8 -8
  54. package/services/transitions/collapse.d.ts +4 -0
  55. package/services/transitions/collapse.js +23 -19
  56. package/services/transitions/cssTransitions.js +2 -2
  57. package/services/transitions/simpleClassTransition.js +1 -1
  58. package/{slider-Br_Qiopx.js → slider-tH5g55yQ.js} +132 -97
  59. package/{toaster-BUBzFeJM.js → toaster-BS9qeRLF.js} +3 -3
  60. package/{tree-vD7ZkV8Z.js → tree-DW6iLxdw.js} +2 -2
  61. package/types.d.ts +8 -1
  62. package/utils/debounceSignal.d.ts +11 -0
  63. package/utils/debounceSignal.js +18 -0
  64. package/utils/directive.js +1 -1
  65. package/utils/edgeState.d.ts +23 -0
  66. package/utils/edgeState.js +43 -0
  67. package/utils/internal/isFocusable.d.ts +40 -0
  68. package/utils/stores.d.ts +2 -16
  69. package/utils/stores.js +5 -24
  70. package/utils/writables.d.ts +27 -13
  71. package/utils/writables.js +12 -11
  72. package/{writables-DYGjj5T3.js → writables-_7BriMb2.js} +37 -12
  73. package/accordion-B0vs8JWM.cjs +0 -314
  74. package/alert-AhaliJ17.cjs +0 -9
  75. package/alert-Cb9FhbFQ.js +0 -10
  76. package/collapse-BnWw4Hnc.cjs +0 -94
  77. package/common-B5jS-Ih_.cjs +0 -73
  78. package/components/accordion/index.cjs +0 -7
  79. package/components/alert/index.cjs +0 -5
  80. package/components/carousel/index.cjs +0 -292
  81. package/components/collapse/index.cjs +0 -5
  82. package/components/drawer/index.cjs +0 -5
  83. package/components/modal/index.cjs +0 -8
  84. package/components/pagination/index.cjs +0 -5
  85. package/components/progressbar/index.cjs +0 -5
  86. package/components/rating/index.cjs +0 -5
  87. package/components/slider/index.cjs +0 -5
  88. package/components/toast/index.cjs +0 -7
  89. package/components/tree/index.cjs +0 -5
  90. package/config.cjs +0 -36
  91. package/directive-DyTodNPd.cjs +0 -523
  92. package/drawer-Ca_ktkEs.cjs +0 -328
  93. package/index.cjs +0 -134
  94. package/isFocusable-Ckwus82R.js +0 -32
  95. package/isFocusable-DfzDLeAN.cjs +0 -31
  96. package/modal-Dxdw2Pkv.cjs +0 -252
  97. package/pagination-BLVa1UsZ.cjs +0 -254
  98. package/progressbar-RopgvVeA.cjs +0 -86
  99. package/promise-CxCD3NYv.cjs +0 -118
  100. package/rating-DZ3OQgtt.cjs +0 -183
  101. package/scrollbars-f651ntzz.cjs +0 -33
  102. package/services/extendWidget.cjs +0 -41
  103. package/services/floatingUI.cjs +0 -111
  104. package/services/floatingUI.d.ts +0 -76
  105. package/services/floatingUI.js +0 -111
  106. package/services/focusElement.cjs +0 -46
  107. package/services/focustrack.cjs +0 -47
  108. package/services/hash.cjs +0 -15
  109. package/services/intersection.cjs +0 -53
  110. package/services/matchMedia.cjs +0 -14
  111. package/services/navManager.cjs +0 -166
  112. package/services/pointerdownPosition.cjs +0 -60
  113. package/services/portal.cjs +0 -42
  114. package/services/resizeObserver.cjs +0 -54
  115. package/services/siblingsInert.cjs +0 -44
  116. package/services/transitions/baseTransitions.cjs +0 -186
  117. package/services/transitions/collapse.cjs +0 -40
  118. package/services/transitions/cssTransitions.cjs +0 -32
  119. package/services/transitions/simpleClassTransition.cjs +0 -37
  120. package/slider-pgDq1V5r.cjs +0 -807
  121. package/textDirection-zqcZ5-eK.cjs +0 -3
  122. package/toaster-Dlube4Ya.cjs +0 -161
  123. package/tree-Chcy4ulJ.cjs +0 -228
  124. package/types.cjs +0 -6
  125. package/utils/directive.cjs +0 -28
  126. package/utils/func.cjs +0 -7
  127. package/utils/id.cjs +0 -5
  128. package/utils/stores.cjs +0 -172
  129. package/utils/widget.cjs +0 -8
  130. package/utils/writables.cjs +0 -16
  131. package/writables-Dt68gADJ.cjs +0 -102
@@ -1,14 +1,79 @@
1
1
  import type { CommonAlertApi, CommonAlertDirectives, CommonAlertProps, CommonAlertState } from './common';
2
- import type { Widget, WidgetFactory } from '../../types';
2
+ import type { Directive, Widget, WidgetFactory } from '../../types';
3
+ export type AlertSize = 'sm' | 'md' | 'lg';
4
+ export type AlertType = 'success' | 'info' | 'warning' | 'danger' | 'tip';
5
+ export type AlertRole = 'alert' | 'status';
6
+ export type AlertAppearance = 'default' | 'banner';
7
+ type AlertIcons = Record<AlertType | 'default', string>;
8
+ interface AlertExtraPropsAndState {
9
+ /**
10
+ * Type of the alert.
11
+ */
12
+ type: AlertType;
13
+ /**
14
+ * Visual appearance variant for alert chrome.
15
+ */
16
+ appearance: AlertAppearance;
17
+ /**
18
+ * Size of the alert.
19
+ */
20
+ size: AlertSize;
21
+ /**
22
+ * Icon classes by alert type.
23
+ */
24
+ icons: AlertIcons;
25
+ /**
26
+ * Icon class for the collapse action.
27
+ */
28
+ collapseIcon: string;
29
+ /**
30
+ * Icon class for the expand action.
31
+ */
32
+ expandIcon: string;
33
+ /**
34
+ * Label shown when alert details can be expanded.
35
+ */
36
+ expandLabel: string;
37
+ /**
38
+ * Label shown when alert details can be collapsed.
39
+ */
40
+ collapseLabel: string;
41
+ /**
42
+ * If `true`, alert details can be toggled with a collapse trigger.
43
+ */
44
+ expandable: boolean;
45
+ /**
46
+ * If `true`, the collapsible content is shown.
47
+ */
48
+ expanded: boolean;
49
+ }
50
+ interface AlertExtraProps extends AlertExtraPropsAndState {
51
+ /**
52
+ * Callback called when collapsible content is hidden.
53
+ */
54
+ onCollapsed: () => void;
55
+ /**
56
+ * Callback called when collapsible content is shown.
57
+ */
58
+ onExpanded: () => void;
59
+ }
3
60
  /**
4
61
  * Represents the state of an alert component.
5
62
  */
6
- export interface AlertState extends CommonAlertState {
63
+ export interface AlertState extends CommonAlertState, AlertExtraPropsAndState {
64
+ /**
65
+ * Computed icon class for current alert type.
66
+ */
67
+ icon: string;
68
+ /**
69
+ * Computed ARIA live region role for current alert type.
70
+ */
71
+ role: AlertRole;
7
72
  }
8
73
  /**
9
74
  * Represents the properties for the alert component.
10
75
  */
11
- export interface AlertProps extends CommonAlertProps {
76
+ export interface AlertProps extends CommonAlertProps, AlertExtraProps {
12
77
  }
13
78
  /**
14
79
  * Represents the API for an alert component.
@@ -19,19 +84,23 @@ export interface AlertApi extends CommonAlertApi {
19
84
  * Represents the directives for an alert component.
20
85
  */
21
86
  export interface AlertDirectives extends CommonAlertDirectives {
87
+ /**
88
+ * Directive to apply the collapse animation to alert details.
89
+ */
90
+ collapseDirective: Directive;
91
+ /**
92
+ * Directive to apply on the collapse trigger element.
93
+ */
94
+ collapseTriggerDirective: Directive;
22
95
  }
23
96
  /**
24
97
  * Represents an alert widget with specific properties, state, API, and directives.
25
98
  */
26
99
  export type AlertWidget = Widget<AlertProps, AlertState, AlertApi, AlertDirectives>;
27
- /**
28
- * Retrieve a shallow copy of the default alert config
29
- * @returns the default alert config
30
- */
31
- export declare function getAlertDefaultConfig(): AlertProps;
32
100
  /**
33
101
  * Create an AlertWidget with given config props
34
102
  * @param config - an optional alert config
35
103
  * @returns an AlertWidget
36
104
  */
37
105
  export declare const createAlert: WidgetFactory<AlertWidget>;
106
+ export {};
@@ -24,6 +24,15 @@ export interface CommonAlertCommonPropsAndState extends WidgetsCommonPropsAndSta
24
24
  * @defaultValue `'Close'`
25
25
  */
26
26
  ariaCloseButtonLabel: string;
27
+ /**
28
+ * If `true`, the alert closing will be animated.
29
+ *
30
+ * Animation is triggered when clicked on the close button (×),
31
+ * via the `.close()` function or the visible prop is changed
32
+ *
33
+ * @defaultValue `true`
34
+ */
35
+ animated: boolean;
27
36
  }
28
37
  /**
29
38
  * Represents the state of a common alert component.
@@ -85,15 +94,6 @@ export interface CommonAlertProps extends CommonAlertCommonPropsAndState {
85
94
  * @defaultValue `false`
86
95
  */
87
96
  animatedOnInit: boolean;
88
- /**
89
- * If `true`, alert closing will be animated.
90
- *
91
- * Animation is triggered when clicked on the close button (×),
92
- * via the `.close()` function or the visible prop is changed
93
- *
94
- * @defaultValue `true`
95
- */
96
- animated: boolean;
97
97
  }
98
98
  /**
99
99
  * Interface representing the common API for alert components.
@@ -1,5 +1,4 @@
1
- import { c, g } from "../../alert-Cb9FhbFQ.js";
1
+ import { c } from "../../alert-Db6cG6JE.js";
2
2
  export {
3
- c as createAlert,
4
- g as getAlertDefaultConfig
3
+ c as createAlert
5
4
  };
@@ -1,8 +1,8 @@
1
1
  import { writablesForProps, true$, stateStores } from "../../utils/stores.js";
2
- import { b as bindDirective, d as browserDirective, g as createAttributesDirective, s as mergeDirectives } from "../../directive-CNNSo5Yn.js";
2
+ import { b as bindDirective, d as browserDirective, g as createAttributesDirective, s as mergeDirectives } from "../../directive-CMT2vEDg.js";
3
3
  import EmblaCarousel from "embla-carousel";
4
4
  import { writable, computed, asReadable, readable } from "@amadeus-it-group/tansu";
5
- import { e as typeFunction, j as typeString, b as typeBoolean, g as typeNumber, k as typeStringOrNull, a as typeArray, c as createTypeEnum } from "../../writables-DYGjj5T3.js";
5
+ import { f as typeFunction, k as typeString, d as typeBoolean, h as typeNumber, l as typeStringOrNull, b as typeArray, c as createTypeEnum } from "../../writables-_7BriMb2.js";
6
6
  import { createNavManager } from "../../services/navManager.js";
7
7
  import { createWidgetFactory } from "../../utils/widget.js";
8
8
  const defaultConfig = {
@@ -1,4 +1,4 @@
1
- import { c, g } from "../../collapse-Bn8iHKrd.js";
1
+ import { c, g } from "../../collapse-D8Jo56k9.js";
2
2
  export {
3
3
  c as createCollapse,
4
4
  g as getCollapseDefaultConfig
@@ -107,6 +107,13 @@ export interface DrawerProps extends DrawerCommonPropsAndState {
107
107
  * @defaultValue `true`
108
108
  */
109
109
  animated: boolean;
110
+ /**
111
+ * If `true` the backdrop fade in / out will be animated.
112
+ * Will use the `animated` property if set to `null`.
113
+ *
114
+ * @defaultValue `null`
115
+ */
116
+ backdropAnimated: boolean | null;
110
117
  /**
111
118
  * aria-labelledby attribute to use for the drawer element.
112
119
  *
@@ -125,6 +132,12 @@ export interface DrawerProps extends DrawerCommonPropsAndState {
125
132
  * @defaultValue `true`
126
133
  */
127
134
  backdrop: boolean;
135
+ /**
136
+ * If `true` the drawer will be closed when clicking on the backdrop, otherwise the backdrop is static and non iteractive.
137
+ *
138
+ * @defaultValue `true`
139
+ */
140
+ closeOnBackdropClick: boolean;
128
141
  /**
129
142
  * If `true` allows body scrolling when the drawer is open.
130
143
  *
@@ -1,4 +1,4 @@
1
- import { c, g } from "../../drawer-CoBXUPyv.js";
1
+ import { c, g } from "../../drawer-D4xSbhcT.js";
2
2
  export {
3
3
  c as createDrawer,
4
4
  g as getDrawerDefaultConfig
@@ -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';
@@ -0,0 +1,5 @@
1
+ import { c, g } from "../../dropdown-Bjj2ql6d.js";
2
+ export {
3
+ c as createDropdown,
4
+ g as getDropdownDefaultConfig
5
+ };
@@ -1,4 +1,4 @@
1
- import { c, g, m, a, b } from "../../modal-BH9nrwVz.js";
1
+ import { c, g, m, a, b } from "../../modal-CQWh2Sm5.js";
2
2
  export {
3
3
  c as createModal,
4
4
  g as getModalDefaultConfig,
@@ -1,4 +1,4 @@
1
- import { c, g } from "../../pagination-BQWusWXN.js";
1
+ import { c, g } from "../../pagination-DIRcpdRE.js";
2
2
  export {
3
3
  c as createPagination,
4
4
  g as getPaginationDefaultConfig
@@ -1,4 +1,4 @@
1
- import { c, g } from "../../progressbar-S1pNn5rM.js";
1
+ import { c, g } from "../../progressbar-Bth8r3Qu.js";
2
2
  export {
3
3
  c as createProgressbar,
4
4
  g as getProgressbarDefaultConfig
@@ -1,4 +1,4 @@
1
- import { c, g } from "../../rating-DWgGgwk3.js";
1
+ import { c, g } from "../../rating-DLsgFSyB.js";
2
2
  export {
3
3
  c as createRating,
4
4
  g as getRatingDefaultConfig
@@ -1,4 +1,4 @@
1
- import { c, g } from "../../slider-Br_Qiopx.js";
1
+ import { c, g } from "../../slider-tH5g55yQ.js";
2
2
  export {
3
3
  c as createSlider,
4
4
  g as getSliderDefaultConfig
@@ -162,16 +162,22 @@ interface SliderCommonPropsAndState extends WidgetsCommonPropsAndState {
162
162
  */
163
163
  showTicks: boolean;
164
164
  /**
165
- * It `true` slider display is inversed
165
+ * If `true`, visually flips the slider direction (both horizontal and vertical).
166
166
  *
167
167
  * @defaultValue `false`
168
168
  */
169
- rtl: boolean;
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;
@@ -1,4 +1,4 @@
1
- import { T, c, d, g } from "../../toaster-BUBzFeJM.js";
1
+ import { T, c, d, g } from "../../toaster-BS9qeRLF.js";
2
2
  export {
3
3
  T as Toaster,
4
4
  c as createToast,
@@ -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
+ void transition.api.toggle(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
+ void transition.api.toggle(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>;
@@ -1,4 +1,4 @@
1
- import { c, g } from "../../tree-vD7ZkV8Z.js";
1
+ import { c, g } from "../../tree-DW6iLxdw.js";
2
2
  export {
3
3
  c as createTree,
4
4
  g as getTreeDefaultConfig