@agnos-ui/core 0.9.1 → 0.9.3

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.
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ const services_transitions_baseTransitions = require("./services/transitions/baseTransitions.cjs");
3
+ const utils_stores = require("./utils/stores.cjs");
4
+ const utils_directive = require("./dom-CuBx1JPZ.cjs");
5
+ const utils_writables = require("./writables-Bn3uhKEG.cjs");
6
+ const tansu = require("@amadeus-it-group/tansu");
7
+ const utils_func = require("./utils/func.cjs");
8
+ const utils_widget = require("./utils/widget.cjs");
9
+ const defaultCollapseConfig = {
10
+ visible: false,
11
+ onVisibleChange: utils_func.noop,
12
+ onShown: utils_func.noop,
13
+ onHidden: utils_func.noop,
14
+ animated: true,
15
+ animatedOnInit: false,
16
+ id: "",
17
+ transition: utils_func.noop
18
+ };
19
+ function getCollapseDefaultConfig() {
20
+ return { ...defaultCollapseConfig };
21
+ }
22
+ const commonCollapseConfigValidator = {
23
+ onVisibleChange: utils_writables.typeFunction,
24
+ onHidden: utils_writables.typeFunction,
25
+ onShown: utils_writables.typeFunction,
26
+ animatedOnInit: utils_writables.typeBoolean,
27
+ animated: utils_writables.typeBoolean,
28
+ visible: utils_writables.typeBoolean,
29
+ id: utils_writables.typeString,
30
+ transition: utils_writables.typeFunction
31
+ };
32
+ const createCollapse = utils_widget.createWidgetFactory("collapse", (config) => {
33
+ const [
34
+ { transition$, animatedOnInit$, animated$, visible$: requestedVisible$, onVisibleChange$, onHidden$, onShown$, id$: _dirtyId$, ...stateProps },
35
+ patch
36
+ ] = utils_stores.writablesForProps(defaultCollapseConfig, config, commonCollapseConfigValidator);
37
+ const id$ = utils_stores.idWithDefault(_dirtyId$);
38
+ const transition = services_transitions_baseTransitions.createTransition({
39
+ props: {
40
+ transition: transition$,
41
+ visible: requestedVisible$,
42
+ animated: animated$,
43
+ animatedOnInit: animatedOnInit$,
44
+ onVisibleChange: onVisibleChange$,
45
+ onHidden: onHidden$,
46
+ onShown: onShown$
47
+ }
48
+ });
49
+ const visible$ = transition.stores.visible$;
50
+ const hidden$ = transition.stores.hidden$;
51
+ return {
52
+ ...utils_stores.stateStores({ ...stateProps, visible$, hidden$ }),
53
+ patch,
54
+ api: {
55
+ open: transition.api.show,
56
+ close: transition.api.hide,
57
+ toggle: transition.api.toggle
58
+ },
59
+ directives: {
60
+ collapseDirective: utils_directive.mergeDirectives(
61
+ transition.directives.directive,
62
+ utils_directive.createAttributesDirective(() => ({
63
+ attributes: {
64
+ id: id$
65
+ }
66
+ }))
67
+ ),
68
+ triggerDirective: utils_directive.createAttributesDirective(() => ({
69
+ attributes: {
70
+ "aria-expanded": tansu.computed(() => `${visible$()}`),
71
+ "aria-controls": id$
72
+ },
73
+ events: {
74
+ click: () => transition.api.toggle()
75
+ }
76
+ }))
77
+ }
78
+ };
79
+ });
80
+ exports.createCollapse = createCollapse;
81
+ exports.getCollapseDefaultConfig = getCollapseDefaultConfig;
@@ -0,0 +1,82 @@
1
+ import { createTransition } from "./services/transitions/baseTransitions.js";
2
+ import { writablesForProps, idWithDefault, stateStores } from "./utils/stores.js";
3
+ import { n as createAttributesDirective, k as mergeDirectives } from "./dom-gfxqXJpK.js";
4
+ import { g as typeFunction, e as typeString, c as typeBoolean } from "./writables-CgpOQ4hA.js";
5
+ import { computed } from "@amadeus-it-group/tansu";
6
+ import { noop } from "./utils/func.js";
7
+ import { createWidgetFactory } from "./utils/widget.js";
8
+ const defaultCollapseConfig = {
9
+ visible: false,
10
+ onVisibleChange: noop,
11
+ onShown: noop,
12
+ onHidden: noop,
13
+ animated: true,
14
+ animatedOnInit: false,
15
+ id: "",
16
+ transition: noop
17
+ };
18
+ function getCollapseDefaultConfig() {
19
+ return { ...defaultCollapseConfig };
20
+ }
21
+ const commonCollapseConfigValidator = {
22
+ onVisibleChange: typeFunction,
23
+ onHidden: typeFunction,
24
+ onShown: typeFunction,
25
+ animatedOnInit: typeBoolean,
26
+ animated: typeBoolean,
27
+ visible: typeBoolean,
28
+ id: typeString,
29
+ transition: typeFunction
30
+ };
31
+ const createCollapse = createWidgetFactory("collapse", (config) => {
32
+ const [
33
+ { transition$, animatedOnInit$, animated$, visible$: requestedVisible$, onVisibleChange$, onHidden$, onShown$, id$: _dirtyId$, ...stateProps },
34
+ patch
35
+ ] = writablesForProps(defaultCollapseConfig, config, commonCollapseConfigValidator);
36
+ const id$ = idWithDefault(_dirtyId$);
37
+ const transition = createTransition({
38
+ props: {
39
+ transition: transition$,
40
+ visible: requestedVisible$,
41
+ animated: animated$,
42
+ animatedOnInit: animatedOnInit$,
43
+ onVisibleChange: onVisibleChange$,
44
+ onHidden: onHidden$,
45
+ onShown: onShown$
46
+ }
47
+ });
48
+ const visible$ = transition.stores.visible$;
49
+ const hidden$ = transition.stores.hidden$;
50
+ return {
51
+ ...stateStores({ ...stateProps, visible$, hidden$ }),
52
+ patch,
53
+ api: {
54
+ open: transition.api.show,
55
+ close: transition.api.hide,
56
+ toggle: transition.api.toggle
57
+ },
58
+ directives: {
59
+ collapseDirective: mergeDirectives(
60
+ transition.directives.directive,
61
+ createAttributesDirective(() => ({
62
+ attributes: {
63
+ id: id$
64
+ }
65
+ }))
66
+ ),
67
+ triggerDirective: createAttributesDirective(() => ({
68
+ attributes: {
69
+ "aria-expanded": computed(() => `${visible$()}`),
70
+ "aria-controls": id$
71
+ },
72
+ events: {
73
+ click: () => transition.api.toggle()
74
+ }
75
+ }))
76
+ }
77
+ };
78
+ });
79
+ export {
80
+ createCollapse as c,
81
+ getCollapseDefaultConfig as g
82
+ };
@@ -0,0 +1,132 @@
1
+ import { type TransitionFn } from '../../services/transitions/baseTransitions';
2
+ import type { Directive, Widget, WidgetFactory } from '../../types';
3
+ /**
4
+ * Interface representing the common properties and state for a collapse component.
5
+ */
6
+ interface CollapseCommonPropsAndState {
7
+ /**
8
+ * If `true` the collapse is visible to the user
9
+ *
10
+ * @defaultValue `true`
11
+ */
12
+ visible: boolean;
13
+ }
14
+ /**
15
+ * Represents the state of a Collapse component.
16
+ */
17
+ export interface CollapseState extends CollapseCommonPropsAndState {
18
+ /**
19
+ * Is `true` when the collapse is hidden. Compared to `visible`, this is updated after the transition is executed.
20
+ */
21
+ hidden: boolean;
22
+ }
23
+ /**
24
+ * Properties for the Collapse component.
25
+ */
26
+ export interface CollapseProps extends CollapseCommonPropsAndState {
27
+ /**
28
+ * Callback called when the collapse visibility changed.
29
+ *
30
+ * @defaultValue
31
+ * ```ts
32
+ * () => {}
33
+ * ```
34
+ * @param visible - The new visibility state of the collapse.
35
+ */
36
+ onVisibleChange: (visible: boolean) => void;
37
+ /**
38
+ * Callback called when the collapse is hidden.
39
+ *
40
+ * @defaultValue
41
+ * ```ts
42
+ * () => {}
43
+ * ```
44
+ */
45
+ onHidden: () => void;
46
+ /**
47
+ * Callback called when the collapse is shown.
48
+ *
49
+ * @defaultValue
50
+ * ```ts
51
+ * () => {}
52
+ * ```
53
+ */
54
+ onShown: () => void;
55
+ /**
56
+ * If `true`, collapse opening will be animated at init time.
57
+ *
58
+ * @defaultValue `false`
59
+ */
60
+ animatedOnInit: boolean;
61
+ /**
62
+ * If `true`, collapse closing and opening will be animated.
63
+ *
64
+ * @defaultValue `true`
65
+ */
66
+ animated: boolean;
67
+ /**
68
+ * id of the collapse
69
+ *
70
+ * @defaultValue `''`
71
+ */
72
+ id: string;
73
+ /**
74
+ * The transition function will be executed when the collapse is displayed or hidden.
75
+ *
76
+ * Depending on the value of `animatedOnInit`, the animation can be optionally skipped during the showing process.
77
+ *
78
+ * @defaultValue `() => {}`
79
+ */
80
+ transition: TransitionFn;
81
+ }
82
+ /**
83
+ * Interface representing the API for a collapsible component.
84
+ */
85
+ export interface CollapseApi {
86
+ /**
87
+ * Triggers collapse closing programmatically.
88
+ */
89
+ close(): void;
90
+ /**
91
+ * Triggers the collapse content to be displayed for the user.
92
+ */
93
+ open(): void;
94
+ /**
95
+ * Toggles the collapse content visibility.
96
+ */
97
+ toggle(): void;
98
+ }
99
+ /**
100
+ * Interface representing the directives used in a collapse component.
101
+ */
102
+ export interface CollapseDirectives {
103
+ /**
104
+ * Directive to apply the collapse.
105
+ */
106
+ collapseDirective: Directive;
107
+ /**
108
+ * Directive to apply to a trigger;
109
+ */
110
+ triggerDirective: Directive;
111
+ }
112
+ /**
113
+ * Represents a widget for handling collapse functionality.
114
+ *
115
+ * This type defines the structure of a CollapseWidget, which includes properties, state, API, and directives
116
+ * necessary for managing the collapse behavior in the UI.
117
+ *
118
+ * @type {Widget<CollapseProps, CollapseState, CollapseApi, CollapseDirectives>}
119
+ */
120
+ export type CollapseWidget = Widget<CollapseProps, CollapseState, CollapseApi, CollapseDirectives>;
121
+ /**
122
+ * Retrieve a shallow copy of the default collapse config
123
+ * @returns the default collapse config
124
+ */
125
+ export declare function getCollapseDefaultConfig(): CollapseProps;
126
+ /**
127
+ * Create an CollapseWidget factory
128
+ * @param transitionFn - the transition function that will be used for the collapse
129
+ * @returns an CollapseWidget
130
+ */
131
+ export declare const createCollapse: WidgetFactory<CollapseWidget>;
132
+ export {};
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const collapse = require("../../collapse-DRp53EuG.cjs");
4
+ exports.createCollapse = collapse.createCollapse;
5
+ exports.getCollapseDefaultConfig = collapse.getCollapseDefaultConfig;
@@ -0,0 +1 @@
1
+ export * from './collapse';
@@ -0,0 +1,5 @@
1
+ import { c, g } from "../../collapse-DwXz2kNw.js";
2
+ export {
3
+ c as createCollapse,
4
+ g as getCollapseDefaultConfig
5
+ };
package/config.d.ts CHANGED
@@ -10,6 +10,7 @@ import type { SliderProps } from './components/slider/slider';
10
10
  import type { ToastProps } from './components/toast/toast';
11
11
  import type { TreeProps } from './components/tree/tree';
12
12
  import type { CarouselProps } from './components/carousel';
13
+ import type { CollapseProps } from './components/collapse';
13
14
  /**
14
15
  * A utility type that makes all properties of an object type `T` optional,
15
16
  * and also makes all properties of the nested objects within `T` optional.
@@ -109,4 +110,8 @@ export type WidgetsConfig = {
109
110
  * carousel widget config
110
111
  */
111
112
  carousel: CarouselProps;
113
+ /**
114
+ * collapse widget config
115
+ */
116
+ collapse: CollapseProps;
112
117
  };
package/index.cjs CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const types = require("./types.cjs");
4
4
  const accordion = require("./accordion-cR5JqWJ8.cjs");
5
5
  const alert = require("./alert-DtDozJal.cjs");
6
+ const collapse = require("./collapse-DRp53EuG.cjs");
6
7
  const modal = require("./modal-BEnQ6c5M.cjs");
7
8
  const pagination = require("./pagination-C1TT-oea.cjs");
8
9
  const progressbar = require("./progressbar-CRvhNB5R.cjs");
@@ -36,6 +37,8 @@ exports.factoryCreateAccordion = accordion.factoryCreateAccordion;
36
37
  exports.getAccordionDefaultConfig = accordion.getAccordionDefaultConfig;
37
38
  exports.createAlert = alert.createAlert;
38
39
  exports.getAlertDefaultConfig = alert.getAlertDefaultConfig;
40
+ exports.createCollapse = collapse.createCollapse;
41
+ exports.getCollapseDefaultConfig = collapse.getCollapseDefaultConfig;
39
42
  exports.createModal = modal.createModal;
40
43
  exports.getModalDefaultConfig = modal.getModalDefaultConfig;
41
44
  exports.modalCloseButtonClick = modal.modalCloseButtonClick;
package/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './types';
2
2
  export * from './components/accordion';
3
3
  export * from './components/alert';
4
+ export * from './components/collapse';
4
5
  export * from './components/modal';
5
6
  export * from './components/pagination';
6
7
  export * from './components/progressbar';
package/index.js CHANGED
@@ -1,14 +1,15 @@
1
1
  import { FACTORY_WIDGET_NAME, INVALID_VALUE } from "./types.js";
2
2
  import { a, c, f, g } from "./accordion-CoM4efp-.js";
3
3
  import { c as c2, g as g2 } from "./alert-YIlqdEPO.js";
4
- import { c as c3, g as g3, a as a2, m } from "./modal-D3wGIDlj.js";
5
- import { c as c4, g as g4 } from "./pagination-B97wBLok.js";
6
- import { c as c5, g as g5 } from "./progressbar-BWBlRk_Y.js";
7
- import { c as c6, g as g6 } from "./rating-BXvy9kXq.js";
8
- import { c as c7, g as g7 } from "./select-BdjpnE7_.js";
9
- import { c as c8, g as g8 } from "./slider-BmxQ3A_u.js";
10
- import { T, c as c9, d, g as g9 } from "./toaster-XfzHDqz_.js";
11
- import { c as c10, g as g10 } from "./tree-BFrXdJox.js";
4
+ import { c as c3, g as g3 } from "./collapse-DwXz2kNw.js";
5
+ import { c as c4, g as g4, a as a2, m } from "./modal-D3wGIDlj.js";
6
+ import { c as c5, g as g5 } from "./pagination-B97wBLok.js";
7
+ import { c as c6, g as g6 } from "./progressbar-BWBlRk_Y.js";
8
+ import { c as c7, g as g7 } from "./rating-BXvy9kXq.js";
9
+ import { c as c8, g as g8 } from "./select-BdjpnE7_.js";
10
+ import { c as c9, g as g9 } from "./slider-BmxQ3A_u.js";
11
+ import { T, c as c10, d, g as g10 } from "./toaster-XfzHDqz_.js";
12
+ import { c as c11, g as g11 } from "./tree-BFrXdJox.js";
12
13
  import { createWidgetsConfig, mergeInto } from "./config.js";
13
14
  import { extendWidgetProps } from "./services/extendWidget.js";
14
15
  import { createFloatingUI } from "./services/floatingUI.js";
@@ -23,9 +24,9 @@ import { hash$ } from "./services/hash.js";
23
24
  import { createTransition, noAnimation } from "./services/transitions/baseTransitions.js";
24
25
  import { createCSSTransition, getTransitionDurationMs, hasTransition } from "./services/transitions/cssTransitions.js";
25
26
  import { createSimpleClassTransition } from "./services/transitions/simpleClassTransition.js";
26
- import { o, a as a3, c as c11, b, p, n, g as g11, j, f as f2, h, q, d as d2, e, i, m as m2, k, l, r, s } from "./dom-gfxqXJpK.js";
27
+ import { o, a as a3, c as c12, b, p, n, g as g12, j, f as f2, h, q, d as d2, e, i, m as m2, k, l, r, s } from "./dom-gfxqXJpK.js";
27
28
  import { bindableDerived, bindableProp, createPatch, false$, findChangedProperties, idWithDefault, isStore, mergeConfigStores, normalizeConfigStores, stateStores, toReadableStore, toWritableStore, true$, writableWithDefault, writablesForProps, writablesWithDefault } from "./utils/stores.js";
28
- import { j as j2, t, i as i2, c as c12, d as d3, g as g12, h as h2, a as a4, b as b2, e as e2, f as f3 } from "./writables-CgpOQ4hA.js";
29
+ import { j as j2, t, i as i2, c as c13, d as d3, g as g13, h as h2, a as a4, b as b2, e as e2, f as f3 } from "./writables-CgpOQ4hA.js";
29
30
  export {
30
31
  FACTORY_WIDGET_NAME,
31
32
  INVALID_VALUE,
@@ -33,7 +34,7 @@ export {
33
34
  activeElement$,
34
35
  o as attributesData,
35
36
  a3 as bindDirective,
36
- c11 as bindDirectiveNoArg,
37
+ c12 as bindDirectiveNoArg,
37
38
  bindableDerived,
38
39
  bindableProp,
39
40
  b as browserDirective,
@@ -42,28 +43,29 @@ export {
42
43
  c as createAccordionItem,
43
44
  c2 as createAlert,
44
45
  n as createAttributesDirective,
45
- g11 as createBrowserStoreArrayDirective,
46
+ g12 as createBrowserStoreArrayDirective,
46
47
  j as createBrowserStoreDirective,
47
48
  createCSSTransition,
49
+ c3 as createCollapse,
48
50
  createFloatingUI,
49
51
  createHasFocus,
50
52
  createIntersection,
51
53
  createMatchMedia,
52
- c3 as createModal,
54
+ c4 as createModal,
53
55
  createNavManager,
54
- c4 as createPagination,
56
+ c5 as createPagination,
55
57
  createPatch,
56
- c5 as createProgressbar,
57
- c6 as createRating,
58
+ c6 as createProgressbar,
59
+ c7 as createRating,
58
60
  createResizeObserver,
59
- c7 as createSelect,
61
+ c8 as createSelect,
60
62
  createSimpleClassTransition,
61
- c8 as createSlider,
63
+ c9 as createSlider,
62
64
  f2 as createStoreArrayDirective,
63
65
  h as createStoreDirective,
64
- c9 as createToast,
66
+ c10 as createToast,
65
67
  createTransition,
66
- c10 as createTree,
68
+ c11 as createTree,
67
69
  j2 as createTypeEnum,
68
70
  createWidgetsConfig,
69
71
  d as defaultToasterProps,
@@ -76,16 +78,17 @@ export {
76
78
  findChangedProperties,
77
79
  g as getAccordionDefaultConfig,
78
80
  g2 as getAlertDefaultConfig,
81
+ g3 as getCollapseDefaultConfig,
79
82
  getKeyName,
80
- g3 as getModalDefaultConfig,
81
- g4 as getPaginationDefaultConfig,
82
- g5 as getProgressbarDefaultConfig,
83
- g6 as getRatingDefaultConfig,
84
- g7 as getSelectDefaultConfig,
85
- g8 as getSliderDefaultConfig,
86
- g9 as getToastDefaultConfig,
83
+ g4 as getModalDefaultConfig,
84
+ g5 as getPaginationDefaultConfig,
85
+ g6 as getProgressbarDefaultConfig,
86
+ g7 as getRatingDefaultConfig,
87
+ g8 as getSelectDefaultConfig,
88
+ g9 as getSliderDefaultConfig,
89
+ g10 as getToastDefaultConfig,
87
90
  getTransitionDurationMs,
88
- g10 as getTreeDefaultConfig,
91
+ g11 as getTreeDefaultConfig,
89
92
  hasTransition,
90
93
  hash$,
91
94
  idWithDefault,
@@ -111,9 +114,9 @@ export {
111
114
  toWritableStore,
112
115
  true$,
113
116
  i2 as typeArray,
114
- c12 as typeBoolean,
117
+ c13 as typeBoolean,
115
118
  d3 as typeBooleanOrNull,
116
- g12 as typeFunction,
119
+ g13 as typeFunction,
117
120
  h2 as typeHTMLElementOrNull,
118
121
  a4 as typeNumber,
119
122
  b2 as typeNumberInRangeFactory,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agnos-ui/core",
3
3
  "description": "Framework-agnostic headless component library.",
4
- "version": "0.9.1",
4
+ "version": "0.9.3",
5
5
  "type": "module",
6
6
  "main": "./index.cjs",
7
7
  "module": "./index.js",