@design-factory/angular 21.0.4 → 21.1.0-next.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.
- package/drawer/README.md +54 -0
- package/fesm2022/design-factory-angular-drawer.mjs +202 -67
- package/fesm2022/design-factory-angular-drawer.mjs.map +1 -1
- package/fesm2022/design-factory-angular-internals.mjs +439 -17
- package/fesm2022/design-factory-angular-internals.mjs.map +1 -1
- package/fesm2022/design-factory-angular-sidenav.mjs +223 -210
- package/fesm2022/design-factory-angular-sidenav.mjs.map +1 -1
- package/fesm2022/design-factory-angular-theme.mjs +198 -0
- package/fesm2022/design-factory-angular-theme.mjs.map +1 -0
- package/fesm2022/design-factory-angular-topnav.mjs +1538 -0
- package/fesm2022/design-factory-angular-topnav.mjs.map +1 -0
- package/node_modules/@agnos-ui/core/README.md +5 -0
- package/node_modules/@agnos-ui/core/accordion-BC_9xn23.cjs +314 -0
- package/node_modules/@agnos-ui/core/accordion-Ca_0T8Bc.js +315 -0
- package/node_modules/@agnos-ui/core/alert-AhaliJ17.cjs +9 -0
- package/node_modules/@agnos-ui/core/alert-Cb9FhbFQ.js +10 -0
- package/node_modules/@agnos-ui/core/collapse-COriZO7o.cjs +94 -0
- package/node_modules/@agnos-ui/core/collapse-CP79atna.js +95 -0
- package/node_modules/@agnos-ui/core/common-B5jS-Ih_.cjs +73 -0
- package/node_modules/@agnos-ui/core/common-DFyZvkII.js +74 -0
- package/node_modules/@agnos-ui/core/components/accordion/accordion.d.ts +333 -0
- package/node_modules/@agnos-ui/core/components/accordion/index.cjs +7 -0
- package/node_modules/@agnos-ui/core/components/accordion/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/accordion/index.js +7 -0
- package/node_modules/@agnos-ui/core/components/alert/alert.d.ts +37 -0
- package/node_modules/@agnos-ui/core/components/alert/common.d.ts +138 -0
- package/node_modules/@agnos-ui/core/components/alert/index.cjs +5 -0
- package/node_modules/@agnos-ui/core/components/alert/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/alert/index.js +5 -0
- package/node_modules/@agnos-ui/core/components/carousel/carousel.d.ts +247 -0
- package/node_modules/@agnos-ui/core/components/carousel/index.cjs +292 -0
- package/node_modules/@agnos-ui/core/components/carousel/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/carousel/index.js +292 -0
- package/node_modules/@agnos-ui/core/components/collapse/collapse.d.ts +135 -0
- package/node_modules/@agnos-ui/core/components/collapse/index.cjs +5 -0
- package/node_modules/@agnos-ui/core/components/collapse/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/collapse/index.js +5 -0
- package/node_modules/@agnos-ui/core/components/commonProps.d.ts +11 -0
- package/node_modules/@agnos-ui/core/components/drawer/drawer.d.ts +279 -0
- package/node_modules/@agnos-ui/core/components/drawer/index.cjs +5 -0
- package/node_modules/@agnos-ui/core/components/drawer/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/drawer/index.js +5 -0
- package/node_modules/@agnos-ui/core/components/modal/index.cjs +8 -0
- package/node_modules/@agnos-ui/core/components/modal/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/modal/index.js +8 -0
- package/node_modules/@agnos-ui/core/components/modal/modal.d.ts +245 -0
- package/node_modules/@agnos-ui/core/components/pagination/index.cjs +5 -0
- package/node_modules/@agnos-ui/core/components/pagination/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/pagination/index.js +5 -0
- package/node_modules/@agnos-ui/core/components/pagination/pagination.d.ts +313 -0
- package/node_modules/@agnos-ui/core/components/progressbar/index.cjs +5 -0
- package/node_modules/@agnos-ui/core/components/progressbar/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/progressbar/index.js +5 -0
- package/node_modules/@agnos-ui/core/components/progressbar/progressbar.d.ts +91 -0
- package/node_modules/@agnos-ui/core/components/rating/index.cjs +5 -0
- package/node_modules/@agnos-ui/core/components/rating/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/rating/index.js +5 -0
- package/node_modules/@agnos-ui/core/components/rating/rating.d.ts +191 -0
- package/node_modules/@agnos-ui/core/components/slider/index.cjs +5 -0
- package/node_modules/@agnos-ui/core/components/slider/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/slider/index.js +5 -0
- package/node_modules/@agnos-ui/core/components/slider/slider-utils.d.ts +25 -0
- package/node_modules/@agnos-ui/core/components/slider/slider.d.ts +383 -0
- package/node_modules/@agnos-ui/core/components/toast/index.cjs +7 -0
- package/node_modules/@agnos-ui/core/components/toast/index.d.ts +2 -0
- package/node_modules/@agnos-ui/core/components/toast/index.js +7 -0
- package/node_modules/@agnos-ui/core/components/toast/toast.d.ts +66 -0
- package/node_modules/@agnos-ui/core/components/toast/toaster.d.ts +128 -0
- package/node_modules/@agnos-ui/core/components/tree/index.cjs +5 -0
- package/node_modules/@agnos-ui/core/components/tree/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/tree/index.js +5 -0
- package/node_modules/@agnos-ui/core/components/tree/tree.d.ts +143 -0
- package/node_modules/@agnos-ui/core/config.cjs +36 -0
- package/node_modules/@agnos-ui/core/config.d.ts +117 -0
- package/node_modules/@agnos-ui/core/config.js +36 -0
- package/node_modules/@agnos-ui/core/directive-Bsreu2z1.js +523 -0
- package/node_modules/@agnos-ui/core/directive-DCaXmRe_.cjs +522 -0
- package/node_modules/@agnos-ui/core/drawer-BbFAHV07.cjs +328 -0
- package/node_modules/@agnos-ui/core/drawer-C6Qa0xEu.js +329 -0
- package/node_modules/@agnos-ui/core/index.cjs +134 -0
- package/node_modules/@agnos-ui/core/index.d.ts +29 -0
- package/node_modules/@agnos-ui/core/index.js +134 -0
- package/node_modules/@agnos-ui/core/isFocusable-Ckwus82R.js +32 -0
- package/node_modules/@agnos-ui/core/isFocusable-DfzDLeAN.cjs +31 -0
- package/node_modules/@agnos-ui/core/modal-BsNuHhT7.cjs +252 -0
- package/node_modules/@agnos-ui/core/modal-CgzY8ezz.js +253 -0
- package/node_modules/@agnos-ui/core/package.json +57 -0
- package/node_modules/@agnos-ui/core/pagination-ZxGaNWZz.js +255 -0
- package/node_modules/@agnos-ui/core/pagination-xbcOHnhd.cjs +254 -0
- package/node_modules/@agnos-ui/core/progressbar-CRbMKp4b.cjs +86 -0
- package/node_modules/@agnos-ui/core/progressbar-CSEIFnlD.js +87 -0
- package/node_modules/@agnos-ui/core/promise-CxCD3NYv.cjs +118 -0
- package/node_modules/@agnos-ui/core/promise-D-RZVPuv.js +119 -0
- package/node_modules/@agnos-ui/core/rating-BIdiiPUo.js +184 -0
- package/node_modules/@agnos-ui/core/rating-qx1xaBmz.cjs +183 -0
- package/node_modules/@agnos-ui/core/scrollbars-CT87iv_6.cjs +30 -0
- package/node_modules/@agnos-ui/core/scrollbars-CcxSrnCx.js +31 -0
- package/node_modules/@agnos-ui/core/services/extendWidget.cjs +41 -0
- package/node_modules/@agnos-ui/core/services/extendWidget.d.ts +31 -0
- package/node_modules/@agnos-ui/core/services/extendWidget.js +41 -0
- package/node_modules/@agnos-ui/core/services/floatingUI.cjs +111 -0
- package/node_modules/@agnos-ui/core/services/floatingUI.d.ts +76 -0
- package/node_modules/@agnos-ui/core/services/floatingUI.js +111 -0
- package/node_modules/@agnos-ui/core/services/focusElement.cjs +46 -0
- package/node_modules/@agnos-ui/core/services/focusElement.d.ts +9 -0
- package/node_modules/@agnos-ui/core/services/focusElement.js +46 -0
- package/node_modules/@agnos-ui/core/services/focustrack.cjs +47 -0
- package/node_modules/@agnos-ui/core/services/focustrack.d.ts +40 -0
- package/node_modules/@agnos-ui/core/services/focustrack.js +47 -0
- package/node_modules/@agnos-ui/core/services/hash.cjs +15 -0
- package/node_modules/@agnos-ui/core/services/hash.d.ts +3 -0
- package/node_modules/@agnos-ui/core/services/hash.js +15 -0
- package/node_modules/@agnos-ui/core/services/intersection.cjs +53 -0
- package/node_modules/@agnos-ui/core/services/intersection.d.ts +30 -0
- package/node_modules/@agnos-ui/core/services/intersection.js +53 -0
- package/node_modules/@agnos-ui/core/services/matchMedia.cjs +14 -0
- package/node_modules/@agnos-ui/core/services/matchMedia.d.ts +8 -0
- package/node_modules/@agnos-ui/core/services/matchMedia.js +14 -0
- package/node_modules/@agnos-ui/core/services/navManager.cjs +166 -0
- package/node_modules/@agnos-ui/core/services/navManager.d.ts +144 -0
- package/node_modules/@agnos-ui/core/services/navManager.js +166 -0
- package/node_modules/@agnos-ui/core/services/pointerdownPosition.cjs +60 -0
- package/node_modules/@agnos-ui/core/services/pointerdownPosition.d.ts +42 -0
- package/node_modules/@agnos-ui/core/services/pointerdownPosition.js +60 -0
- package/node_modules/@agnos-ui/core/services/portal.cjs +42 -0
- package/node_modules/@agnos-ui/core/services/portal.d.ts +16 -0
- package/node_modules/@agnos-ui/core/services/portal.js +42 -0
- package/node_modules/@agnos-ui/core/services/resizeObserver.cjs +54 -0
- package/node_modules/@agnos-ui/core/services/resizeObserver.d.ts +18 -0
- package/node_modules/@agnos-ui/core/services/resizeObserver.js +54 -0
- package/node_modules/@agnos-ui/core/services/siblingsInert.cjs +44 -0
- package/node_modules/@agnos-ui/core/services/siblingsInert.d.ts +16 -0
- package/node_modules/@agnos-ui/core/services/siblingsInert.js +44 -0
- package/node_modules/@agnos-ui/core/services/transitions/baseTransitions.cjs +186 -0
- package/node_modules/@agnos-ui/core/services/transitions/baseTransitions.d.ts +166 -0
- package/node_modules/@agnos-ui/core/services/transitions/baseTransitions.js +186 -0
- package/node_modules/@agnos-ui/core/services/transitions/collapse.cjs +40 -0
- package/node_modules/@agnos-ui/core/services/transitions/collapse.d.ts +49 -0
- package/node_modules/@agnos-ui/core/services/transitions/collapse.js +40 -0
- package/node_modules/@agnos-ui/core/services/transitions/cssTransitions.cjs +32 -0
- package/node_modules/@agnos-ui/core/services/transitions/cssTransitions.d.ts +25 -0
- package/node_modules/@agnos-ui/core/services/transitions/cssTransitions.js +32 -0
- package/node_modules/@agnos-ui/core/services/transitions/simpleClassTransition.cjs +37 -0
- package/node_modules/@agnos-ui/core/services/transitions/simpleClassTransition.d.ts +47 -0
- package/node_modules/@agnos-ui/core/services/transitions/simpleClassTransition.js +37 -0
- package/node_modules/@agnos-ui/core/slider-B93hE0ag.cjs +807 -0
- package/node_modules/@agnos-ui/core/slider-Cjiq9FgI.js +808 -0
- package/node_modules/@agnos-ui/core/textDirection-cNgt24LJ.js +4 -0
- package/node_modules/@agnos-ui/core/textDirection-zqcZ5-eK.cjs +3 -0
- package/node_modules/@agnos-ui/core/toaster-BQWqxYv-.cjs +190 -0
- package/node_modules/@agnos-ui/core/toaster-BzEkshT2.js +191 -0
- package/node_modules/@agnos-ui/core/tree-DY04XPPg.cjs +228 -0
- package/node_modules/@agnos-ui/core/tree-HwcvZ0_p.js +229 -0
- package/node_modules/@agnos-ui/core/types.cjs +6 -0
- package/node_modules/@agnos-ui/core/types.d.ts +246 -0
- package/node_modules/@agnos-ui/core/types.js +6 -0
- package/node_modules/@agnos-ui/core/utils/directive.cjs +28 -0
- package/node_modules/@agnos-ui/core/utils/directive.d.ts +352 -0
- package/node_modules/@agnos-ui/core/utils/directive.js +28 -0
- package/node_modules/@agnos-ui/core/utils/func.cjs +7 -0
- package/node_modules/@agnos-ui/core/utils/func.d.ts +11 -0
- package/node_modules/@agnos-ui/core/utils/func.js +7 -0
- package/node_modules/@agnos-ui/core/utils/id.cjs +5 -0
- package/node_modules/@agnos-ui/core/utils/id.d.ts +6 -0
- package/node_modules/@agnos-ui/core/utils/id.js +5 -0
- package/node_modules/@agnos-ui/core/utils/internal/assign.d.ts +10 -0
- package/node_modules/@agnos-ui/core/utils/internal/checks.d.ts +57 -0
- package/node_modules/@agnos-ui/core/utils/internal/dom.d.ts +75 -0
- package/node_modules/@agnos-ui/core/utils/internal/isFocusable.d.ts +9 -0
- package/node_modules/@agnos-ui/core/utils/internal/math.d.ts +5 -0
- package/node_modules/@agnos-ui/core/utils/internal/promise.d.ts +98 -0
- package/node_modules/@agnos-ui/core/utils/internal/scrollbars.d.ts +8 -0
- package/node_modules/@agnos-ui/core/utils/internal/sort.d.ts +16 -0
- package/node_modules/@agnos-ui/core/utils/internal/ssrHTMLElement.d.ts +17 -0
- package/node_modules/@agnos-ui/core/utils/internal/textDirection.d.ts +7 -0
- package/node_modules/@agnos-ui/core/utils/internal/traversal.d.ts +54 -0
- package/node_modules/@agnos-ui/core/utils/stores.cjs +172 -0
- package/node_modules/@agnos-ui/core/utils/stores.d.ts +224 -0
- package/node_modules/@agnos-ui/core/utils/stores.js +172 -0
- package/node_modules/@agnos-ui/core/utils/widget.cjs +8 -0
- package/node_modules/@agnos-ui/core/utils/widget.d.ts +11 -0
- package/node_modules/@agnos-ui/core/utils/widget.js +8 -0
- package/node_modules/@agnos-ui/core/utils/writables.cjs +16 -0
- package/node_modules/@agnos-ui/core/utils/writables.d.ts +95 -0
- package/node_modules/@agnos-ui/core/utils/writables.js +16 -0
- package/node_modules/@agnos-ui/core/writables-DYGjj5T3.js +103 -0
- package/node_modules/@agnos-ui/core/writables-Dt68gADJ.cjs +102 -0
- package/package.json +25 -6
- package/schematics/collection.json +1 -1
- package/types/design-factory-angular-drawer.d.ts +71 -13
- package/types/design-factory-angular-internals.d.ts +220 -31
- package/types/design-factory-angular-sidenav.d.ts +15 -7
- package/types/design-factory-angular-theme.d.ts +122 -0
- package/types/design-factory-angular-topnav.d.ts +435 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const tansu = require("@amadeus-it-group/tansu");
|
|
3
|
+
const utils_stores = require("./utils/stores.cjs");
|
|
4
|
+
const utils_writables = require("./writables-Dt68gADJ.cjs");
|
|
5
|
+
const utils_func = require("./utils/func.cjs");
|
|
6
|
+
const utils_directive = require("./directive-DCaXmRe_.cjs");
|
|
7
|
+
const utils_widget = require("./utils/widget.cjs");
|
|
8
|
+
const PAGE_LINK_DEFAULT = "#";
|
|
9
|
+
const defaultConfig = {
|
|
10
|
+
page: 1,
|
|
11
|
+
collectionSize: 0,
|
|
12
|
+
pageSize: 10,
|
|
13
|
+
disabled: false,
|
|
14
|
+
directionLinks: true,
|
|
15
|
+
boundaryLinks: false,
|
|
16
|
+
onPageChange: utils_func.noop,
|
|
17
|
+
pagesFactory: (_page, pageCount) => {
|
|
18
|
+
const pages = [];
|
|
19
|
+
for (let i = 1; i <= pageCount; i++) {
|
|
20
|
+
pages.push(i);
|
|
21
|
+
}
|
|
22
|
+
return pages;
|
|
23
|
+
},
|
|
24
|
+
ariaLabel: "Page navigation",
|
|
25
|
+
activeLabel: "(current)",
|
|
26
|
+
ariaPageLabel: (processPage, pageCount) => `Page ${processPage} of ${pageCount}`,
|
|
27
|
+
ariaFirstLabel: "Action link for first page",
|
|
28
|
+
ariaPreviousLabel: "Action link for previous page",
|
|
29
|
+
ariaNextLabel: "Action link for next page",
|
|
30
|
+
ariaLastLabel: "Action link for last page",
|
|
31
|
+
ariaEllipsisLabel: "Ellipsis page element",
|
|
32
|
+
ariaLiveLabel: (currentPage) => `Current page is ${currentPage}`,
|
|
33
|
+
className: "",
|
|
34
|
+
pageLink: (_page) => PAGE_LINK_DEFAULT
|
|
35
|
+
};
|
|
36
|
+
function getPaginationDefaultConfig() {
|
|
37
|
+
return { ...defaultConfig };
|
|
38
|
+
}
|
|
39
|
+
const configValidator = {
|
|
40
|
+
page: utils_writables.typeNumber,
|
|
41
|
+
collectionSize: utils_writables.typeNumber,
|
|
42
|
+
pageSize: utils_writables.typeNumber,
|
|
43
|
+
disabled: utils_writables.typeBoolean,
|
|
44
|
+
directionLinks: utils_writables.typeBoolean,
|
|
45
|
+
boundaryLinks: utils_writables.typeBoolean,
|
|
46
|
+
onPageChange: utils_writables.typeFunction,
|
|
47
|
+
pagesFactory: utils_writables.typeFunction,
|
|
48
|
+
ariaLabel: utils_writables.typeString,
|
|
49
|
+
activeLabel: utils_writables.typeString,
|
|
50
|
+
ariaPageLabel: utils_writables.typeFunction,
|
|
51
|
+
ariaFirstLabel: utils_writables.typeString,
|
|
52
|
+
ariaPreviousLabel: utils_writables.typeString,
|
|
53
|
+
ariaNextLabel: utils_writables.typeString,
|
|
54
|
+
ariaLastLabel: utils_writables.typeString,
|
|
55
|
+
ariaLiveLabel: utils_writables.typeFunction,
|
|
56
|
+
className: utils_writables.typeString,
|
|
57
|
+
pageLink: utils_writables.typeFunction,
|
|
58
|
+
ariaEllipsisLabel: utils_writables.typeString
|
|
59
|
+
};
|
|
60
|
+
const createPagination = utils_widget.createWidgetFactory(
|
|
61
|
+
"pagination",
|
|
62
|
+
(config) => {
|
|
63
|
+
const [
|
|
64
|
+
{
|
|
65
|
+
// dirty inputs that need adjustment:
|
|
66
|
+
page$: _dirtyPage$,
|
|
67
|
+
// clean inputs with value validation:
|
|
68
|
+
collectionSize$,
|
|
69
|
+
pageSize$,
|
|
70
|
+
onPageChange$,
|
|
71
|
+
pagesFactory$,
|
|
72
|
+
ariaPageLabel$,
|
|
73
|
+
ariaLiveLabel$,
|
|
74
|
+
pageLink$,
|
|
75
|
+
disabled$,
|
|
76
|
+
ariaFirstLabel$,
|
|
77
|
+
ariaLastLabel$,
|
|
78
|
+
ariaNextLabel$,
|
|
79
|
+
ariaPreviousLabel$,
|
|
80
|
+
...stateProps
|
|
81
|
+
},
|
|
82
|
+
patch
|
|
83
|
+
] = utils_stores.writablesForProps(defaultConfig, config, configValidator);
|
|
84
|
+
const pageCount$ = tansu.computed(() => {
|
|
85
|
+
let pageCount = Math.ceil(collectionSize$() / pageSize$());
|
|
86
|
+
if (!utils_writables.isNumber(pageCount) || pageCount < 1) {
|
|
87
|
+
pageCount = 1;
|
|
88
|
+
}
|
|
89
|
+
return pageCount;
|
|
90
|
+
});
|
|
91
|
+
const page$ = utils_stores.bindableProp(_dirtyPage$, onPageChange$, (dirtyPage) => utils_writables.clamp(dirtyPage, pageCount$(), 1));
|
|
92
|
+
const pages$ = tansu.computed(() => pagesFactory$()(page$(), pageCount$()));
|
|
93
|
+
const nextDisabled$ = tansu.computed(() => page$() === pageCount$() || disabled$());
|
|
94
|
+
const previousDisabled$ = tansu.computed(() => page$() === 1 || disabled$());
|
|
95
|
+
const pagesLabel$ = tansu.computed(() => {
|
|
96
|
+
const ariaPageLabel = ariaPageLabel$();
|
|
97
|
+
const pageCount = pageCount$();
|
|
98
|
+
return pages$().map((page) => ariaPageLabel(page, pageCount));
|
|
99
|
+
});
|
|
100
|
+
const pagesHrefs$ = tansu.computed(() => {
|
|
101
|
+
const pageLinkFactory = pageLink$();
|
|
102
|
+
const pageCount = pageCount$();
|
|
103
|
+
return Array.from({ length: pageCount }, (_, index) => pageLinkFactory(index + 1));
|
|
104
|
+
});
|
|
105
|
+
const directionsHrefs$ = tansu.computed(() => {
|
|
106
|
+
const pagesHrefs = pagesHrefs$();
|
|
107
|
+
const pageIndex = page$() - 1;
|
|
108
|
+
return {
|
|
109
|
+
previous: pagesHrefs.at(pageIndex > 0 ? pageIndex - 1 : 0),
|
|
110
|
+
next: pagesHrefs.at(pageIndex + 1) ?? pagesHrefs.at(-1)
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
const ariaLiveLabelText$ = tansu.computed(() => ariaLiveLabel$()(page$(), pageCount$()));
|
|
114
|
+
function handleNavigation(pageNumber, event) {
|
|
115
|
+
if (pagesHrefs$()[pageNumber - 1] === PAGE_LINK_DEFAULT) {
|
|
116
|
+
event?.preventDefault();
|
|
117
|
+
}
|
|
118
|
+
if (!event || !(event.ctrlKey || event.metaKey)) {
|
|
119
|
+
event?.preventDefault();
|
|
120
|
+
page$.set(pageNumber);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const widget = {
|
|
124
|
+
...utils_stores.stateStores({
|
|
125
|
+
pageCount$,
|
|
126
|
+
page$,
|
|
127
|
+
pages$,
|
|
128
|
+
nextDisabled$,
|
|
129
|
+
previousDisabled$,
|
|
130
|
+
pagesLabel$,
|
|
131
|
+
pagesHrefs$,
|
|
132
|
+
directionsHrefs$,
|
|
133
|
+
disabled$,
|
|
134
|
+
ariaFirstLabel$,
|
|
135
|
+
ariaLastLabel$,
|
|
136
|
+
ariaNextLabel$,
|
|
137
|
+
ariaPreviousLabel$,
|
|
138
|
+
ariaLiveLabelText$,
|
|
139
|
+
...stateProps
|
|
140
|
+
}),
|
|
141
|
+
patch,
|
|
142
|
+
api: {
|
|
143
|
+
/**
|
|
144
|
+
* Set the current page pageNumber (starting from 1)
|
|
145
|
+
* @param pageNumber - Current page number to set.
|
|
146
|
+
* Value is normalized between 1 and the number of page
|
|
147
|
+
*/
|
|
148
|
+
select(pageNumber) {
|
|
149
|
+
page$.set(pageNumber);
|
|
150
|
+
},
|
|
151
|
+
/**
|
|
152
|
+
* Select the first page
|
|
153
|
+
*/
|
|
154
|
+
first() {
|
|
155
|
+
page$.set(1);
|
|
156
|
+
},
|
|
157
|
+
/**
|
|
158
|
+
* Select the previous page
|
|
159
|
+
*/
|
|
160
|
+
previous() {
|
|
161
|
+
page$.update((p) => p - 1);
|
|
162
|
+
},
|
|
163
|
+
/**
|
|
164
|
+
* Select the next page
|
|
165
|
+
*/
|
|
166
|
+
next() {
|
|
167
|
+
page$.update((p) => p + 1);
|
|
168
|
+
},
|
|
169
|
+
/**
|
|
170
|
+
* Select the last page
|
|
171
|
+
*/
|
|
172
|
+
last() {
|
|
173
|
+
page$.set(pageCount$());
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
directives: {
|
|
177
|
+
pageLink: utils_directive.createAttributesDirective((pageLinkContext$) => ({
|
|
178
|
+
events: {
|
|
179
|
+
click: (e) => handleNavigation(pageLinkContext$().page, e)
|
|
180
|
+
},
|
|
181
|
+
attributes: {
|
|
182
|
+
"aria-current": tansu.computed(() => page$() === pageLinkContext$().page ? "page" : void 0),
|
|
183
|
+
"aria-label": tansu.computed(() => pagesLabel$()[pageLinkContext$().page - 1]),
|
|
184
|
+
href: tansu.computed(() => pagesHrefs$()[pageLinkContext$().page - 1]),
|
|
185
|
+
tabindex: tansu.computed(() => disabled$() ? "-1" : void 0),
|
|
186
|
+
"aria-disabled": tansu.computed(() => disabled$() ? "true" : void 0)
|
|
187
|
+
},
|
|
188
|
+
classNames: {
|
|
189
|
+
"au-page": utils_stores.true$
|
|
190
|
+
}
|
|
191
|
+
})),
|
|
192
|
+
pageFirst: utils_directive.createAttributesDirective(() => ({
|
|
193
|
+
events: {
|
|
194
|
+
click: (e) => handleNavigation(1, e)
|
|
195
|
+
},
|
|
196
|
+
attributes: {
|
|
197
|
+
"aria-label": ariaFirstLabel$,
|
|
198
|
+
href: tansu.computed(() => pagesHrefs$()[0]),
|
|
199
|
+
tabindex: tansu.computed(() => previousDisabled$() ? "-1" : void 0),
|
|
200
|
+
"aria-disabled": tansu.computed(() => previousDisabled$() ? "true" : void 0)
|
|
201
|
+
},
|
|
202
|
+
classNames: {
|
|
203
|
+
"au-first": utils_stores.true$
|
|
204
|
+
}
|
|
205
|
+
})),
|
|
206
|
+
pagePrev: utils_directive.createAttributesDirective(() => ({
|
|
207
|
+
events: {
|
|
208
|
+
click: (e) => handleNavigation(page$() - 1, e)
|
|
209
|
+
},
|
|
210
|
+
attributes: {
|
|
211
|
+
"aria-label": ariaPreviousLabel$,
|
|
212
|
+
href: tansu.computed(() => directionsHrefs$().previous),
|
|
213
|
+
tabindex: tansu.computed(() => previousDisabled$() ? "-1" : void 0),
|
|
214
|
+
"aria-disabled": tansu.computed(() => previousDisabled$() ? "true" : void 0)
|
|
215
|
+
},
|
|
216
|
+
classNames: {
|
|
217
|
+
"au-previous": utils_stores.true$
|
|
218
|
+
}
|
|
219
|
+
})),
|
|
220
|
+
pageNext: utils_directive.createAttributesDirective(() => ({
|
|
221
|
+
events: {
|
|
222
|
+
click: (e) => handleNavigation(page$() + 1, e)
|
|
223
|
+
},
|
|
224
|
+
attributes: {
|
|
225
|
+
"aria-label": ariaNextLabel$,
|
|
226
|
+
href: tansu.computed(() => directionsHrefs$().next),
|
|
227
|
+
tabindex: tansu.computed(() => nextDisabled$() ? "-1" : void 0),
|
|
228
|
+
"aria-disabled": tansu.computed(() => nextDisabled$() ? "true" : void 0)
|
|
229
|
+
},
|
|
230
|
+
classNames: {
|
|
231
|
+
"au-next": utils_stores.true$
|
|
232
|
+
}
|
|
233
|
+
})),
|
|
234
|
+
pageLast: utils_directive.createAttributesDirective(() => ({
|
|
235
|
+
events: {
|
|
236
|
+
click: (e) => handleNavigation(pageCount$(), e)
|
|
237
|
+
},
|
|
238
|
+
attributes: {
|
|
239
|
+
"aria-label": ariaLastLabel$,
|
|
240
|
+
href: tansu.computed(() => pagesHrefs$().at(-1)),
|
|
241
|
+
tabindex: tansu.computed(() => nextDisabled$() ? "-1" : void 0),
|
|
242
|
+
"aria-disabled": tansu.computed(() => nextDisabled$() ? "true" : void 0)
|
|
243
|
+
},
|
|
244
|
+
classNames: {
|
|
245
|
+
"au-last": utils_stores.true$
|
|
246
|
+
}
|
|
247
|
+
}))
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
return widget;
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
exports.createPagination = createPagination;
|
|
254
|
+
exports.getPaginationDefaultConfig = getPaginationDefaultConfig;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const utils_writables = require("./writables-Dt68gADJ.cjs");
|
|
3
|
+
const utils_stores = require("./utils/stores.cjs");
|
|
4
|
+
const tansu = require("@amadeus-it-group/tansu");
|
|
5
|
+
const utils_directive = require("./directive-DCaXmRe_.cjs");
|
|
6
|
+
const utils_widget = require("./utils/widget.cjs");
|
|
7
|
+
const defaultConfig = {
|
|
8
|
+
min: 0,
|
|
9
|
+
max: 100,
|
|
10
|
+
value: 0,
|
|
11
|
+
ariaLabel: "Progressbar",
|
|
12
|
+
className: "",
|
|
13
|
+
ariaValueTextFn: () => void 0
|
|
14
|
+
};
|
|
15
|
+
function getProgressbarDefaultConfig() {
|
|
16
|
+
return { ...defaultConfig };
|
|
17
|
+
}
|
|
18
|
+
const configValidator = {
|
|
19
|
+
min: utils_writables.typeNumber,
|
|
20
|
+
max: utils_writables.typeNumber,
|
|
21
|
+
value: utils_writables.typeNumber,
|
|
22
|
+
ariaLabel: utils_writables.typeString,
|
|
23
|
+
className: utils_writables.typeString,
|
|
24
|
+
ariaValueTextFn: utils_writables.typeFunction
|
|
25
|
+
};
|
|
26
|
+
const createProgressbar = utils_widget.createWidgetFactory(
|
|
27
|
+
"progressbar",
|
|
28
|
+
(config) => {
|
|
29
|
+
const [
|
|
30
|
+
{
|
|
31
|
+
// dirty inputs that need adjustment:
|
|
32
|
+
max$: _dirtyMaximum$,
|
|
33
|
+
value$: _dirtyValue$,
|
|
34
|
+
// clean inputs
|
|
35
|
+
min$,
|
|
36
|
+
ariaValueTextFn$,
|
|
37
|
+
ariaLabel$,
|
|
38
|
+
...stateProps
|
|
39
|
+
},
|
|
40
|
+
patch
|
|
41
|
+
] = utils_stores.writablesForProps(defaultConfig, config, configValidator);
|
|
42
|
+
const max$ = tansu.computed(() => Math.max(min$(), _dirtyMaximum$()));
|
|
43
|
+
const value$ = tansu.computed(() => utils_writables.clamp(_dirtyValue$(), max$(), min$()));
|
|
44
|
+
const percentage$ = tansu.computed(() => {
|
|
45
|
+
const max = max$();
|
|
46
|
+
const min = min$();
|
|
47
|
+
if (max > min) {
|
|
48
|
+
return utils_writables.clamp((value$() - min) * 100 / (max - min), 100, 0);
|
|
49
|
+
} else {
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const started$ = tansu.computed(() => value$() > min$());
|
|
54
|
+
const finished$ = tansu.computed(() => value$() === max$());
|
|
55
|
+
const ariaValueText$ = tansu.computed(() => ariaValueTextFn$()(value$(), min$(), max$()));
|
|
56
|
+
return {
|
|
57
|
+
...utils_stores.stateStores({
|
|
58
|
+
min$,
|
|
59
|
+
max$,
|
|
60
|
+
value$,
|
|
61
|
+
percentage$,
|
|
62
|
+
started$,
|
|
63
|
+
finished$,
|
|
64
|
+
ariaValueText$,
|
|
65
|
+
ariaLabel$,
|
|
66
|
+
...stateProps
|
|
67
|
+
}),
|
|
68
|
+
patch,
|
|
69
|
+
api: {},
|
|
70
|
+
directives: {
|
|
71
|
+
ariaDirective: utils_directive.createAttributesDirective(() => ({
|
|
72
|
+
attributes: {
|
|
73
|
+
role: tansu.readable("progressbar"),
|
|
74
|
+
"aria-label": ariaLabel$,
|
|
75
|
+
"aria-valuenow": value$,
|
|
76
|
+
"aria-valuemin": min$,
|
|
77
|
+
"aria-valuemax": max$,
|
|
78
|
+
"aria-valuetext": ariaValueText$
|
|
79
|
+
}
|
|
80
|
+
}))
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
exports.createProgressbar = createProgressbar;
|
|
86
|
+
exports.getProgressbarDefaultConfig = getProgressbarDefaultConfig;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { e as typeFunction, j as typeString, g as typeNumber, l as clamp } from "./writables-DYGjj5T3.js";
|
|
2
|
+
import { writablesForProps, stateStores } from "./utils/stores.js";
|
|
3
|
+
import { computed, readable } from "@amadeus-it-group/tansu";
|
|
4
|
+
import { g as createAttributesDirective } from "./directive-Bsreu2z1.js";
|
|
5
|
+
import { createWidgetFactory } from "./utils/widget.js";
|
|
6
|
+
const defaultConfig = {
|
|
7
|
+
min: 0,
|
|
8
|
+
max: 100,
|
|
9
|
+
value: 0,
|
|
10
|
+
ariaLabel: "Progressbar",
|
|
11
|
+
className: "",
|
|
12
|
+
ariaValueTextFn: () => void 0
|
|
13
|
+
};
|
|
14
|
+
function getProgressbarDefaultConfig() {
|
|
15
|
+
return { ...defaultConfig };
|
|
16
|
+
}
|
|
17
|
+
const configValidator = {
|
|
18
|
+
min: typeNumber,
|
|
19
|
+
max: typeNumber,
|
|
20
|
+
value: typeNumber,
|
|
21
|
+
ariaLabel: typeString,
|
|
22
|
+
className: typeString,
|
|
23
|
+
ariaValueTextFn: typeFunction
|
|
24
|
+
};
|
|
25
|
+
const createProgressbar = createWidgetFactory(
|
|
26
|
+
"progressbar",
|
|
27
|
+
(config) => {
|
|
28
|
+
const [
|
|
29
|
+
{
|
|
30
|
+
// dirty inputs that need adjustment:
|
|
31
|
+
max$: _dirtyMaximum$,
|
|
32
|
+
value$: _dirtyValue$,
|
|
33
|
+
// clean inputs
|
|
34
|
+
min$,
|
|
35
|
+
ariaValueTextFn$,
|
|
36
|
+
ariaLabel$,
|
|
37
|
+
...stateProps
|
|
38
|
+
},
|
|
39
|
+
patch
|
|
40
|
+
] = writablesForProps(defaultConfig, config, configValidator);
|
|
41
|
+
const max$ = computed(() => Math.max(min$(), _dirtyMaximum$()));
|
|
42
|
+
const value$ = computed(() => clamp(_dirtyValue$(), max$(), min$()));
|
|
43
|
+
const percentage$ = computed(() => {
|
|
44
|
+
const max = max$();
|
|
45
|
+
const min = min$();
|
|
46
|
+
if (max > min) {
|
|
47
|
+
return clamp((value$() - min) * 100 / (max - min), 100, 0);
|
|
48
|
+
} else {
|
|
49
|
+
return 0;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const started$ = computed(() => value$() > min$());
|
|
53
|
+
const finished$ = computed(() => value$() === max$());
|
|
54
|
+
const ariaValueText$ = computed(() => ariaValueTextFn$()(value$(), min$(), max$()));
|
|
55
|
+
return {
|
|
56
|
+
...stateStores({
|
|
57
|
+
min$,
|
|
58
|
+
max$,
|
|
59
|
+
value$,
|
|
60
|
+
percentage$,
|
|
61
|
+
started$,
|
|
62
|
+
finished$,
|
|
63
|
+
ariaValueText$,
|
|
64
|
+
ariaLabel$,
|
|
65
|
+
...stateProps
|
|
66
|
+
}),
|
|
67
|
+
patch,
|
|
68
|
+
api: {},
|
|
69
|
+
directives: {
|
|
70
|
+
ariaDirective: createAttributesDirective(() => ({
|
|
71
|
+
attributes: {
|
|
72
|
+
role: readable("progressbar"),
|
|
73
|
+
"aria-label": ariaLabel$,
|
|
74
|
+
"aria-valuenow": value$,
|
|
75
|
+
"aria-valuemin": min$,
|
|
76
|
+
"aria-valuemax": max$,
|
|
77
|
+
"aria-valuetext": ariaValueText$
|
|
78
|
+
}
|
|
79
|
+
}))
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
export {
|
|
85
|
+
createProgressbar as c,
|
|
86
|
+
getProgressbarDefaultConfig as g
|
|
87
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const tansu = require("@amadeus-it-group/tansu");
|
|
3
|
+
const utils_func = require("./utils/func.cjs");
|
|
4
|
+
const promisePending = { status: "pending" };
|
|
5
|
+
const isThenable = (value) => {
|
|
6
|
+
const type = typeof value;
|
|
7
|
+
return type === "object" && value !== null || type === "function" ? typeof value.then === "function" : false;
|
|
8
|
+
};
|
|
9
|
+
const createPromiseStateStore = (promise) => {
|
|
10
|
+
const store = tansu.writable(promisePending);
|
|
11
|
+
Promise.resolve(promise).then(
|
|
12
|
+
(value) => store.set({ status: "fulfilled", value }),
|
|
13
|
+
(reason) => store.set({ status: "rejected", reason })
|
|
14
|
+
);
|
|
15
|
+
return tansu.asReadable(store);
|
|
16
|
+
};
|
|
17
|
+
const promiseWeakMap = /* @__PURE__ */ new WeakMap();
|
|
18
|
+
const promiseStateStore = (value) => {
|
|
19
|
+
if (!isThenable(value)) {
|
|
20
|
+
return tansu.readable({ status: "fulfilled", value });
|
|
21
|
+
}
|
|
22
|
+
let response = promiseWeakMap.get(value);
|
|
23
|
+
if (!response) {
|
|
24
|
+
response = createPromiseStateStore(value);
|
|
25
|
+
promiseWeakMap.set(value, response);
|
|
26
|
+
}
|
|
27
|
+
return response;
|
|
28
|
+
};
|
|
29
|
+
const promiseStateStoreEqual = (a, b) => Object.is(a, b) || a.status === b.status && (a.status !== "fulfilled" || tansu.equal(a.value, b.value)) && (a.status !== "rejected" || tansu.equal(a.reason, b.reason));
|
|
30
|
+
const promiseStoreToPromiseStateStore = (promiseStore$) => tansu.computed(() => promiseStateStore(promiseStore$())(), { equal: promiseStateStoreEqual });
|
|
31
|
+
const promiseStateStoreToValueStore = (store$, initialValue, equal2) => tansu.derived(
|
|
32
|
+
store$,
|
|
33
|
+
{
|
|
34
|
+
derive: (state, set) => {
|
|
35
|
+
if (state.status === "fulfilled") {
|
|
36
|
+
set(state.value);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
equal: equal2
|
|
40
|
+
},
|
|
41
|
+
initialValue
|
|
42
|
+
);
|
|
43
|
+
const promiseStoreToValueStore = (promiseStore$, initialValue, equal2) => promiseStateStoreToValueStore(promiseStoreToPromiseStateStore(promiseStore$), initialValue, equal2);
|
|
44
|
+
const truthyValue = (value) => !!value;
|
|
45
|
+
const promiseFromStore = (store, condition = truthyValue) => {
|
|
46
|
+
let resolve;
|
|
47
|
+
const promise = new Promise((r) => resolve = r);
|
|
48
|
+
let unsubscribe = () => {
|
|
49
|
+
storeUnsubscribe();
|
|
50
|
+
unsubscribe = utils_func.noop;
|
|
51
|
+
};
|
|
52
|
+
let storeUnsubscribe = utils_func.noop;
|
|
53
|
+
storeUnsubscribe = store.subscribe((value) => {
|
|
54
|
+
if (condition(value)) {
|
|
55
|
+
resolve(value);
|
|
56
|
+
unsubscribe();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
if (unsubscribe === utils_func.noop) {
|
|
60
|
+
storeUnsubscribe();
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
promise,
|
|
64
|
+
unsubscribe() {
|
|
65
|
+
unsubscribe();
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
const promiseFromEvent = (element, event) => {
|
|
70
|
+
let resolve;
|
|
71
|
+
const promise = new Promise((r) => resolve = r);
|
|
72
|
+
let unsubscribe = () => {
|
|
73
|
+
element.removeEventListener(event, eventListener);
|
|
74
|
+
unsubscribe = utils_func.noop;
|
|
75
|
+
};
|
|
76
|
+
const eventListener = (event2) => {
|
|
77
|
+
if (event2.target === element) {
|
|
78
|
+
resolve(event2);
|
|
79
|
+
unsubscribe();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
element.addEventListener(event, eventListener);
|
|
83
|
+
return {
|
|
84
|
+
promise,
|
|
85
|
+
unsubscribe() {
|
|
86
|
+
unsubscribe();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
const promiseFromTimeout = (delay) => {
|
|
91
|
+
let timeout;
|
|
92
|
+
return {
|
|
93
|
+
promise: new Promise((r) => {
|
|
94
|
+
timeout = setTimeout(() => {
|
|
95
|
+
timeout = void 0;
|
|
96
|
+
r();
|
|
97
|
+
}, delay);
|
|
98
|
+
}),
|
|
99
|
+
unsubscribe() {
|
|
100
|
+
if (timeout) {
|
|
101
|
+
clearTimeout(timeout);
|
|
102
|
+
timeout = void 0;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
const promiseWithResolve = () => {
|
|
108
|
+
let resolve;
|
|
109
|
+
const promise = new Promise((r) => {
|
|
110
|
+
resolve = r;
|
|
111
|
+
});
|
|
112
|
+
return { promise, resolve };
|
|
113
|
+
};
|
|
114
|
+
exports.promiseFromEvent = promiseFromEvent;
|
|
115
|
+
exports.promiseFromStore = promiseFromStore;
|
|
116
|
+
exports.promiseFromTimeout = promiseFromTimeout;
|
|
117
|
+
exports.promiseStoreToValueStore = promiseStoreToValueStore;
|
|
118
|
+
exports.promiseWithResolve = promiseWithResolve;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { derived, computed, readable, equal, writable, asReadable } from "@amadeus-it-group/tansu";
|
|
2
|
+
import { noop } from "./utils/func.js";
|
|
3
|
+
const promisePending = { status: "pending" };
|
|
4
|
+
const isThenable = (value) => {
|
|
5
|
+
const type = typeof value;
|
|
6
|
+
return type === "object" && value !== null || type === "function" ? typeof value.then === "function" : false;
|
|
7
|
+
};
|
|
8
|
+
const createPromiseStateStore = (promise) => {
|
|
9
|
+
const store = writable(promisePending);
|
|
10
|
+
Promise.resolve(promise).then(
|
|
11
|
+
(value) => store.set({ status: "fulfilled", value }),
|
|
12
|
+
(reason) => store.set({ status: "rejected", reason })
|
|
13
|
+
);
|
|
14
|
+
return asReadable(store);
|
|
15
|
+
};
|
|
16
|
+
const promiseWeakMap = /* @__PURE__ */ new WeakMap();
|
|
17
|
+
const promiseStateStore = (value) => {
|
|
18
|
+
if (!isThenable(value)) {
|
|
19
|
+
return readable({ status: "fulfilled", value });
|
|
20
|
+
}
|
|
21
|
+
let response = promiseWeakMap.get(value);
|
|
22
|
+
if (!response) {
|
|
23
|
+
response = createPromiseStateStore(value);
|
|
24
|
+
promiseWeakMap.set(value, response);
|
|
25
|
+
}
|
|
26
|
+
return response;
|
|
27
|
+
};
|
|
28
|
+
const promiseStateStoreEqual = (a, b) => Object.is(a, b) || a.status === b.status && (a.status !== "fulfilled" || equal(a.value, b.value)) && (a.status !== "rejected" || equal(a.reason, b.reason));
|
|
29
|
+
const promiseStoreToPromiseStateStore = (promiseStore$) => computed(() => promiseStateStore(promiseStore$())(), { equal: promiseStateStoreEqual });
|
|
30
|
+
const promiseStateStoreToValueStore = (store$, initialValue, equal2) => derived(
|
|
31
|
+
store$,
|
|
32
|
+
{
|
|
33
|
+
derive: (state, set) => {
|
|
34
|
+
if (state.status === "fulfilled") {
|
|
35
|
+
set(state.value);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
equal: equal2
|
|
39
|
+
},
|
|
40
|
+
initialValue
|
|
41
|
+
);
|
|
42
|
+
const promiseStoreToValueStore = (promiseStore$, initialValue, equal2) => promiseStateStoreToValueStore(promiseStoreToPromiseStateStore(promiseStore$), initialValue, equal2);
|
|
43
|
+
const truthyValue = (value) => !!value;
|
|
44
|
+
const promiseFromStore = (store, condition = truthyValue) => {
|
|
45
|
+
let resolve;
|
|
46
|
+
const promise = new Promise((r) => resolve = r);
|
|
47
|
+
let unsubscribe = () => {
|
|
48
|
+
storeUnsubscribe();
|
|
49
|
+
unsubscribe = noop;
|
|
50
|
+
};
|
|
51
|
+
let storeUnsubscribe = noop;
|
|
52
|
+
storeUnsubscribe = store.subscribe((value) => {
|
|
53
|
+
if (condition(value)) {
|
|
54
|
+
resolve(value);
|
|
55
|
+
unsubscribe();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
if (unsubscribe === noop) {
|
|
59
|
+
storeUnsubscribe();
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
promise,
|
|
63
|
+
unsubscribe() {
|
|
64
|
+
unsubscribe();
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
const promiseFromEvent = (element, event) => {
|
|
69
|
+
let resolve;
|
|
70
|
+
const promise = new Promise((r) => resolve = r);
|
|
71
|
+
let unsubscribe = () => {
|
|
72
|
+
element.removeEventListener(event, eventListener);
|
|
73
|
+
unsubscribe = noop;
|
|
74
|
+
};
|
|
75
|
+
const eventListener = (event2) => {
|
|
76
|
+
if (event2.target === element) {
|
|
77
|
+
resolve(event2);
|
|
78
|
+
unsubscribe();
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
element.addEventListener(event, eventListener);
|
|
82
|
+
return {
|
|
83
|
+
promise,
|
|
84
|
+
unsubscribe() {
|
|
85
|
+
unsubscribe();
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
const promiseFromTimeout = (delay) => {
|
|
90
|
+
let timeout;
|
|
91
|
+
return {
|
|
92
|
+
promise: new Promise((r) => {
|
|
93
|
+
timeout = setTimeout(() => {
|
|
94
|
+
timeout = void 0;
|
|
95
|
+
r();
|
|
96
|
+
}, delay);
|
|
97
|
+
}),
|
|
98
|
+
unsubscribe() {
|
|
99
|
+
if (timeout) {
|
|
100
|
+
clearTimeout(timeout);
|
|
101
|
+
timeout = void 0;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
const promiseWithResolve = () => {
|
|
107
|
+
let resolve;
|
|
108
|
+
const promise = new Promise((r) => {
|
|
109
|
+
resolve = r;
|
|
110
|
+
});
|
|
111
|
+
return { promise, resolve };
|
|
112
|
+
};
|
|
113
|
+
export {
|
|
114
|
+
promiseStoreToValueStore as a,
|
|
115
|
+
promiseFromEvent as b,
|
|
116
|
+
promiseFromTimeout as c,
|
|
117
|
+
promiseWithResolve as d,
|
|
118
|
+
promiseFromStore as p
|
|
119
|
+
};
|