@agnos-ui/core 0.0.1-alpha.3 → 0.0.1-alpha.5

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 (96) hide show
  1. package/{accordion.d.ts → components/accordion/accordion.d.ts} +13 -4
  2. package/{accordion.js → components/accordion/accordion.js} +17 -11
  3. package/components/alert/alert.d.ts +32 -0
  4. package/components/alert/alert.js +23 -0
  5. package/{alert.d.ts → components/alert/common.d.ts} +17 -21
  6. package/{alert.js → components/alert/common.js} +12 -12
  7. package/{modal → components/modal}/modal.d.ts +28 -21
  8. package/{modal → components/modal}/modal.js +39 -13
  9. package/{pagination.d.ts → components/pagination/pagination.d.ts} +3 -3
  10. package/{pagination.js → components/pagination/pagination.js} +6 -4
  11. package/{progressbar.d.ts → components/progressbar/progressbar.d.ts} +2 -3
  12. package/{progressbar.js → components/progressbar/progressbar.js} +6 -6
  13. package/{rating.d.ts → components/rating/rating.d.ts} +2 -3
  14. package/{rating.js → components/rating/rating.js} +6 -9
  15. package/components/select/select.d.ts +337 -0
  16. package/components/select/select.js +266 -0
  17. package/components/slider/slider.d.ts +239 -0
  18. package/components/slider/slider.js +389 -0
  19. package/config.d.ts +13 -8
  20. package/config.js +3 -3
  21. package/index.d.ts +23 -12
  22. package/index.js +29 -12
  23. package/package.json +32 -4
  24. package/services/extendWidget.d.ts +23 -0
  25. package/{extendWidget.js → services/extendWidget.js} +8 -1
  26. package/services/floatingUI.d.ts +48 -0
  27. package/services/floatingUI.js +97 -0
  28. package/services/focustrack.js +1 -1
  29. package/services/intersection.d.ts +1 -1
  30. package/services/intersection.js +2 -2
  31. package/services/navManager.d.ts +83 -1
  32. package/services/navManager.js +153 -37
  33. package/services/portal.js +8 -4
  34. package/services/siblingsInert.d.ts +2 -1
  35. package/services/siblingsInert.js +2 -2
  36. package/{transitions → services/transitions}/baseTransitions.d.ts +1 -2
  37. package/{transitions → services/transitions}/baseTransitions.js +7 -10
  38. package/services/transitions/bootstrap/collapse.d.ts +2 -0
  39. package/services/transitions/bootstrap/fade.d.ts +1 -0
  40. package/services/transitions/bootstrap.d.ts +2 -0
  41. package/services/transitions/bootstrap.js +2 -0
  42. package/{transitions → services/transitions}/collapse.js +1 -1
  43. package/{transitions → services/transitions}/cssTransitions.js +2 -4
  44. package/{transitions → services/transitions}/simpleClassTransition.js +1 -1
  45. package/types.d.ts +37 -4
  46. package/types.js +1 -0
  47. package/{services/directiveUtils.js → utils/directive.js} +1 -1
  48. package/{services → utils/internal}/checks.d.ts +12 -0
  49. package/{services → utils/internal}/checks.js +12 -0
  50. package/utils/internal/dom.d.ts +13 -0
  51. package/utils/internal/dom.js +49 -0
  52. package/utils/internal/isFocusable.d.ts +9 -0
  53. package/utils/internal/isFocusable.js +35 -0
  54. package/utils/internal/math.d.ts +5 -0
  55. package/utils/internal/math.js +13 -0
  56. package/utils/internal/promise.d.ts +31 -0
  57. package/utils/internal/promise.js +113 -0
  58. package/{modal → utils/internal}/scrollbars.js +1 -1
  59. package/utils/internal/textDirection.d.ts +1 -0
  60. package/utils/internal/textDirection.js +1 -0
  61. package/utils/internal/traversal.d.ts +54 -0
  62. package/utils/internal/traversal.js +105 -0
  63. package/{services → utils}/stores.d.ts +11 -35
  64. package/{services → utils}/stores.js +21 -19
  65. package/utils/writables.d.ts +26 -0
  66. package/utils/writables.js +66 -0
  67. package/extendWidget.d.ts +0 -3
  68. package/select.d.ts +0 -196
  69. package/select.js +0 -240
  70. package/services/index.d.ts +0 -8
  71. package/services/index.js +0 -8
  72. package/services/writables.d.ts +0 -8
  73. package/services/writables.js +0 -30
  74. package/transitions/bootstrap/collapse.d.ts +0 -2
  75. package/transitions/bootstrap/fade.d.ts +0 -1
  76. package/transitions/bootstrap/index.d.ts +0 -2
  77. package/transitions/bootstrap/index.js +0 -2
  78. package/transitions/index.d.ts +0 -5
  79. package/transitions/index.js +0 -5
  80. package/transitions/utils.d.ts +0 -20
  81. package/transitions/utils.js +0 -83
  82. /package/{commonProps.d.ts → components/commonProps.d.ts} +0 -0
  83. /package/{commonProps.js → components/commonProps.js} +0 -0
  84. /package/{pagination.utils.d.ts → components/pagination/bootstrap.d.ts} +0 -0
  85. /package/{pagination.utils.js → components/pagination/bootstrap.js} +0 -0
  86. /package/{transitions → services/transitions}/bootstrap/collapse.js +0 -0
  87. /package/{transitions → services/transitions}/bootstrap/fade.js +0 -0
  88. /package/{transitions → services/transitions}/collapse.d.ts +0 -0
  89. /package/{transitions → services/transitions}/cssTransitions.d.ts +0 -0
  90. /package/{transitions → services/transitions}/simpleClassTransition.d.ts +0 -0
  91. /package/{services/directiveUtils.d.ts → utils/directive.d.ts} +0 -0
  92. /package/{utils.d.ts → utils/internal/func.d.ts} +0 -0
  93. /package/{utils.js → utils/internal/func.js} +0 -0
  94. /package/{modal → utils/internal}/scrollbars.d.ts +0 -0
  95. /package/{services/sortUtils.d.ts → utils/internal/sort.d.ts} +0 -0
  96. /package/{services/sortUtils.js → utils/internal/sort.js} +0 -0
