@agnos-ui/core 0.0.1-alpha.0 → 0.0.1-alpha.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 (65) hide show
  1. package/README.md +4 -4
  2. package/{dist/lib/accordion.d.ts → accordion.d.ts} +3 -8
  3. package/{dist/lib/accordion.js → accordion.js} +1 -1
  4. package/{dist/lib/alert.d.ts → alert.d.ts} +2 -1
  5. package/{dist/lib/alert.js → alert.js} +1 -0
  6. package/commonProps.d.ts +6 -0
  7. package/commonProps.js +1 -0
  8. package/{dist/lib/index.d.ts → index.d.ts} +1 -0
  9. package/{dist/lib/index.js → index.js} +1 -0
  10. package/{dist/lib/modal → modal}/modal.d.ts +3 -9
  11. package/{dist/lib/modal → modal}/modal.js +1 -1
  12. package/package.json +13 -27
  13. package/{dist/lib/pagination.d.ts → pagination.d.ts} +4 -12
  14. package/{dist/lib/pagination.js → pagination.js} +1 -1
  15. package/{dist/lib/rating.d.ts → rating.d.ts} +3 -9
  16. package/{dist/lib/select.d.ts → select.d.ts} +2 -5
  17. package/{dist/lib/services → services}/index.d.ts +1 -0
  18. package/{dist/lib/services → services}/index.js +1 -0
  19. package/services/intersection.d.ts +26 -0
  20. package/services/intersection.js +47 -0
  21. package/dist/lib/tsdoc-metadata.json +0 -11
  22. /package/{dist/lib/config.d.ts → config.d.ts} +0 -0
  23. /package/{dist/lib/config.js → config.js} +0 -0
  24. /package/{dist/lib/modal → modal}/scrollbars.d.ts +0 -0
  25. /package/{dist/lib/modal → modal}/scrollbars.js +0 -0
  26. /package/{dist/lib/pagination.utils.d.ts → pagination.utils.d.ts} +0 -0
  27. /package/{dist/lib/pagination.utils.js → pagination.utils.js} +0 -0
  28. /package/{dist/lib/rating.js → rating.js} +0 -0
  29. /package/{dist/lib/select.js → select.js} +0 -0
  30. /package/{dist/lib/services → services}/checks.d.ts +0 -0
  31. /package/{dist/lib/services → services}/checks.js +0 -0
  32. /package/{dist/lib/services → services}/directiveUtils.d.ts +0 -0
  33. /package/{dist/lib/services → services}/directiveUtils.js +0 -0
  34. /package/{dist/lib/services → services}/focustrack.d.ts +0 -0
  35. /package/{dist/lib/services → services}/focustrack.js +0 -0
  36. /package/{dist/lib/services → services}/portal.d.ts +0 -0
  37. /package/{dist/lib/services → services}/portal.js +0 -0
  38. /package/{dist/lib/services → services}/siblingsInert.d.ts +0 -0
  39. /package/{dist/lib/services → services}/siblingsInert.js +0 -0
  40. /package/{dist/lib/services → services}/stores.d.ts +0 -0
  41. /package/{dist/lib/services → services}/stores.js +0 -0
  42. /package/{dist/lib/services → services}/writables.d.ts +0 -0
  43. /package/{dist/lib/services → services}/writables.js +0 -0
  44. /package/{dist/lib/transitions → transitions}/baseTransitions.d.ts +0 -0
  45. /package/{dist/lib/transitions → transitions}/baseTransitions.js +0 -0
  46. /package/{dist/lib/transitions → transitions}/bootstrap/collapse.d.ts +0 -0
  47. /package/{dist/lib/transitions → transitions}/bootstrap/collapse.js +0 -0
  48. /package/{dist/lib/transitions → transitions}/bootstrap/fade.d.ts +0 -0
  49. /package/{dist/lib/transitions → transitions}/bootstrap/fade.js +0 -0
  50. /package/{dist/lib/transitions → transitions}/bootstrap/index.d.ts +0 -0
  51. /package/{dist/lib/transitions → transitions}/bootstrap/index.js +0 -0
  52. /package/{dist/lib/transitions → transitions}/collapse.d.ts +0 -0
  53. /package/{dist/lib/transitions → transitions}/collapse.js +0 -0
  54. /package/{dist/lib/transitions → transitions}/cssTransitions.d.ts +0 -0
  55. /package/{dist/lib/transitions → transitions}/cssTransitions.js +0 -0
  56. /package/{dist/lib/transitions → transitions}/index.d.ts +0 -0
  57. /package/{dist/lib/transitions → transitions}/index.js +0 -0
  58. /package/{dist/lib/transitions → transitions}/simpleClassTransition.d.ts +0 -0
  59. /package/{dist/lib/transitions → transitions}/simpleClassTransition.js +0 -0
  60. /package/{dist/lib/transitions → transitions}/utils.d.ts +0 -0
  61. /package/{dist/lib/transitions → transitions}/utils.js +0 -0
  62. /package/{dist/lib/types.d.ts → types.d.ts} +0 -0
  63. /package/{dist/lib/types.js → types.js} +0 -0
  64. /package/{dist/lib/utils.d.ts → utils.d.ts} +0 -0
  65. /package/{dist/lib/utils.js → utils.js} +0 -0
