@agnos-ui/core 0.1.0 → 0.2.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.
@@ -3,7 +3,7 @@ import type { Directive, PropsConfig, SlotContent, Widget, WidgetSlotContext } f
3
3
  import type { WidgetsCommonPropsAndState } from '../commonProps';
4
4
  export interface AccordionProps extends WidgetsCommonPropsAndState {
5
5
  /**
6
- * If `true`, only one item at the time can stay open.
6
+ * If `true`, only one accordion-item at the time can stay open.
7
7
  */
8
8
  closeOthers: boolean;
9
9
  /**
@@ -25,7 +25,7 @@ export interface AccordionProps extends WidgetsCommonPropsAndState {
25
25
  */
26
26
  itemId: string;
27
27
  /**
28
- * If `true`, the content of the accordion-item collapse will be removed from the DOM. It will be just hidden otherwise.
28
+ * If `true`, the accordion-item body container will be removed from the DOM when the accordion-item is collapsed. It will be just hidden otherwise.
29
29
  *
30
30
  * It is a prop of the accordion-item.
31
31
  */
@@ -50,7 +50,7 @@ export interface AccordionProps extends WidgetsCommonPropsAndState {
50
50
  */
51
51
  itemAnimation: boolean;
52
52
  /**
53
- * The transition to use for the accordion-item collapse when is toggled.
53
+ * The transition to use for the accordion-item body-container when the accordion-item is toggled.
54
54
  *
55
55
  * It is a prop of the accordion-item.
56
56
  */
@@ -77,8 +77,9 @@ export interface AccordionProps extends WidgetsCommonPropsAndState {
77
77
  onItemVisibleChange: (visible: boolean) => void;
78
78
  /**
79
79
  * Structure of the accordion-item. The default item structure is: accordion-item
80
- * contains accordion header and accordion collapse; the accordion header contains the accordion button
81
- * (that contains `slotItemHeader`), while the accordion collapse contains the accordion body (that contains slotItemBody).
80
+ * contains accordion header and accordion-item body container; the accordion header contains the accordion button
81
+ * (that contains `slotItemHeader`), while the accordion-item body container contains the accordion body (that contains `slotItemBody`).
82
+ * The itemTransition it applied on this element.
82
83
  *
83
84
  * It is a prop of the accordion-item.
84
85
  */
@@ -96,31 +97,32 @@ export interface AccordionProps extends WidgetsCommonPropsAndState {
96
97
  */
97
98
  slotItemHeader: SlotContent<AccordionItemContext>;
98
99
  /**
99
- * Classes to add on the accordion-item DOM element.
100
+ * CSS classes to add on the accordion-item DOM element.
100
101
  *
101
102
  * It is a prop of the accordion-item.
102
103
  */
103
104
  itemClass: string;
104
105
  /**
105
- * Classes to add on the accordion-item header DOM element.
106
+ * CSS classes to add on the accordion-item header DOM element.
106
107
  *
107
108
  * It is a prop of the accordion-item.
108
109
  */
109
110
  itemHeaderClass: string;
110
111
  /**
111
- * Classes to add on the accordion-item toggle button DOM element.
112
+ * CSS classes to add on the accordion-item toggle button DOM element.
112
113
  *
113
114
  * It is a prop of the accordion-item.
114
115
  */
115
116
  itemButtonClass: string;
116
117
  /**
117
- * Classes to add on the accordion-item collapse DOM element.
118
+ * CSS classes to add on the accordion-item body container DOM element.
119
+ * The accordion-item body container is the DOM element on what the itemTransition is applied.
118
120
  *
119
121
  * It is a prop of the accordion-item.
120
122
  */
121
- itemCollapseClass: string;
123
+ itemBodyContainerClass: string;
122
124
  /**
123
- * Classes to add on the accordion-item body DOM element.
125
+ * CSS classes to add on the accordion-item body DOM element.
124
126
  *
125
127
  * It is a prop of the accordion-item.
126
128
  */
@@ -244,28 +246,30 @@ export interface AccordionItemCommonPropsAndState {
244
246
  slotItemBody: SlotContent<AccordionItemContext>;
245
247
  /**
246
248
  * Structure of the accordion-item. The default item structure is: accordion-item
247
- * contains accordion header and accordion collapse; the accordion header contains the accordion button
248
- * (that contains `slotItemHeader`), while the accordion collapse contains the accordion body (that contains slotItemBody).
249
+ * contains accordion header and accordion-item body container; the accordion header contains the accordion button
250
+ * (that contains `slotItemHeader`), while the accordion-item body container contains the accordion body (that contains `slotItemBody`).
251
+ * The itemTransition it applied on this element.
249
252
  */
250
253
  slotItemStructure: SlotContent<AccordionItemContext>;
251
254
  /**
252
- * Classes to add on the accordion-item DOM element.
255
+ * CSS classes to add on the accordion-item DOM element.
253
256
  */
254
257
  itemClass: string;
255
258
  /**
256
- * Classes to add on the accordion-item header DOM element.
259
+ * CSS classes to add on the accordion-item header DOM element.
257
260
  */
258
261
  itemHeaderClass: string;
259
262
  /**
260
- * Classes to add on the accordion-item collapse DOM element.
263
+ * CSS classes to add on the accordion-item collapse DOM element.
261
264
  */
262
265
  itemButtonClass: string;
263
266
  /**
264
- * Classes to add on the accordion-item collapse DOM element.
267
+ * CSS classes to add on the accordion-item body container DOM element.
268
+ * The accordion-item body container is the DOM element on what the itemTransition is applied.
265
269
  */
266
- itemCollapseClass: string;
270
+ itemBodyContainerClass: string;
267
271
  /**
268
- * Classes to add on the accordion-item body DOM element.
272
+ * CSS classes to add on the accordion-item body DOM element.
269
273
  */
270
274
  itemBodyClass: string;
271
275
  /**
@@ -279,11 +283,11 @@ export interface AccordionItemProps extends AccordionItemCommonPropsAndState {
279
283
  */
280
284
  itemAnimation: boolean;
281
285
  /**
282
- * The transition to use for the accordion-item collapse when is toggled.
286
+ * The transition to use for the accordion-item body-container when the accordion-item is toggled.
283
287
  */
284
288
  itemTransition: TransitionFn;
285
289
  /**
286
- * If `true`, the content of the accordion-item collapse will be removed from the DOM. It will be just hidden otherwise.
290
+ * If `true`, the accordion-item body container will be removed from the DOM when the accordion-item is collapsed. It will be just hidden otherwise.
287
291
  */
288
292
  itemDestroyOnHide: boolean;
289
293
  /**
@@ -5,10 +5,7 @@ import { computed, writable } from '@amadeus-it-group/tansu';
5
5
  import { noop } from '../../utils/internal/func';
6
6
  import { typeBoolean, typeFunction, typeString } from '../../utils/writables';
7
7
  import { bindDirectiveNoArg, directiveSubscribe, registrationArray } from '../../utils/directive';
8
- let itemId = 0;
9
- function getItemId() {
10
- return `accordion-item-${itemId++}`;
11
- }
8
+ import { generateId } from '../../utils/internal/dom';
12
9
  function adjustItemsCloseOthers(items, openItems, oldOpen) {
13
10
  let keepOpen;
14
11
  if (openItems.length == 2) {
@@ -52,7 +49,7 @@ const defaultAccordionConfig = {
52
49
  itemClass: '',
53
50
  itemHeaderClass: '',
54
51
  itemButtonClass: '',
55
- itemCollapseClass: '',
52
+ itemBodyContainerClass: '',
56
53
  itemBodyClass: '',
57
54
  };
58
55
  const defaultItemConfig = {
@@ -71,7 +68,7 @@ const defaultItemConfig = {
71
68
  itemClass: defaultAccordionConfig.itemClass,
72
69
  itemHeaderClass: defaultAccordionConfig.itemHeaderClass,
73
70
  itemButtonClass: defaultAccordionConfig.itemButtonClass,
74
- itemCollapseClass: defaultAccordionConfig.itemCollapseClass,
71
+ itemBodyContainerClass: defaultAccordionConfig.itemBodyContainerClass,
75
72
  itemBodyClass: defaultAccordionConfig.itemBodyClass,
76
73
  itemHeadingTag: defaultAccordionConfig.itemHeadingTag,
77
74
  };
@@ -99,7 +96,7 @@ const configAccordionValidator = {
99
96
  itemClass: typeString,
100
97
  itemHeaderClass: typeString,
101
98
  itemButtonClass: typeString,
102
- itemCollapseClass: typeString,
99
+ itemBodyContainerClass: typeString,
103
100
  itemBodyClass: typeString,
104
101
  itemHeadingTag: typeString,
105
102
  };
@@ -116,14 +113,14 @@ const configItemValidator = {
116
113
  itemClass: typeString,
117
114
  itemHeaderClass: typeString,
118
115
  itemButtonClass: typeString,
119
- itemCollapseClass: typeString,
116
+ itemBodyContainerClass: typeString,
120
117
  itemBodyClass: typeString,
121
118
  itemHeadingTag: typeString,
122
119
  };
123
120
  function createAccordionItem(accordionOnShown, accordionOnHidden, config) {
124
121
  const [{ itemAnimation$, itemTransition$, itemDestroyOnHide$, onItemShown$, onItemHidden$, onItemVisibleChange$, itemVisible$, itemId$: _dirtyItemId$, itemDisabled$, ...stateProps }, patch,] = writablesForProps(defaultItemConfig, config, configItemValidator);
125
122
  const initDone$ = writable(false);
126
- const _autoItemId$ = computed(() => getItemId());
123
+ const _autoItemId$ = computed(() => generateId());
127
124
  const itemId$ = computed(() => _dirtyItemId$() || _autoItemId$());
128
125
  const shouldBeInDOM$ = computed(() => itemDestroyOnHide$() === false || !itemTransition.state$().hidden);
129
126
  const itemTransition = createTransition({
@@ -183,7 +180,7 @@ function createAccordionItem(accordionOnShown, accordionOnHidden, config) {
183
180
  * @returns a new accordion widget instance
184
181
  */
185
182
  export function createAccordion(config) {
186
- const [{ closeOthers$, onShown$, onHidden$, itemId$, itemAnimation$, itemClass$, itemDisabled$, itemVisible$, itemTransition$, itemDestroyOnHide$, itemBodyClass$, itemButtonClass$, itemCollapseClass$, itemHeaderClass$, itemHeadingTag$, onItemVisibleChange$, onItemHidden$, onItemShown$, slotItemStructure$, slotItemBody$, slotItemHeader$, ...stateProps }, patch,] = writablesForProps(defaultAccordionConfig, config, configAccordionValidator);
183
+ const [{ closeOthers$, onShown$, onHidden$, itemId$, itemAnimation$, itemClass$, itemDisabled$, itemVisible$, itemTransition$, itemDestroyOnHide$, itemBodyClass$, itemButtonClass$, itemBodyContainerClass$, itemHeaderClass$, itemHeadingTag$, onItemVisibleChange$, onItemHidden$, onItemShown$, slotItemStructure$, slotItemBody$, slotItemHeader$, ...stateProps }, patch,] = writablesForProps(defaultAccordionConfig, config, configAccordionValidator);
187
184
  const accordionItemConfig = {
188
185
  itemId: itemId$,
189
186
  itemClass: itemClass$,
@@ -194,7 +191,7 @@ export function createAccordion(config) {
194
191
  itemDestroyOnHide: itemDestroyOnHide$,
195
192
  itemBodyClass: itemBodyClass$,
196
193
  itemButtonClass: itemButtonClass$,
197
- itemCollapseClass: itemCollapseClass$,
194
+ itemBodyContainerClass: itemBodyContainerClass$,
198
195
  itemHeaderClass: itemHeaderClass$,
199
196
  itemHeadingTag: itemHeadingTag$,
200
197
  onItemVisibleChange: onItemVisibleChange$,
@@ -9,9 +9,9 @@ export interface AlertExtraProps {
9
9
  */
10
10
  type: string;
11
11
  }
12
- export interface AlertState extends ExtendWidgetAdaptSlotWidgetProps<CommonAlertState, AlertExtraProps> {
12
+ export interface AlertState extends ExtendWidgetAdaptSlotWidgetProps<CommonAlertState, AlertExtraProps, object> {
13
13
  }
14
- export interface AlertProps extends ExtendWidgetAdaptSlotWidgetProps<CommonAlertProps, AlertExtraProps> {
14
+ export interface AlertProps extends ExtendWidgetAdaptSlotWidgetProps<CommonAlertProps, AlertExtraProps, object> {
15
15
  }
16
16
  export interface AlertApi extends CommonAlertApi {
17
17
  }
@@ -86,6 +86,14 @@ export interface PaginationCommonPropsAndState extends WidgetsCommonPropsAndStat
86
86
  * @defaultValue false
87
87
  */
88
88
  boundaryLinks: boolean;
89
+ /**
90
+ * The template to use for the structure of the pagination component
91
+ * The default structure uses {@link PaginationCommonPropsAndState.slotEllipsis|slotEllipsis}, {@link PaginationCommonPropsAndState.slotFirst|slotFirst},
92
+ * {@link PaginationCommonPropsAndState.slotPrevious|slotPrevious}, {@link PaginationCommonPropsAndState.slotNext|slotNext},
93
+ * {@link PaginationCommonPropsAndState.slotLast|slotLast}, {@link PaginationCommonPropsAndState.slotPages|slotPages},
94
+ * {@link PaginationCommonPropsAndState.slotNumberLabel|slotNumberLabel},
95
+ */
96
+ slotStructure: SlotContent<PaginationContext>;
89
97
  /**
90
98
  * The template to use for the ellipsis slot
91
99
  * for I18n, we suggest to use the global configuration
@@ -201,6 +209,26 @@ export interface PaginationProps extends PaginationCommonPropsAndState {
201
209
  * ```
202
210
  */
203
211
  ariaPageLabel: (processPage: number, pageCount: number) => string;
212
+ /**
213
+ * Factory function providing the href for a "Page" page anchor,
214
+ * based on the current page number
215
+ * @param pageNumber - The index to use in the link
216
+ * @defaultValue
217
+ * ```ts
218
+ * (_pageNumber) => '#'
219
+ * ```
220
+ */
221
+ pageLink: (pageNumber: number) => string;
222
+ }
223
+ export interface DirectionsHrefs {
224
+ /**
225
+ * The href for the 'Previous' navigation link
226
+ */
227
+ previous: string;
228
+ /**
229
+ * The href for the 'Next' direction link
230
+ */
231
+ next: string;
204
232
  }
205
233
  export interface PaginationState extends PaginationCommonPropsAndState {
206
234
  /**
@@ -223,29 +251,33 @@ export interface PaginationState extends PaginationCommonPropsAndState {
223
251
  * The label for each "Page" page link.
224
252
  */
225
253
  pagesLabel: string[];
254
+ /** The hrefs for each "Page" page link */
255
+ pagesHrefs: string[];
256
+ /** The hrefs for the direction links */
257
+ directionsHrefs: DirectionsHrefs;
226
258
  }
227
259
  export interface PaginationActions {
228
260
  /**
229
261
  * To "go" to a specific page
230
262
  * @param page - The page number to select
231
263
  */
232
- select(page: number): void;
264
+ select(page: number, event?: MouseEvent): void;
233
265
  /**
234
266
  * To "go" to the first page
235
267
  */
236
- first(): void;
268
+ first(event?: MouseEvent): void;
237
269
  /**
238
270
  * To "go" to the previous page
239
271
  */
240
- previous(): void;
272
+ previous(event?: MouseEvent): void;
241
273
  /**
242
274
  * To "go" to the next page
243
275
  */
244
- next(): void;
276
+ next(event?: MouseEvent): void;
245
277
  /**
246
278
  * To "go" to the last page
247
279
  */
248
- last(): void;
280
+ last(event?: MouseEvent): void;
249
281
  }
250
282
  export interface PaginationApi {
251
283
  /**
@@ -321,6 +353,16 @@ export declare function getPaginationDefaultConfig(): {
321
353
  * ```
322
354
  */
323
355
  ariaPageLabel: (processPage: number, pageCount: number) => string;
356
+ /**
357
+ * Factory function providing the href for a "Page" page anchor,
358
+ * based on the current page number
359
+ * @param pageNumber - The index to use in the link
360
+ * @defaultValue
361
+ * ```ts
362
+ * (_pageNumber) => '#'
363
+ * ```
364
+ */
365
+ pageLink: (pageNumber: number) => string;
324
366
  /**
325
367
  * The current page.
326
368
  *
@@ -393,6 +435,14 @@ export declare function getPaginationDefaultConfig(): {
393
435
  * @defaultValue false
394
436
  */
395
437
  boundaryLinks: boolean;
438
+ /**
439
+ * The template to use for the structure of the pagination component
440
+ * The default structure uses {@link PaginationCommonPropsAndState.slotEllipsis|slotEllipsis}, {@link PaginationCommonPropsAndState.slotFirst|slotFirst},
441
+ * {@link PaginationCommonPropsAndState.slotPrevious|slotPrevious}, {@link PaginationCommonPropsAndState.slotNext|slotNext},
442
+ * {@link PaginationCommonPropsAndState.slotLast|slotLast}, {@link PaginationCommonPropsAndState.slotPages|slotPages},
443
+ * {@link PaginationCommonPropsAndState.slotNumberLabel|slotNumberLabel},
444
+ */
445
+ slotStructure: SlotContent<PaginationContext>;
396
446
  /**
397
447
  * The template to use for the ellipsis slot
398
448
  * for I18n, we suggest to use the global configuration
@@ -1,9 +1,10 @@
1
1
  import { computed } from '@amadeus-it-group/tansu';
2
2
  import { INVALID_VALUE } from '../../types';
3
- import { bindableDerived, stateStores, writablesForProps } from '../../utils/stores';
3
+ import { bindableProp, stateStores, writablesForProps } from '../../utils/stores';
4
4
  import { clamp, isNumber } from '../../utils/internal/checks';
5
5
  import { typeBoolean, typeFunction, typeNumber, typeString } from '../../utils/writables';
6
6
  import { noop } from '../../utils/internal/func';
7
+ const PAGE_LINK_DEFAULT = '#';
7
8
  const defaultConfig = {
8
9
  page: 1,
9
10
  collectionSize: 0,
@@ -35,7 +36,9 @@ const defaultConfig = {
35
36
  slotNext: '›',
36
37
  slotLast: '»',
37
38
  slotPages: undefined,
39
+ slotStructure: undefined,
38
40
  slotNumberLabel: ({ displayedPage }) => `${displayedPage}`,
41
+ pageLink: (_page) => PAGE_LINK_DEFAULT,
39
42
  };
40
43
  /**
41
44
  * Returns a shallow copy of the default pagination config
@@ -62,6 +65,7 @@ const configValidator = {
62
65
  ariaNextLabel: typeString,
63
66
  ariaLastLabel: typeString,
64
67
  className: typeString,
68
+ pageLink: typeFunction,
65
69
  };
66
70
  /**
67
71
  * Create a PaginationWidget with given config props
@@ -73,7 +77,7 @@ export function createPagination(config) {
73
77
  // dirty inputs that need adjustment:
74
78
  page$: _dirtyPage$,
75
79
  // clean inputs with value validation:
76
- collectionSize$, pageSize$, onPageChange$, pagesFactory$, ariaPageLabel$, ...stateProps }, patch,] = writablesForProps(defaultConfig, config, configValidator);
80
+ collectionSize$, pageSize$, onPageChange$, pagesFactory$, ariaPageLabel$, pageLink$, ...stateProps }, patch,] = writablesForProps(defaultConfig, config, configValidator);
77
81
  // computed
78
82
  // nb total of Pages.
79
83
  const pageCount$ = computed(() => {
@@ -85,7 +89,7 @@ export function createPagination(config) {
85
89
  return pageCount;
86
90
  });
87
91
  // current page
88
- const page$ = bindableDerived(onPageChange$, [_dirtyPage$, pageCount$], ([dirtyPage, pageCount]) => clamp(dirtyPage, pageCount, 1));
92
+ const page$ = bindableProp(_dirtyPage$, onPageChange$, (dirtyPage) => clamp(dirtyPage, pageCount$(), 1));
89
93
  const pages$ = computed(() => pagesFactory$()(page$(), pageCount$()));
90
94
  const nextDisabled$ = computed(() => page$() === pageCount$() || stateProps.disabled$());
91
95
  const previousDisabled$ = computed(() => page$() === 1 || stateProps.disabled$());
@@ -94,6 +98,41 @@ export function createPagination(config) {
94
98
  const pageCount = pageCount$();
95
99
  return pages$().map((page) => ariaPageLabel(page, pageCount));
96
100
  });
101
+ const pagesHrefs$ = computed(() => {
102
+ const pageLinkFactory = pageLink$();
103
+ const pageCount = pageCount$();
104
+ return Array.from({ length: pageCount }, (_, index) => pageLinkFactory(index + 1));
105
+ });
106
+ const directionsHrefs$ = computed(() => {
107
+ const pagesHrefs = pagesHrefs$();
108
+ const pageIndex = page$() - 1;
109
+ return {
110
+ previous: pagesHrefs.at(pageIndex > 0 ? pageIndex - 1 : 0),
111
+ next: pagesHrefs.at(pageIndex + 1) ?? pagesHrefs.at(-1),
112
+ };
113
+ });
114
+ /**
115
+ * Stop event propagation when href is the default value;
116
+ * Update page number when navigation is in the same tab and stop the event propagation;
117
+ * For navigations outside current browser tab let the default behavior, without updating the page number;
118
+ * @param pageNumber current page number
119
+ * @param event UI event triggered when page changed
120
+ * @param pageNavigationHandler change handler callback for navigation elements
121
+ */
122
+ function handleNavigation(pageNumber, event, pageNavigationHandler) {
123
+ if (pagesHrefs$()[pageNumber - 1] === PAGE_LINK_DEFAULT) {
124
+ event?.preventDefault();
125
+ }
126
+ if (!event || !(event.ctrlKey || event.metaKey)) {
127
+ event?.preventDefault();
128
+ if (pageNavigationHandler) {
129
+ page$.update(pageNavigationHandler);
130
+ }
131
+ else {
132
+ page$.set(pageNumber);
133
+ }
134
+ }
135
+ }
97
136
  return {
98
137
  ...stateStores({
99
138
  pageCount$,
@@ -102,6 +141,8 @@ export function createPagination(config) {
102
141
  nextDisabled$,
103
142
  previousDisabled$,
104
143
  pagesLabel$,
144
+ pagesHrefs$,
145
+ directionsHrefs$,
105
146
  ...stateProps,
106
147
  }),
107
148
  patch,
@@ -110,33 +151,38 @@ export function createPagination(config) {
110
151
  * Set the current page pageNumber (starting from 1)
111
152
  * @param pageNumber - Current page number to set.
112
153
  * Value is normalized between 1 and the number of page
154
+ * @param event UI event that triggered the select
113
155
  */
114
- select(pageNumber) {
115
- patch({ page: pageNumber });
156
+ select(pageNumber, event) {
157
+ handleNavigation(pageNumber, event);
116
158
  },
117
159
  /**
118
160
  * Select the first page
161
+ * @param event Event triggering the action
119
162
  */
120
- first() {
121
- patch({ page: 1 });
163
+ first(event) {
164
+ handleNavigation(1, event);
122
165
  },
123
166
  /**
124
167
  * Select the previous page
168
+ * @param event Event triggering the action
125
169
  */
126
- previous() {
127
- patch({ page: page$() - 1 });
170
+ previous(event) {
171
+ handleNavigation(page$() - 1, event, (page) => page - 1);
128
172
  },
129
173
  /**
130
174
  * Select the next page
175
+ * @param event Event triggering the action
131
176
  */
132
- next() {
133
- patch({ page: page$() + 1 });
177
+ next(event) {
178
+ handleNavigation(page$() + 1, event, (page) => page + 1);
134
179
  },
135
180
  /**
136
181
  * Select the last page
182
+ * @param event Event triggering the action
137
183
  */
138
- last() {
139
- patch({ page: pageCount$() });
184
+ last(event) {
185
+ handleNavigation(pageCount$(), event);
140
186
  },
141
187
  },
142
188
  api: {
@@ -22,9 +22,9 @@ export interface ProgressbarCommonPropsAndState extends WidgetsCommonPropsAndSta
22
22
  */
23
23
  ariaLabel: string;
24
24
  /**
25
- * Global template for the Progressbar content.
25
+ * Global template for the Progressbar.
26
26
  */
27
- slotContent: SlotContent<ProgressbarContext>;
27
+ slotStructure: SlotContent<ProgressbarContext>;
28
28
  /**
29
29
  * Label of the progress.
30
30
  */
@@ -8,7 +8,7 @@ const defaultConfig = {
8
8
  value: 0,
9
9
  ariaLabel: 'Progressbar',
10
10
  className: '',
11
- slotContent: undefined,
11
+ slotStructure: undefined,
12
12
  slotDefault: undefined,
13
13
  height: '',
14
14
  striped: false,
@@ -1,6 +1,6 @@
1
1
  import { computed, writable } from '@amadeus-it-group/tansu';
2
2
  import { INVALID_VALUE } from '../../types';
3
- import { bindableDerived, stateStores, writablesForProps } from '../../utils/stores';
3
+ import { bindableProp, stateStores, writablesForProps } from '../../utils/stores';
4
4
  import { clamp, isNumber } from '../../utils/internal/checks';
5
5
  import { typeBoolean, typeFunction, typeNumber, typeString } from '../../utils/writables';
6
6
  import { noop } from '../../utils/internal/func';
@@ -57,15 +57,14 @@ export function createRating(config) {
57
57
  const { maxRating$, disabled$, readonly$, resettable$ } = stateProps;
58
58
  // clean inputs adjustment to valid range
59
59
  const tabindex$ = computed(() => (disabled$() ? -1 : _dirtyTabindex$()));
60
- const rating$ = bindableDerived(onRatingChange$, [_dirtyRating$, maxRating$], ([dirtyRating, maxRating]) => clamp(dirtyRating, maxRating));
60
+ const rating$ = bindableProp(_dirtyRating$, onRatingChange$, (dirtyRating) => clamp(dirtyRating, maxRating$()));
61
61
  // internal inputs
62
62
  const _hoveredRating$ = writable(0);
63
63
  // computed
64
64
  const isInteractive$ = computed(() => !disabled$() && !readonly$());
65
65
  const visibleRating$ = computed(() => {
66
- const rating = rating$(); // call rating unconditionnally (for the bindableDerived to stay active)
67
66
  const hoveredRating = _hoveredRating$();
68
- return hoveredRating !== 0 ? hoveredRating : rating;
67
+ return hoveredRating !== 0 ? hoveredRating : rating$();
69
68
  });
70
69
  const ariaValueText$ = computed(() => ariaValueTextFn$()(visibleRating$(), maxRating$()));
71
70
  const stars$ = computed(() => {
@@ -89,7 +88,7 @@ export function createRating(config) {
89
88
  actions: {
90
89
  click: (index) => {
91
90
  if (isInteractive$() && index > 0 && index <= maxRating$()) {
92
- patch({ rating: rating$() === index && resettable$() ? 0 : index });
91
+ rating$.update((rating) => (rating === index && resettable$() ? 0 : index));
93
92
  }
94
93
  },
95
94
  hover: (index) => {
@@ -110,19 +109,19 @@ export function createRating(config) {
110
109
  switch (key) {
111
110
  case 'ArrowLeft':
112
111
  case 'ArrowDown':
113
- patch({ rating: rating$() - 1 });
112
+ rating$.update((rating) => rating - 1);
114
113
  break;
115
114
  case 'ArrowRight':
116
115
  case 'ArrowUp':
117
- patch({ rating: rating$() + 1 });
116
+ rating$.update((rating) => rating + 1);
118
117
  break;
119
118
  case 'Home':
120
119
  case 'PageDown':
121
- patch({ rating: 0 });
120
+ rating$.set(0);
122
121
  break;
123
122
  case 'End':
124
123
  case 'PageUp':
125
- patch({ rating: maxRating$() });
124
+ rating$.set(maxRating$());
126
125
  break;
127
126
  default:
128
127
  return;
@@ -1,7 +1,7 @@
1
1
  import type { Placement } from '@floating-ui/dom';
2
2
  import type { FloatingUI } from '../../services/floatingUI';
3
3
  import type { HasFocus } from '../../services/focustrack';
4
- import type { PropsConfig, SlotContent, Widget, WidgetSlotContext } from '../../types';
4
+ import type { Directive, PropsConfig, SlotContent, Widget, WidgetSlotContext } from '../../types';
5
5
  import type { WidgetsCommonPropsAndState } from '../commonProps';
6
6
  /**
7
7
  * A type for the slot context of the pagination widget
@@ -80,6 +80,12 @@ export interface SelectProps<T> extends SelectCommonPropsAndState<T> {
80
80
  * By default, the item is returned
81
81
  */
82
82
  itemIdFn(item: T): string;
83
+ /**
84
+ * Retrieves navigable elements within an HTML element containing badges and the input.
85
+ *
86
+ * @param node - HTMLElement that contains the badges and the input
87
+ */
88
+ navSelector(node: HTMLElement): NodeListOf<HTMLSpanElement | HTMLInputElement>;
83
89
  /**
84
90
  * Callback called dropdown open state change
85
91
  * @param isOpen - updated open state
@@ -163,27 +169,6 @@ export interface SelectApi<Item> {
163
169
  * Highlight the last item among the visible list
164
170
  */
165
171
  highlightLast(): void;
166
- /**
167
- * Focus the provided item among the selected list.
168
- * The focus feature is designed to know what item must be focused in the UI, i.e. among the badge elements.
169
- */
170
- focus(item: Item): void;
171
- /**
172
- * Focus the first element
173
- */
174
- focusFirst(): void;
175
- /**
176
- * Focus the previous element. If no element was focused before the call, nothing happens.
177
- */
178
- focusPrevious(): void;
179
- /**
180
- * Focus the next element. If no element was focused before the call, nothing happens.
181
- */
182
- focusNext(): void;
183
- /**
184
- * Focus the last element. If no element was focused before the call, nothing happens.
185
- */
186
- focusLast(): void;
187
172
  /**
188
173
  * Select the provided item.
189
174
  * The selected list is used to
@@ -228,8 +213,12 @@ export interface SelectDirectives {
228
213
  * A directive to be applied to the input group element serves as the base for menu positioning
229
214
  */
230
215
  referenceDirective: FloatingUI['directives']['referenceDirective'];
216
+ /**
217
+ * A directive to be applied to the element that contains the badges and the input
218
+ */
219
+ inputContainerDirective: Directive;
231
220
  }
232
- export interface SelectActions {
221
+ export interface SelectActions<Item> {
233
222
  /**
234
223
  * Method to be plugged to on the 'input' event. The input text will be used as the filter text.
235
224
  */
@@ -237,12 +226,23 @@ export interface SelectActions {
237
226
  target: any;
238
227
  }) => void;
239
228
  /**
240
- * Method to be plugged to on an keydown event, in order to control the keyboard interactions with the highlighted item.
229
+ * Method to be attached to the node element to close a badge on click.
230
+ */
231
+ onRemoveBadgeClick: (event: MouseEvent, item: Item) => void;
232
+ /**
233
+ * Method to be plugged to on an keydown event of the main input, in order to control the keyboard interactions with the highlighted item.
241
234
  * It manages arrow keys to move the highlighted item, or enter to toggle the item.
242
235
  */
243
- onInputKeydown: (e: any) => void;
236
+ onInputKeydown: (event: KeyboardEvent) => void;
237
+ /**
238
+ * Method to be plugged to on an keydown event of a badge container, in order to manage main actions on badges.
239
+ *
240
+ * @param event - keyboard event
241
+ * @param item - corresponding item
242
+ */
243
+ onBadgeKeydown: (event: KeyboardEvent, item: Item) => void;
244
244
  }
245
- export type SelectWidget<Item> = Widget<SelectProps<Item>, SelectState<Item>, SelectApi<Item>, SelectActions, SelectDirectives>;
245
+ export type SelectWidget<Item> = Widget<SelectProps<Item>, SelectState<Item>, SelectApi<Item>, SelectActions<Item>, SelectDirectives>;
246
246
  export declare const defaultConfig: SelectProps<any>;
247
247
  /**
248
248
  * Returns a shallow copy of the default select config.
@@ -263,6 +263,12 @@ export declare function getSelectDefaultConfig(): {
263
263
  * By default, the item is returned
264
264
  */
265
265
  itemIdFn(item: any): string;
266
+ /**
267
+ * Retrieves navigable elements within an HTML element containing badges and the input.
268
+ *
269
+ * @param node - HTMLElement that contains the badges and the input
270
+ */
271
+ navSelector(node: HTMLElement): NodeListOf<HTMLInputElement | HTMLSpanElement>;
266
272
  /**
267
273
  * Callback called dropdown open state change
268
274
  * @param isOpen - updated open state