package/select.js DELETED
@@ -1,240 +0,0 @@
1
- import { asReadable, batch, computed, writable } from '@amadeus-it-group/tansu';
2
- import { createHasFocus } from './services/focustrack';
3
- import { stateStores, writablesForProps } from './services/stores';
4
- function defaultMatchFn(item, text) {
5
- return JSON.stringify(item).toLowerCase().includes(text.toLowerCase());
6
- }
7
- function defaultItemId(item) {
8
- return '' + item;
9
- }
10
- const defaultConfig = {
11
- opened: false,
12
- disabled: false,
13
- items: [],
14
- filterText: '',
15
- loading: false,
16
- selected: [],
17
- itemId: defaultItemId,
18
- matchFn: defaultMatchFn,
19
- onFilterTextChange: undefined,
20
- className: '',
21
- };
22
- /**
23
- * Create a SelectWidget with given config props
24
- * @param config - an optional alert config
25
- * @returns a SelectWidget
26
- */
27
- export function createSelect(config) {
28
- // Props
29
- const [{ opened$: _dirtyOpened$, items$, itemId$, matchFn$, onFilterTextChange$, ...otherProps }, patch] = writablesForProps(defaultConfig, config);
30
- const { selected$, filterText$ } = otherProps;
31
- const { hasFocus$, directive: hasFocusDirective } = createHasFocus();
32
- const opened$ = computed(() => {
33
- const _dirtyOpened = _dirtyOpened$();
34
- const hasFocus = hasFocus$();
35
- if (!hasFocus && _dirtyOpened) {
36
- _dirtyOpened$.set(false);
37
- }
38
- return _dirtyOpened && hasFocus;
39
- });
40
- const highlightedIndex$ = (function () {
41
- const store = writable(0);
42
- const newStore = asReadable(store, {
43
- set(index) {
44
- const { length } = visible$();
45
- if (index != undefined) {
46
- if (!length) {
47
- index = undefined;
48
- }
49
- else if (index < 0) {
50
- index = length - 1;
51
- }
52
- else if (index >= length) {
53
- index = 0;
54
- }
55
- }
56
- store.set(index);
57
- },
58
- update(fn) {
59
- newStore.set(fn(store()));
60
- },
61
- });
62
- return newStore;
63
- })();
64
- const visible$ = computed(() => {
65
- const list = [];
66
- if (opened$()) {
67
- const selected = selected$();
68
- const filterText = filterText$();
69
- const matchFn = !filterText ? () => true : matchFn$();
70
- const itemId = itemId$();
71
- for (const item of items$()) {
72
- if (matchFn(item, filterText)) {
73
- list.push({
74
- item,
75
- id: itemId(item),
76
- selected: selected.includes(item),
77
- select: function () {
78
- widget.api.select(this);
79
- }.bind(item),
80
- unselect: function () {
81
- widget.api.unselect(this);
82
- }.bind(item),
83
- toggle: function () {
84
- widget.api.toggleItem(this);
85
- }.bind(item),
86
- });
87
- }
88
- }
89
- }
90
- return list;
91
- });
92
- const highlighted$ = computed(() => {
93
- const visible = visible$();
94
- const highlightedIndex = highlightedIndex$();
95
- return visible.length && highlightedIndex != undefined ? visible[highlightedIndex] : undefined;
96
- });
97
- const widget = {
98
- ...stateStores({
99
- visible$,
100
- highlighted$,
101
- opened$,
102
- ...otherProps,
103
- }),
104
- patch,
105
- api: {
106
- clear() {
107
- selected$.set([]);
108
- },
109
- select(item) {
110
- widget.api.toggleItem(item, true);
111
- },
112
- unselect(item) {
113
- widget.api.toggleItem(item, false);
114
- },
115
- toggleItem(item, selected) {
116
- if (!items$().includes(item)) {
117
- return;
118
- }
119
- selected$.update((selectedItems) => {
120
- selectedItems = [...selectedItems];
121
- const index = selectedItems.indexOf(item);
122
- if (selected == null) {
123
- selected = index === -1;
124
- }
125
- if (selected && index === -1) {
126
- selectedItems.push(item);
127
- }
128
- else if (!selected && index !== -1) {
129
- selectedItems.splice(index, 1);
130
- }
131
- return selectedItems;
132
- });
133
- },
134
- clearText() {
135
- // FIXME: not implemented yet!
136
- },
137
- highlight(item) {
138
- const index = visible$().findIndex((itemCtx) => itemCtx.item === item);
139
- highlightedIndex$.set(index === -1 ? undefined : index);
140
- },
141
- highlightFirst() {
142
- highlightedIndex$.set(0);
143
- },
144
- highlightPrevious() {
145
- highlightedIndex$.update((highlightedIndex) => {
146
- return highlightedIndex != null ? highlightedIndex - 1 : -1;
147
- });
148
- },
149
- highlightNext() {
150
- highlightedIndex$.update((highlightedIndex) => {
151
- return highlightedIndex != null ? highlightedIndex + 1 : Infinity;
152
- });
153
- },
154
- highlightLast() {
155
- highlightedIndex$.set(-1);
156
- },
157
- focus(item) {
158
- // FIXME: not implemented yet!
159
- },
160
- focusFirst() {
161
- // FIXME: not implemented yet!
162
- },
163
- focusPrevious() {
164
- // FIXME: not implemented yet!
165
- },
166
- focusNext() {
167
- // FIXME: not implemented yet!
168
- },
169
- focusLast() {
170
- // FIXME: not implemented yet!
171
- },
172
- open: () => widget.api.toggle(true),
173
- close: () => widget.api.toggle(false),
174
- toggle(isOpen) {
175
- _dirtyOpened$.update((value) => (isOpen != null ? isOpen : !value));
176
- },
177
- },
178
- directives: {
179
- hasFocusDirective,
180
- },
181
- actions: {
182
- onInput({ target }) {
183
- const value = target.value;
184
- batch(() => {
185
- patch({
186
- opened: value != null && value !== '',
187
- filterText: value,
188
- });
189
- onFilterTextChange$()?.(value);
190
- });
191
- },
192
- onInputKeydown(e) {
193
- const { ctrlKey, key } = e;
194
- let keyManaged = true;
195
- switch (key) {
196
- case 'ArrowDown': {
197
- const isOpen = opened$();
198
- if (isOpen) {
199
- if (ctrlKey) {
200
- widget.api.highlightLast();
201
- }
202
- else {
203
- widget.api.highlightNext();
204
- }
205
- }
206
- else {
207
- widget.api.open();
208
- widget.api.highlightFirst();
209
- }
210
- break;
211
- }
212
- case 'ArrowUp':
213
- if (ctrlKey) {
214
- widget.api.highlightFirst();
215
- }
216
- else {
217
- widget.api.highlightPrevious();
218
- }
219
- break;
220
- case 'Enter': {
221
- const itemCtx = highlighted$();
222
- if (itemCtx) {
223
- widget.api.toggleItem(itemCtx.item);
224
- }
225
- break;
226
- }
227
- case 'Escape':
228
- _dirtyOpened$.set(false);
229
- break;
230
- default:
231
- keyManaged = false;
232
- }
233
- if (keyManaged) {
234
- e.preventDefault();
235
- }
236
- },
237
- },
238
- };
239
- return widget;
240
- }
@@ -1,8 +0,0 @@
1
- export * from './siblingsInert';
2
- export * from './directiveUtils';
3
- export * from './focustrack';
4
- export * from './intersection';
5
- export * from './portal';
6
- export * from './stores';
7
- export * from './writables';
8
- export * from './navManager';
package/services/index.js DELETED
@@ -1,8 +0,0 @@
1
- export * from './siblingsInert';
2
- export * from './directiveUtils';
3
- export * from './focustrack';
4
- export * from './intersection';
5
- export * from './portal';
6
- export * from './stores';
7
- export * from './writables';
8
- export * from './navManager';
@@ -1,8 +0,0 @@
1
- import type { WritableWithDefaultOptions } from './stores';
2
- import { INVALID_VALUE } from './stores';
3
- export declare const testToNormalizeValue: <T>(filter: (value: T) => boolean) => (value: T) => typeof INVALID_VALUE | T;
4
- export declare const typeNumber: WritableWithDefaultOptions<number>;
5
- export declare const typeBoolean: WritableWithDefaultOptions<boolean>;
6
- export declare const typeString: WritableWithDefaultOptions<string>;
7
- export declare const typeFunction: WritableWithDefaultOptions<(...args: any[]) => any>;
8
- export declare const typeArray: WritableWithDefaultOptions<any[]>;
@@ -1,30 +0,0 @@
1
- import { isArray, isBoolean, isFunction, isNumber, isString } from './checks';
2
- import { INVALID_VALUE } from './stores';
3
- export const testToNormalizeValue = (filter) => (value) => filter(value) ? value : INVALID_VALUE;
4
- export const typeNumber = {
5
- normalizeValue: testToNormalizeValue(isNumber),
6
- };
7
- export const typeBoolean = {
8
- normalizeValue: testToNormalizeValue(isBoolean),
9
- };
10
- export const typeString = {
11
- normalizeValue: testToNormalizeValue(isString),
12
- };
13
- export const typeFunction = {
14
- normalizeValue: testToNormalizeValue(isFunction),
15
- equal: Object.is,
16
- };
17
- export const typeArray = {
18
- normalizeValue: testToNormalizeValue(isArray),
19
- equal: (a, b) => {
20
- if (a === b) {
21
- return true;
22
- }
23
- else {
24
- if (a?.length !== b?.length) {
25
- return false;
26
- }
27
- return a.every((val, index) => val === b[index]);
28
- }
29
- },
30
- };
@@ -1,2 +0,0 @@
1
- export declare const collapseVerticalTransition: import("..").TransitionFn;
2
- export declare const collapseHorizontalTransition: import("..").TransitionFn;
@@ -1 +0,0 @@
1
- export declare const fadeTransition: import("..").TransitionFn;
@@ -1,2 +0,0 @@
1
- export * from './collapse';
2
- export * from './fade';
@@ -1,2 +0,0 @@
1
- export * from './collapse';
2
- export * from './fade';
@@ -1,5 +0,0 @@
1
- export * from './baseTransitions';
2
- export * from './cssTransitions';
3
- export * from './simpleClassTransition';
4
- import * as bootstrap from './bootstrap';
5
- export { bootstrap };
@@ -1,5 +0,0 @@
1
- export * from './baseTransitions';
2
- export * from './cssTransitions';
3
- export * from './simpleClassTransition';
4
- import * as bootstrap from './bootstrap';
5
- export { bootstrap };
@@ -1,20 +0,0 @@
1
- import type { ReadableSignal } from '@amadeus-it-group/tansu';
2
- export declare const promiseFromStore: <T>(store: ReadableSignal<T>, condition?: (value: T) => boolean) => {
3
- promise: Promise<T>;
4
- unsubscribe(): void;
5
- };
6
- export declare const promiseFromEvent: (element: EventTarget, event: string) => {
7
- promise: Promise<Event>;
8
- unsubscribe(): void;
9
- };
10
- export declare const promiseFromTimeout: (delay: number) => {
11
- promise: Promise<void>;
12
- unsubscribe(): void;
13
- };
14
- /**
15
- * Launch a reflow using a call to the provided html element getBoudingClientRect
16
- * @param element the html element
17
- */
18
- export declare function reflow(element?: HTMLElement): void;
19
- export declare const addClasses: (element: HTMLElement, classes?: string[]) => void;
20
- export declare const removeClasses: (element: HTMLElement, classes?: string[]) => void;
@@ -1,83 +0,0 @@
1
- const noop = () => {
2
- /* nothing to do*/
3
- };
4
- const truthyValue = (value) => !!value;
5
- export const promiseFromStore = (store, condition = truthyValue) => {
6
- let resolve;
7
- const promise = new Promise((r) => (resolve = r));
8
- let unsubscribe = () => {
9
- storeUnsubscribe();
10
- unsubscribe = noop;
11
- };
12
- let storeUnsubscribe = noop;
13
- storeUnsubscribe = store.subscribe((value) => {
14
- if (condition(value)) {
15
- resolve(value);
16
- unsubscribe();
17
- }
18
- });
19
- if (unsubscribe === noop) {
20
- storeUnsubscribe();
21
- }
22
- return {
23
- promise,
24
- unsubscribe() {
25
- unsubscribe();
26
- },
27
- };
28
- };
29
- export const promiseFromEvent = (element, event) => {
30
- let resolve;
31
- const promise = new Promise((r) => (resolve = r));
32
- let unsubscribe = () => {
33
- element.removeEventListener(event, eventListener);
34
- unsubscribe = noop;
35
- };
36
- const eventListener = (event) => {
37
- if (event.target === element) {
38
- resolve(event);
39
- unsubscribe();
40
- }
41
- };
42
- element.addEventListener(event, eventListener);
43
- return {
44
- promise,
45
- unsubscribe() {
46
- unsubscribe();
47
- },
48
- };
49
- };
50
- export const promiseFromTimeout = (delay) => {
51
- let timeout;
52
- return {
53
- promise: new Promise((r) => {
54
- timeout = setTimeout(() => {
55
- timeout = undefined;
56
- r();
57
- }, delay);
58
- }),
59
- unsubscribe() {
60
- if (timeout) {
61
- clearTimeout(timeout);
62
- timeout = undefined;
63
- }
64
- },
65
- };
66
- };
67
- /**
68
- * Launch a reflow using a call to the provided html element getBoudingClientRect
69
- * @param element the html element
70
- */
71
- export function reflow(element = document.body) {
72
- element.getBoundingClientRect();
73
- }
74
- export const addClasses = (element, classes) => {
75
- if (classes && classes.length > 0) {
76
- element.classList.add(...classes);
77
- }
78
- };
79
- export const removeClasses = (element, classes) => {
80
- if (classes && classes.length > 0) {
81
- element.classList.remove(...classes);
82
- }
83
- };
File without changes
File without changes
File without changes
File without changes