package/README.md CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/@agnos-ui/core)](https://www.npmjs.com/package/@agnos-ui/core)
4
4
 
5
- [AgnosUI](https://amadeusitgroup.github.io/AgnosUI/latest/) is a framework-agnostic widget library with adapters for multiple frameworks:
5
+ [AgnosUI](https://amadeusitgroup.github.io/AgnosUI/latest/) is a framework-agnostic widget library with adapters for multiple frameworks, either [Bootstrap](https://getbootstrap.com/)-based or headless:
6
6
 
7
- - [Angular](https://www.npmjs.com/package/@agnos-ui/angular)
8
- - [React](https://www.npmjs.com/package/@agnos-ui/react)
9
- - [Svelte](https://www.npmjs.com/package/@agnos-ui/svelte)
7
+ - [Angular](https://www.npmjs.com/package/@agnos-ui/angular), [Angular headless](https://www.npmjs.com/package/@agnos-ui/angular-headless)
8
+ - [React](https://www.npmjs.com/package/@agnos-ui/react), [React headless](https://www.npmjs.com/package/@agnos-ui/react-headless)
9
+ - [Svelte](https://www.npmjs.com/package/@agnos-ui/svelte), [Svelte headless](https://www.npmjs.com/package/@agnos-ui/svelte-headless)
10
10
 
11
11
  This `@agnos-ui/core` package contains the framework-agnostic common code used by the above framework adapters.
12
12
 
@@ -1,13 +1,8 @@
1
1
  import type { PropsConfig } from './services';
2
2
  import type { TransitionFn } from './transitions';
3
3
  import type { Directive, SlotContent, Widget, WidgetSlotContext } from './types';
4
- export interface AccordionCommonPropsAndState {
5
- /**
6
- * Classes to add on the accordion DOM element.
7
- */
8
- accordionClass: string;
9
- }
10
- export interface AccordionProps extends AccordionCommonPropsAndState {
4
+ import type { WidgetsCommonPropsAndState } from './commonProps';
5
+ export interface AccordionProps extends WidgetsCommonPropsAndState {
11
6
  /**
12
7
  * If `true`, only one item at the time can stay open.
13
8
  */
@@ -132,7 +127,7 @@ export interface AccordionProps extends AccordionCommonPropsAndState {
132
127
  */
133
128
  itemBodyClass: string;
134
129
  }
135
- export interface AccordionState extends AccordionCommonPropsAndState {
130
+ export interface AccordionState extends WidgetsCommonPropsAndState {
136
131
  /**
137
132
  * Array containing all the accordion-items contained in the accordion.
138
133
  */
@@ -35,7 +35,7 @@ const defaultAccordionConfig = {
35
35
  closeOthers: false,
36
36
  onShown: noop,
37
37
  onHidden: noop,
38
- accordionClass: '',
38
+ className: '',
39
39
  itemId: '',
40
40
  itemDestroyOnHide: false,
41
41
  itemDisabled: false,
@@ -1,8 +1,9 @@
1
+ import type { WidgetsCommonPropsAndState } from './commonProps';
1
2
  import type { PropsConfig } from './services';
2
3
  import type { TransitionFn } from './transitions';
3
4
  import type { Directive, SlotContent, Widget, WidgetSlotContext } from './types';
4
5
  export type AlertContext = WidgetSlotContext<AlertWidget>;
5
- export interface AlertCommonPropsAndState {
6
+ export interface AlertCommonPropsAndState extends WidgetsCommonPropsAndState {
6
7
  /**
7
8
  * If `true`, alert can be dismissed by the user.
8
9
  * The close button (×) will be displayed and you can be notified of the event with the (close) output.
@@ -15,6 +15,7 @@ const defaultConfig = {
15
15
  animation: true,
16
16
  animationOnInit: false,
17
17
  transition: fadeTransition,
18
+ className: '',
18
19
  };
19
20
  /**
20
21
  * Retrieve a shallow copy of the default alert config
@@ -0,0 +1,6 @@
1
+ export interface WidgetsCommonPropsAndState {
2
+ /**
3
+ * CSS classes to be applied on the widget main container
4
+ */
5
+ className: string;
6
+ }
package/commonProps.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -9,3 +9,4 @@ export * from './config';
9
9
  export * from './modal/modal';
10
10
  export * from './alert';
11
11
  export * from './accordion';
12
+ export * from './commonProps';
@@ -9,3 +9,4 @@ export * from './config';
9
9
  export * from './modal/modal';
10
10
  export * from './alert';
11
11
  export * from './accordion';
12
+ export * from './commonProps';
@@ -1,6 +1,7 @@
1
1
  import type { PropsConfig } from '../services';
2
2
  import type { TransitionFn } from '../transitions';
3
3
  import type { Widget, Directive, SlotContent, WidgetSlotContext } from '../types';
4
+ import type { WidgetsCommonPropsAndState } from '../commonProps';
4
5
  /**
5
6
  * Value present in the {@link ModalBeforeCloseEvent.result|result} property of the {@link ModalProps.onBeforeClose|onBeforeClose} event
6
7
  * and returned by the {@link ModalApi.open|open} method, when the modal is closed by a click inside the viewport but outside the modal.
@@ -18,7 +19,7 @@ export type ModalContext = WidgetSlotContext<ModalWidget>;
18
19
  /**
19
20
  * Properties of the modal widget that are also in the state of the modal.
20
21
  */
21
- export interface ModalCommonPropsAndState {
22
+ export interface ModalCommonPropsAndState extends WidgetsCommonPropsAndState {
22
23
  /**
23
24
  * Value of the aria-label attribute to put on the close button.
24
25
  */
@@ -37,10 +38,6 @@ export interface ModalCommonPropsAndState {
37
38
  * Otherwise, they stay where the widget is located.
38
39
  */
39
40
  container: HTMLElement | null;
40
- /**
41
- * Classes to add on the modal DOM element.
42
- */
43
- modalClass: string;
44
41
  /**
45
42
  * Body of the modal.
46
43
  */
@@ -280,10 +277,6 @@ export declare function getModalDefaultConfig(): {
280
277
  * Otherwise, they stay where the widget is located.
281
278
  */
282
279
  container: HTMLElement | null;
283
- /**
284
- * Classes to add on the modal DOM element.
285
- */
286
- modalClass: string;
287
280
  /**
288
281
  * Body of the modal.
289
282
  */
@@ -309,6 +302,7 @@ export declare function getModalDefaultConfig(): {
309
302
  * Whether the modal should be visible when the transition is completed.
310
303
  */
311
304
  visible: boolean;
305
+ className: string;
312
306
  };
313
307
  /**
314
308
  * Creates a new modal widget instance.
@@ -24,7 +24,7 @@ const defaultConfig = {
24
24
  closeButton: true,
25
25
  closeOnOutsideClick: true,
26
26
  container: typeof window !== 'undefined' ? document.body : null,
27
- modalClass: '',
27
+ className: '',
28
28
  modalTransition: fadeTransition,
29
29
  onBeforeClose: noop,
30
30
  onVisibleChange: noop,
package/package.json CHANGED
@@ -1,52 +1,38 @@
1
1
  {
2
2
  "name": "@agnos-ui/core",
3
3
  "description": "Framework-agnostic headless widget library.",
4
- "homepage": "https://amadeusitgroup.github.io/AgnosUI/latest/",
5
4
  "keywords": [
6
5
  "headless",
7
6
  "agnostic",
8
7
  "components",
9
8
  "widgets",
9
+ "accordion",
10
10
  "alert",
11
11
  "modal",
12
12
  "pagination",
13
13
  "rating"
14
14
  ],
15
15
  "type": "module",
16
- "main": "./dist/lib/index.js",
17
- "module": "./dist/lib/index.js",
18
- "types": "./dist/lib/index.d.ts",
16
+ "main": "./index.js",
17
+ "module": "./index.js",
18
+ "types": "./index.d.ts",
19
19
  "exports": {
20
20
  ".": {
21
- "types": "./dist/lib/index.d.ts",
22
- "default": "./dist/lib/index.js"
21
+ "types": "./index.d.ts",
22
+ "default": "./index.js"
23
23
  }
24
24
  },
25
- "scripts": {
26
- "build": "npm run build:lib && npm run build:tsc && npm run build:api-extractor",
27
- "build:lib": "node ../scripts/rm.js dist/lib && tsc -p tsconfig.lib.json",
28
- "build:tsc": "tsc",
29
- "build:api-extractor": "api-extractor run",
30
- "test": "vitest run",
31
- "tdd": "vitest",
32
- "tdd:ui": "vitest --ui",
33
- "test:coverage": "vitest run --coverage"
34
- },
35
25
  "dependencies": {
36
26
  "@amadeus-it-group/tansu": "0.0.22"
37
27
  },
38
- "files": [
39
- "dist/lib"
40
- ],
41
- "license": "MIT",
28
+ "sideEffects": false,
29
+ "version": "0.0.1-alpha.1",
30
+ "homepage": "https://amadeusitgroup.github.io/AgnosUI/latest/",
42
31
  "bugs": "https://github.com/AmadeusITGroup/AgnosUI/issues",
32
+ "license": "MIT",
43
33
  "repository": {
44
34
  "type": "git",
45
35
  "url": "https://github.com/AmadeusITGroup/AgnosUI.git",
46
- "directory": "core"
47
- },
48
- "devDependencies": {
49
- "eslint-plugin-jsdoc": "^46.4.6"
50
- },
51
- "version": "0.0.1-alpha.0"
52
- }
36
+ "directory": "core/lib"
37
+ }
38
+ }
@@ -1,5 +1,6 @@
1
1
  import type { PropsConfig } from './services';
2
2
  import type { Widget, SlotContent, WidgetSlotContext } from './types';
3
+ import type { WidgetsCommonPropsAndState } from './commonProps';
3
4
  /**
4
5
  * A type for the slot context of the pagination widget
5
6
  */
@@ -13,7 +14,7 @@ export interface PaginationNumberContext extends PaginationContext {
13
14
  */
14
15
  displayedPage: number;
15
16
  }
16
- export interface PaginationCommonPropsAndState {
17
+ export interface PaginationCommonPropsAndState extends WidgetsCommonPropsAndState {
17
18
  /**
18
19
  * The current page.
19
20
  *
@@ -86,11 +87,6 @@ export interface PaginationCommonPropsAndState {
86
87
  * @defaultValue false
87
88
  */
88
89
  boundaryLinks: boolean;
89
- /**
90
- * An input to add a custom class to the UL
91
- * @defaultValue ''
92
- */
93
- className: string;
94
90
  /**
95
91
  * The template to use for the ellipsis slot
96
92
  * for I18n, we suggest to use the global configuration
@@ -398,11 +394,6 @@ export declare function getPaginationDefaultConfig(): {
398
394
  * @defaultValue false
399
395
  */
400
396
  boundaryLinks: boolean;
401
- /**
402
- * An input to add a custom class to the UL
403
- * @defaultValue ''
404
- */
405
- className: string;
406
397
  /**
407
398
  * The template to use for the ellipsis slot
408
399
  * for I18n, we suggest to use the global configuration
@@ -455,10 +446,11 @@ export declare function getPaginationDefaultConfig(): {
455
446
  * @param displayedPage - The current page number
456
447
  */
457
448
  slotNumberLabel: SlotContent<PaginationNumberContext>;
449
+ className: string;
458
450
  };
459
451
  /**
460
452
  * Create a PaginationWidget with given config props
461
- * @param config - an optional alert config
453
+ * @param config - an optional pagination config
462
454
  * @returns a PaginationWidget
463
455
  */
464
456
  export declare function createPagination(config?: PropsConfig<PaginationProps>): PaginationWidget;
@@ -64,7 +64,7 @@ const configValidator = {
64
64
  };
65
65
  /**
66
66
  * Create a PaginationWidget with given config props
67
- * @param config - an optional alert config
67
+ * @param config - an optional pagination config
68
68
  * @returns a PaginationWidget
69
69
  */
70
70
  export function createPagination(config) {
@@ -1,5 +1,6 @@
1
1
  import type { PropsConfig } from './services';
2
2
  import type { SlotContent, Widget } from './types';
3
+ import type { WidgetsCommonPropsAndState } from './commonProps';
3
4
  export interface StarContext {
4
5
  /**
5
6
  * indicates how much the current star is filled, from 0 to 100
@@ -10,7 +11,7 @@ export interface StarContext {
10
11
  */
11
12
  index: number;
12
13
  }
13
- export interface RatingCommonPropsAndState {
14
+ export interface RatingCommonPropsAndState extends WidgetsCommonPropsAndState {
14
15
  /**
15
16
  * The current rating. Could be a decimal value like `3.75`.
16
17
  */
@@ -38,10 +39,6 @@ export interface RatingCommonPropsAndState {
38
39
  * If the component is disabled, `tabindex` will still be set to `-1`.
39
40
  */
40
41
  tabindex: number;
41
- /**
42
- * Classname to be applied on the rating container
43
- */
44
- className: string;
45
42
  /**
46
43
  * The template to override the way each star is displayed.
47
44
  */
@@ -184,10 +181,6 @@ export declare function getRatingDefaultConfig(): {
184
181
  * If the component is disabled, `tabindex` will still be set to `-1`.
185
182
  */
186
183
  tabindex: number;
187
- /**
188
- * Classname to be applied on the rating container
189
- */
190
- className: string;
191
184
  /**
192
185
  * The template to override the way each star is displayed.
193
186
  */
@@ -200,6 +193,7 @@ export declare function getRatingDefaultConfig(): {
200
193
  * The aria labelled by
201
194
  */
202
195
  ariaLabelledBy: string;
196
+ className: string;
203
197
  };
204
198
  /**
205
199
  * Create a RatingWidget with given config props
@@ -1,11 +1,8 @@
1
1
  import type { HasFocus } from './services/focustrack';
2
2
  import type { PropsConfig } from './services/stores';
3
3
  import type { Widget } from './types';
4
- export interface SelectCommonPropsAndState<Item> {
5
- /**
6
- * the class to attach to the select DOM element
7
- */
8
- className: string;
4
+ import type { WidgetsCommonPropsAndState } from './commonProps';
5
+ export interface SelectCommonPropsAndState<Item> extends WidgetsCommonPropsAndState {
9
6
  /**
10
7
  * List of selected items
11
8
  */
@@ -1,6 +1,7 @@
1
1
  export * from './siblingsInert';
2
2
  export * from './directiveUtils';
3
3
  export * from './focustrack';
4
+ export * from './intersection';
4
5
  export * from './portal';
5
6
  export * from './stores';
6
7
  export * from './writables';
@@ -1,6 +1,7 @@
1
1
  export * from './siblingsInert';
2
2
  export * from './directiveUtils';
3
3
  export * from './focustrack';
4
+ export * from './intersection';
4
5
  export * from './portal';
5
6
  export * from './stores';
6
7
  export * from './writables';
@@ -0,0 +1,26 @@
1
+ import type { PropsConfig } from './stores';
2
+ export interface IntersectionProps {
3
+ /**
4
+ * elements to observe
5
+ */
6
+ elements: HTMLElement[];
7
+ /**
8
+ * IntersectionObserverInit used in the IntersectionObserver
9
+ *
10
+ * See the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/IntersectionObserver#options)
11
+ */
12
+ options: Partial<IntersectionObserverInit> | undefined;
13
+ }
14
+ export declare const createIntersection: (config?: PropsConfig<IntersectionProps>) => {
15
+ /**
16
+ * Readable of observed elements
17
+ */
18
+ elements$: import("@amadeus-it-group/tansu").ReadableSignal<HTMLElement[]>;
19
+ /**
20
+ * Store of map that contains the visible elements (for the key) and the corresponding entries
21
+ *
22
+ * See the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry)
23
+ */
24
+ visibleElements$: import("@amadeus-it-group/tansu").ReadableSignal<Map<Element, IntersectionObserverEntry>>;
25
+ patch: <U extends Partial<IntersectionProps>>(storesValues?: void | U | undefined) => void;
26
+ };
@@ -0,0 +1,47 @@
1
+ import { asReadable, derived } from '@amadeus-it-group/tansu';
2
+ import { noop } from '../utils';
3
+ import { writablesForProps } from './stores';
4
+ const defaultValues = {
5
+ elements: [],
6
+ options: undefined,
7
+ };
8
+ export const createIntersection = (config) => {
9
+ const [{ elements$, options$ }, patch] = writablesForProps(defaultValues, config);
10
+ const visibleElements$ = derived([elements$, options$], ([elements, options], set) => {
11
+ if (elements.length) {
12
+ const visibleElements = new Map();
13
+ const observer = new IntersectionObserver((entries) => {
14
+ for (const entry of entries) {
15
+ const { target, isIntersecting } = entry;
16
+ if (isIntersecting) {
17
+ visibleElements.set(target, entry);
18
+ }
19
+ else {
20
+ visibleElements.delete(target);
21
+ }
22
+ }
23
+ set(visibleElements);
24
+ }, options);
25
+ for (const element of elements) {
26
+ observer.observe(element);
27
+ }
28
+ return () => {
29
+ observer.disconnect();
30
+ };
31
+ }
32
+ return noop;
33
+ }, new Map());
34
+ return {
35
+ /**
36
+ * Readable of observed elements
37
+ */
38
+ elements$: asReadable(elements$),
39
+ /**
40
+ * Store of map that contains the visible elements (for the key) and the corresponding entries
41
+ *
42
+ * See the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry)
43
+ */
44
+ visibleElements$: asReadable(visibleElements$),
45
+ patch,
46
+ };
47
+ };
@@ -1,11 +0,0 @@
1
- // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
- // It should be published with your NPM package. It should not be tracked by Git.
3
- {
4
- "tsdocVersion": "0.12",
5
- "toolPackages": [
6
- {
7
- "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.36.4"
9
- }
10
- ]
11
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes