@supersoniks/concorde 2.0.7 → 3.0.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.
- package/build-infos.json +1 -0
- package/concorde-core.bundle.js +387 -344
- package/concorde-core.es.js +8040 -11093
- package/index.html +44 -0
- package/notes de migration.md +21 -0
- package/package.json +23 -290
- package/scripts/postbuild.mjs +22 -0
- package/scripts/prebuild.mjs +22 -0
- package/{components.js → src/components.ts} +5 -2
- package/src/concorde-loaded.ts +3 -0
- package/src/core/_types/types.ts +55 -0
- package/src/core/components/functional/date/date.md +290 -0
- package/src/core/components/functional/date/date.ts +206 -0
- package/src/core/components/functional/example/example.ts +11 -0
- package/src/core/components/functional/fetch/fetch.md +117 -0
- package/{core/components/functional/fetch/fetch.js → src/core/components/functional/fetch/fetch.ts} +33 -37
- package/src/core/components/functional/if/if.md +16 -0
- package/src/core/components/functional/if/if.test.ts +40 -0
- package/src/core/components/functional/if/if.ts +23 -0
- package/src/core/components/functional/list/list.md +194 -0
- package/src/core/components/functional/list/list.ts +236 -0
- package/src/core/components/functional/mix/mix.md +41 -0
- package/src/core/components/functional/mix/mix.ts +95 -0
- package/src/core/components/functional/queue/queue.md +87 -0
- package/src/core/components/functional/queue/queue.ts +279 -0
- package/src/core/components/functional/router/redirect.ts +44 -0
- package/src/core/components/functional/router/router.md +112 -0
- package/src/core/components/functional/router/router.ts +108 -0
- package/src/core/components/functional/sdui/SDUIDescriptorTransformer.ts +229 -0
- package/{core → src/core}/components/functional/sdui/default-library.json +13 -13
- package/src/core/components/functional/sdui/example.json +99 -0
- package/src/core/components/functional/sdui/sdui-utils.ts +62 -0
- package/src/core/components/functional/sdui/sdui.md +356 -0
- package/src/core/components/functional/sdui/sdui.ts +230 -0
- package/src/core/components/functional/sdui/types.ts +34 -0
- package/src/core/components/functional/sonic-scope/sonic-scope.ts +13 -0
- package/src/core/components/functional/states/states.md +87 -0
- package/src/core/components/functional/states/states.ts +121 -0
- package/src/core/components/functional/submit/submit.md +48 -0
- package/src/core/components/functional/submit/submit.ts +265 -0
- package/src/core/components/functional/subscriber/subscriber.md +91 -0
- package/src/core/components/functional/subscriber/subscriber.ts +28 -0
- package/src/core/components/functional/value/value.md +35 -0
- package/src/core/components/functional/value/value.ts +18 -0
- package/{core/components/ui/_css/scroll.js → src/core/components/ui/_css/scroll.ts} +3 -2
- package/{core/components/ui/_css/size.js → src/core/components/ui/_css/size.ts} +5 -2
- package/{core/components/ui/_css/type.js → src/core/components/ui/_css/type.ts} +5 -3
- package/src/core/components/ui/alert/alert.md +121 -0
- package/src/core/components/ui/alert/alert.ts +177 -0
- package/src/core/components/ui/badge/badge.md +102 -0
- package/{core/components/ui/badge/badge.js → src/core/components/ui/badge/badge.ts} +36 -51
- package/src/core/components/ui/button/button.md +184 -0
- package/{core/components/ui/button/button.js → src/core/components/ui/button/button.ts} +258 -302
- package/src/core/components/ui/captcha/captcha.md +12 -0
- package/src/core/components/ui/captcha/captcha.ts +88 -0
- package/src/core/components/ui/card/card-footer.ts +19 -0
- package/src/core/components/ui/card/card-header-descripton.ts +24 -0
- package/{core/components/ui/card/card-header.js → src/core/components/ui/card/card-header.ts} +28 -38
- package/src/core/components/ui/card/card-main.ts +24 -0
- package/src/core/components/ui/card/card.md +96 -0
- package/{core/components/ui/card/card.js → src/core/components/ui/card/card.ts} +23 -34
- package/src/core/components/ui/divider/divider.md +35 -0
- package/{core/components/ui/divider/divider.js → src/core/components/ui/divider/divider.ts} +35 -65
- package/src/core/components/ui/form/checkbox/checkbox.md +96 -0
- package/{core/components/ui/form/checkbox/checkbox.js → src/core/components/ui/form/checkbox/checkbox.ts} +79 -98
- package/{core/components/ui/form/css/form-control.js → src/core/components/ui/form/css/form-control.ts} +9 -5
- package/src/core/components/ui/form/fieldset/fieldset.md +129 -0
- package/src/core/components/ui/form/fieldset/fieldset.ts +96 -0
- package/src/core/components/ui/form/fieldset/legend-description.ts +23 -0
- package/src/core/components/ui/form/fieldset/legend.ts +90 -0
- package/src/core/components/ui/form/form-actions/form-actions.md +77 -0
- package/src/core/components/ui/form/form-actions/form-actions.ts +32 -0
- package/src/core/components/ui/form/form-layout/form-layout.md +43 -0
- package/src/core/components/ui/form/form-layout/form-layout.ts +71 -0
- package/src/core/components/ui/form/input/input.md +168 -0
- package/src/core/components/ui/form/input/input.ts +227 -0
- package/src/core/components/ui/form/input/password-helper.ts +68 -0
- package/src/core/components/ui/form/input/same-value-helper.ts +48 -0
- package/src/core/components/ui/form/input-autocomplete/input-autocomplete.md +130 -0
- package/src/core/components/ui/form/input-autocomplete/input-autocomplete.ts +285 -0
- package/src/core/components/ui/form/radio/radio.md +86 -0
- package/src/core/components/ui/form/radio/radio.ts +44 -0
- package/src/core/components/ui/form/select/select.md +99 -0
- package/src/core/components/ui/form/select/select.ts +310 -0
- package/src/core/components/ui/form/textarea/textarea.md +66 -0
- package/src/core/components/ui/form/textarea/textarea.ts +119 -0
- package/src/core/components/ui/group/group.md +75 -0
- package/src/core/components/ui/group/group.ts +101 -0
- package/src/core/components/ui/icon/icon.md +125 -0
- package/src/core/components/ui/icon/icon.stories.ts +100 -0
- package/src/core/components/ui/icon/icon.ts +106 -0
- package/src/core/components/ui/icon/icons.json +1 -0
- package/src/core/components/ui/icon/icons.ts +130 -0
- package/src/core/components/ui/icon/svgs/cancel.svg +3 -0
- package/src/core/components/ui/icon/svgs/check-circled-outline.svg +4 -0
- package/src/core/components/ui/icon/svgs/check.svg +3 -0
- package/src/core/components/ui/icon/svgs/emoji-puzzled.svg +1 -0
- package/src/core/components/ui/icon/svgs/info-empty.svg +5 -0
- package/src/core/components/ui/icon/svgs/loader.svg +1 -0
- package/src/core/components/ui/icon/svgs/minus-small.svg +3 -0
- package/src/core/components/ui/icon/svgs/more-horiz.svg +5 -0
- package/src/core/components/ui/icon/svgs/more-vert.svg +5 -0
- package/src/core/components/ui/icon/svgs/nav-arrow-down.svg +3 -0
- package/src/core/components/ui/icon/svgs/warning-circled-outline.svg +5 -0
- package/src/core/components/ui/image/image.md +107 -0
- package/src/core/components/ui/image/image.ts +117 -0
- package/src/core/components/ui/link/link.md +43 -0
- package/src/core/components/ui/link/link.ts +108 -0
- package/src/core/components/ui/loader/loader.md +37 -0
- package/src/core/components/ui/loader/loader.stories.ts +25 -0
- package/src/core/components/ui/loader/loader.ts +81 -0
- package/{core/components/ui/loader/styles/fixed.js → src/core/components/ui/loader/styles/fixed.ts} +2 -1
- package/{core/components/ui/loader/styles/inline.js → src/core/components/ui/loader/styles/inline.ts} +3 -2
- package/src/core/components/ui/menu/menu-item.ts +30 -0
- package/src/core/components/ui/menu/menu.md +288 -0
- package/src/core/components/ui/menu/menu.ts +292 -0
- package/src/core/components/ui/modal/modal-actions.ts +35 -0
- package/src/core/components/ui/modal/modal-close.ts +36 -0
- package/src/core/components/ui/modal/modal-content.ts +19 -0
- package/src/core/components/ui/modal/modal-subtitle.ts +23 -0
- package/src/core/components/ui/modal/modal-title.ts +22 -0
- package/src/core/components/ui/modal/modal.md +123 -0
- package/src/core/components/ui/modal/modal.stories.ts +140 -0
- package/src/core/components/ui/modal/modal.ts +386 -0
- package/src/core/components/ui/pop/pop.md +79 -0
- package/src/core/components/ui/pop/pop.ts +291 -0
- package/src/core/components/ui/progress/progress.md +65 -0
- package/{core/components/ui/progress/progress.js → src/core/components/ui/progress/progress.ts} +31 -50
- package/src/core/components/ui/table/table-caption.ts +21 -0
- package/src/core/components/ui/table/table-tbody.ts +32 -0
- package/src/core/components/ui/table/table-td.ts +47 -0
- package/src/core/components/ui/table/table-tfoot.ts +20 -0
- package/src/core/components/ui/table/table-th.ts +56 -0
- package/src/core/components/ui/table/table-thead.ts +18 -0
- package/src/core/components/ui/table/table-tr.ts +48 -0
- package/src/core/components/ui/table/table.md +467 -0
- package/{core/components/ui/table/table.js → src/core/components/ui/table/table.ts} +32 -53
- package/{core/components/ui/theme/theme-collection/core-variables.js → src/core/components/ui/theme/theme-collection/core-variables.ts} +3 -2
- package/{core/components/ui/theme/theme-collection/dark.js → src/core/components/ui/theme/theme-collection/dark.ts} +5 -3
- package/{core/components/ui/theme/theme-collection/light.js → src/core/components/ui/theme/theme-collection/light.ts} +3 -2
- package/src/core/components/ui/theme/theme.ts +118 -0
- package/src/core/components/ui/toast/message-subscriber.stories.ts +43 -0
- package/src/core/components/ui/toast/message-subscriber.ts +37 -0
- package/{core/components/ui/toast/toast-item.js → src/core/components/ui/toast/toast-item.ts} +86 -113
- package/src/core/components/ui/toast/toast.ts +237 -0
- package/src/core/components/ui/toast/types.ts +14 -0
- package/src/core/components/ui/tooltip/tooltip.md +37 -0
- package/{core/components/ui/tooltip/tooltip.js → src/core/components/ui/tooltip/tooltip.ts} +26 -47
- package/{core/components/ui/ui.js → src/core/components/ui/ui.ts} +2 -0
- package/src/core/core.ts +22 -0
- package/src/core/decorators/Subscriber.ts +187 -0
- package/src/core/directives/DataProvider.ts +113 -0
- package/src/core/directives/Wording.ts +220 -0
- package/src/core/mixins/Fetcher.ts +258 -0
- package/src/core/mixins/FormCheckable.ts +287 -0
- package/src/core/mixins/FormElement.ts +275 -0
- package/src/core/mixins/FormInput.ts +135 -0
- package/src/core/mixins/Subscriber.ts +352 -0
- package/src/core/mixins/TemplatesContainer.ts +70 -0
- package/{core/mixins/mixins.d.ts → src/core/mixins/mixins.ts} +1 -1
- package/src/core/utils/Arrays.ts +161 -0
- package/src/core/utils/DataBindObserver.ts +286 -0
- package/src/core/utils/Electron.ts +15 -0
- package/src/core/utils/Format.ts +58 -0
- package/src/core/utils/HTML.ts +126 -0
- package/src/core/utils/LocationHandler.ts +139 -0
- package/src/core/utils/Objects.ts +103 -0
- package/src/core/utils/PublisherProxy.ts +786 -0
- package/src/core/utils/Utils.ts +12 -0
- package/src/core/utils/api.ts +456 -0
- package/{core/utils/url-pattern.d.ts → src/core/utils/url-pattern.ts} +1 -0
- package/{decorators.js → src/decorators.ts} +6 -2
- package/{directives.js → src/directives.ts} +11 -6
- package/src/docs/_core-concept/overview.md +57 -0
- package/src/docs/_core-concept/subscriber.md +76 -0
- package/src/docs/_getting-started/concorde-outside.md +141 -0
- package/src/docs/_getting-started/create-a-component.md +137 -0
- package/src/docs/_getting-started/pubsub.md +150 -0
- package/src/docs/_getting-started/start.md +37 -0
- package/src/docs/_getting-started/theming.md +91 -0
- package/src/docs/code.ts +281 -0
- package/src/docs/docs.ts +6 -0
- package/src/docs/example/users.ts +64 -0
- package/src/docs/navigation/navigation.ts +101 -0
- package/src/docs/prism/index.ts +6 -0
- package/src/docs/prism/prism.css +158 -0
- package/src/docs/prism/prism.js +1022 -0
- package/src/docs/search/docs-search.json +3767 -0
- package/src/docs/search/markdown-renderer.ts +40 -0
- package/src/docs/search/page.ts +40 -0
- package/src/docs/search/search.ts +184 -0
- package/src/docs.ts +2 -0
- package/src/index.ts +7 -0
- package/{mixins.js → src/mixins.ts} +10 -6
- package/src/tag-list.json +1 -0
- package/src/test-utils/TestUtils.ts +13 -0
- package/src/tsconfig.json +113 -0
- package/{utils.js → src/utils.ts} +15 -11
- package/test-utils/TestUtils.ts +13 -0
- package/vite/config.js +136 -0
- package/vite.config.mts +87 -0
- package/README.md +0 -27
- package/cli.js +0 -75
- package/components.d.ts +0 -4
- package/core/_types/types.d.ts +0 -28
- package/core/_types/types.js +0 -2
- package/core/components/functional/date/date.d.ts +0 -45
- package/core/components/functional/date/date.js +0 -243
- package/core/components/functional/example/example.d.ts +0 -7
- package/core/components/functional/example/example.js +0 -26
- package/core/components/functional/fetch/fetch.d.ts +0 -93
- package/core/components/functional/functional.js +0 -15
- package/core/components/functional/if/if.d.ts +0 -12
- package/core/components/functional/if/if.js +0 -38
- package/core/components/functional/if/if.test.d.ts +0 -1
- package/core/components/functional/if/if.test.js +0 -35
- package/core/components/functional/list/list.d.ts +0 -117
- package/core/components/functional/list/list.js +0 -214
- package/core/components/functional/mix/mix.d.ts +0 -22
- package/core/components/functional/mix/mix.js +0 -102
- package/core/components/functional/queue/queue.d.ts +0 -67
- package/core/components/functional/queue/queue.js +0 -310
- package/core/components/functional/router/redirect.d.ts +0 -18
- package/core/components/functional/router/redirect.js +0 -53
- package/core/components/functional/router/router.d.ts +0 -27
- package/core/components/functional/router/router.js +0 -119
- package/core/components/functional/sdui/SDUIDescriptorTransformer.d.ts +0 -58
- package/core/components/functional/sdui/SDUIDescriptorTransformer.js +0 -215
- package/core/components/functional/sdui/sdui-utils.d.ts +0 -5
- package/core/components/functional/sdui/sdui-utils.js +0 -63
- package/core/components/functional/sdui/sdui.d.ts +0 -136
- package/core/components/functional/sdui/sdui.js +0 -254
- package/core/components/functional/sdui/types.d.ts +0 -37
- package/core/components/functional/sdui/types.js +0 -1
- package/core/components/functional/sonic-scope/sonic-scope.d.ts +0 -5
- package/core/components/functional/sonic-scope/sonic-scope.js +0 -21
- package/core/components/functional/states/states.d.ts +0 -29
- package/core/components/functional/states/states.js +0 -134
- package/core/components/functional/submit/submit.d.ts +0 -30
- package/core/components/functional/submit/submit.js +0 -236
- package/core/components/functional/subscriber/subscriber.d.ts +0 -12
- package/core/components/functional/subscriber/subscriber.js +0 -38
- package/core/components/functional/value/value.d.ts +0 -7
- package/core/components/functional/value/value.js +0 -27
- package/core/components/ui/_css/scroll.d.ts +0 -1
- package/core/components/ui/_css/size.d.ts +0 -2
- package/core/components/ui/_css/type.d.ts +0 -2
- package/core/components/ui/alert/alert.d.ts +0 -34
- package/core/components/ui/alert/alert.js +0 -202
- package/core/components/ui/badge/badge.d.ts +0 -26
- package/core/components/ui/button/button.d.ts +0 -171
- package/core/components/ui/captcha/captcha.d.ts +0 -30
- package/core/components/ui/captcha/captcha.js +0 -93
- package/core/components/ui/card/card-footer.d.ts +0 -4
- package/core/components/ui/card/card-footer.js +0 -24
- package/core/components/ui/card/card-header-descripton.d.ts +0 -5
- package/core/components/ui/card/card-header-descripton.js +0 -32
- package/core/components/ui/card/card-header.d.ts +0 -8
- package/core/components/ui/card/card-main.d.ts +0 -4
- package/core/components/ui/card/card-main.js +0 -28
- package/core/components/ui/card/card.d.ts +0 -12
- package/core/components/ui/divider/divider.d.ts +0 -15
- package/core/components/ui/form/checkbox/checkbox.d.ts +0 -181
- package/core/components/ui/form/css/form-control.d.ts +0 -4
- package/core/components/ui/form/fieldset/fieldset.d.ts +0 -23
- package/core/components/ui/form/fieldset/fieldset.js +0 -118
- package/core/components/ui/form/fieldset/legend-description.d.ts +0 -5
- package/core/components/ui/form/fieldset/legend-description.js +0 -30
- package/core/components/ui/form/fieldset/legend.d.ts +0 -16
- package/core/components/ui/form/fieldset/legend.js +0 -112
- package/core/components/ui/form/form-actions/form-actions.d.ts +0 -7
- package/core/components/ui/form/form-actions/form-actions.js +0 -46
- package/core/components/ui/form/form-layout/form-layout.d.ts +0 -12
- package/core/components/ui/form/form-layout/form-layout.js +0 -83
- package/core/components/ui/form/input/input.d.ts +0 -106
- package/core/components/ui/form/input/input.js +0 -268
- package/core/components/ui/form/input/password-helper.d.ts +0 -25
- package/core/components/ui/form/input/password-helper.js +0 -119
- package/core/components/ui/form/input/same-value-helper.d.ts +0 -16
- package/core/components/ui/form/input/same-value-helper.js +0 -77
- package/core/components/ui/form/input-autocomplete/input-autocomplete.d.ts +0 -136
- package/core/components/ui/form/input-autocomplete/input-autocomplete.js +0 -296
- package/core/components/ui/form/radio/radio.d.ts +0 -12
- package/core/components/ui/form/radio/radio.js +0 -50
- package/core/components/ui/form/select/select.d.ts +0 -58
- package/core/components/ui/form/select/select.js +0 -298
- package/core/components/ui/form/textarea/textarea.d.ts +0 -84
- package/core/components/ui/form/textarea/textarea.js +0 -150
- package/core/components/ui/group/group.d.ts +0 -16
- package/core/components/ui/group/group.js +0 -118
- package/core/components/ui/icon/icon.d.ts +0 -26
- package/core/components/ui/icon/icon.js +0 -113
- package/core/components/ui/icon/icons.d.ts +0 -10
- package/core/components/ui/icon/icons.js +0 -126
- package/core/components/ui/icon/icons.json +0 -1
- package/core/components/ui/image/image.d.ts +0 -15
- package/core/components/ui/image/image.js +0 -153
- package/core/components/ui/link/link.d.ts +0 -29
- package/core/components/ui/link/link.js +0 -124
- package/core/components/ui/loader/loader.d.ts +0 -23
- package/core/components/ui/loader/loader.js +0 -97
- package/core/components/ui/loader/styles/fixed.d.ts +0 -1
- package/core/components/ui/loader/styles/inline.d.ts +0 -1
- package/core/components/ui/menu/menu-item.d.ts +0 -5
- package/core/components/ui/menu/menu-item.js +0 -34
- package/core/components/ui/menu/menu.d.ts +0 -41
- package/core/components/ui/menu/menu.js +0 -313
- package/core/components/ui/modal/modal-actions.d.ts +0 -7
- package/core/components/ui/modal/modal-actions.js +0 -42
- package/core/components/ui/modal/modal-close.d.ts +0 -7
- package/core/components/ui/modal/modal-close.js +0 -43
- package/core/components/ui/modal/modal-content.d.ts +0 -5
- package/core/components/ui/modal/modal-content.js +0 -26
- package/core/components/ui/modal/modal-subtitle.d.ts +0 -5
- package/core/components/ui/modal/modal-subtitle.js +0 -30
- package/core/components/ui/modal/modal-title.d.ts +0 -5
- package/core/components/ui/modal/modal-title.js +0 -29
- package/core/components/ui/modal/modal.d.ts +0 -58
- package/core/components/ui/modal/modal.js +0 -401
- package/core/components/ui/pop/pop.d.ts +0 -37
- package/core/components/ui/pop/pop.js +0 -299
- package/core/components/ui/progress/progress.d.ts +0 -10
- package/core/components/ui/table/table-caption.d.ts +0 -5
- package/core/components/ui/table/table-caption.js +0 -28
- package/core/components/ui/table/table-tbody.d.ts +0 -5
- package/core/components/ui/table/table-tbody.js +0 -39
- package/core/components/ui/table/table-td.d.ts +0 -12
- package/core/components/ui/table/table-td.js +0 -68
- package/core/components/ui/table/table-tfoot.d.ts +0 -5
- package/core/components/ui/table/table-tfoot.js +0 -27
- package/core/components/ui/table/table-th.d.ts +0 -11
- package/core/components/ui/table/table-th.js +0 -73
- package/core/components/ui/table/table-thead.d.ts +0 -5
- package/core/components/ui/table/table-thead.js +0 -25
- package/core/components/ui/table/table-tr.d.ts +0 -13
- package/core/components/ui/table/table-tr.js +0 -66
- package/core/components/ui/table/table.d.ts +0 -17
- package/core/components/ui/theme/theme-collection/core-variables.d.ts +0 -1
- package/core/components/ui/theme/theme-collection/dark.d.ts +0 -1
- package/core/components/ui/theme/theme-collection/light.d.ts +0 -1
- package/core/components/ui/theme/theme.d.ts +0 -19
- package/core/components/ui/theme/theme.js +0 -124
- package/core/components/ui/toast/message-subscriber.d.ts +0 -18
- package/core/components/ui/toast/message-subscriber.js +0 -40
- package/core/components/ui/toast/toast-item.d.ts +0 -19
- package/core/components/ui/toast/toast.d.ts +0 -25
- package/core/components/ui/toast/toast.js +0 -226
- package/core/components/ui/toast/types.d.ts +0 -11
- package/core/components/ui/toast/types.js +0 -1
- package/core/components/ui/tooltip/tooltip.d.ts +0 -10
- package/core/components/ui/ui.d.ts +0 -32
- package/core/core.d.ts +0 -4
- package/core/core.js +0 -19
- package/core/decorators/Subscriber.d.ts +0 -4
- package/core/decorators/Subscriber.js +0 -166
- package/core/directives/DataProvider.d.ts +0 -23
- package/core/directives/DataProvider.js +0 -102
- package/core/directives/Wording.d.ts +0 -42
- package/core/directives/Wording.js +0 -202
- package/core/mixins/Fetcher.d.ts +0 -90
- package/core/mixins/Fetcher.js +0 -242
- package/core/mixins/FormCheckable.d.ts +0 -88
- package/core/mixins/FormCheckable.js +0 -306
- package/core/mixins/FormElement.d.ts +0 -32
- package/core/mixins/FormElement.js +0 -272
- package/core/mixins/FormInput.d.ts +0 -70
- package/core/mixins/FormInput.js +0 -81
- package/core/mixins/Subscriber.d.ts +0 -36
- package/core/mixins/Subscriber.js +0 -333
- package/core/mixins/TemplatesContainer.d.ts +0 -13
- package/core/mixins/TemplatesContainer.js +0 -69
- package/core/mixins/mixins.js +0 -6
- package/core/utils/Arrays.d.ts +0 -97
- package/core/utils/Arrays.js +0 -140
- package/core/utils/DataBindObserver.d.ts +0 -83
- package/core/utils/DataBindObserver.js +0 -264
- package/core/utils/Electron.d.ts +0 -7
- package/core/utils/Electron.js +0 -11
- package/core/utils/Format.d.ts +0 -12
- package/core/utils/Format.js +0 -38
- package/core/utils/HTML.d.ts +0 -42
- package/core/utils/HTML.js +0 -119
- package/core/utils/LocationHandler.d.ts +0 -46
- package/core/utils/LocationHandler.js +0 -133
- package/core/utils/Objects.d.ts +0 -28
- package/core/utils/Objects.js +0 -102
- package/core/utils/PublisherProxy.d.ts +0 -176
- package/core/utils/PublisherProxy.js +0 -709
- package/core/utils/Utils.d.ts +0 -4
- package/core/utils/Utils.js +0 -12
- package/core/utils/api.d.ts +0 -139
- package/core/utils/api.js +0 -391
- package/core/utils/url-pattern.js +0 -2
- package/decorators.d.ts +0 -3
- package/directives.d.ts +0 -40
- package/img/concorde-logo.svg +0 -1
- package/img/concorde.png +0 -0
- package/img/concorde_def.png +0 -0
- package/mixins.d.ts +0 -181
- package/svg/regular/plane.svg +0 -1
- package/svg/solid/plane.svg +0 -1
- package/test-utils/TestUtils.d.ts +0 -4
- package/test-utils/TestUtils.js +0 -12
- package/utils.d.ts +0 -20
- /package/{core/components/functional/functional.d.ts → src/core/components/functional/functional.ts} +0 -0
- /package/{core → src/core}/components/ui/theme/css/tailwind.css +0 -0
- /package/{core → src/core}/components/ui/theme/css/tailwind.d.ts +0 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import {AsyncDirective, PartInfo} from "lit/async-directive.js";
|
|
2
|
+
import {directive} from "lit/directive.js";
|
|
3
|
+
import {PublisherManager, PublisherProxy} from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
4
|
+
import {noChange} from "lit";
|
|
5
|
+
import Objects from "../utils/Objects";
|
|
6
|
+
import {SearchableDomElement} from "../utils/HTML";
|
|
7
|
+
import Publisher from "../utils/PublisherProxy";
|
|
8
|
+
type Observable = PublisherProxy | string | (() => unknown);
|
|
9
|
+
function getObservables(observable: Observable): Set<PublisherProxy> {
|
|
10
|
+
if (typeof observable === "function") {
|
|
11
|
+
const func = observable as () => unknown;
|
|
12
|
+
PublisherManager.collectModifiedPublisher();
|
|
13
|
+
func();
|
|
14
|
+
return PublisherManager.getModifiedPublishers() || new Set();
|
|
15
|
+
}
|
|
16
|
+
if (typeof observable === "string") {
|
|
17
|
+
const split = observable.split(".");
|
|
18
|
+
const dataProvider: string = split.shift() || "";
|
|
19
|
+
let publisher = PublisherManager.get(dataProvider);
|
|
20
|
+
publisher = Objects.traverse(publisher, split);
|
|
21
|
+
const set = new Set<PublisherProxy>();
|
|
22
|
+
set.add(publisher);
|
|
23
|
+
return set;
|
|
24
|
+
}
|
|
25
|
+
return new Set<PublisherProxy>([observable as Publisher]);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
class ObserveDirective extends AsyncDirective {
|
|
29
|
+
observables: Set<PublisherProxy> = new Set();
|
|
30
|
+
unsubscribe(): void {
|
|
31
|
+
this.observables.forEach((publisher: PublisherProxy) => publisher.offAssign(this.onAssign));
|
|
32
|
+
}
|
|
33
|
+
observable?: Observable;
|
|
34
|
+
node?: SearchableDomElement;
|
|
35
|
+
|
|
36
|
+
/* eslint-disable @typescript-eslint/no-explicit-any*/
|
|
37
|
+
constructor(partInfo: any) {
|
|
38
|
+
super(partInfo as PartInfo);
|
|
39
|
+
this.node = partInfo.options?.host;
|
|
40
|
+
}
|
|
41
|
+
/* eslint-enable @typescript-eslint/no-explicit-any*/
|
|
42
|
+
|
|
43
|
+
render(observable: Observable) {
|
|
44
|
+
if (this.observable !== observable) {
|
|
45
|
+
this.observable = observable;
|
|
46
|
+
if (this.isConnected) {
|
|
47
|
+
this.subscribe(observable);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return noChange;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
onAssign = (v: unknown) => {
|
|
54
|
+
this.setValue(v);
|
|
55
|
+
};
|
|
56
|
+
// Subscribes to the observable, calling the directive's asynchronous
|
|
57
|
+
// setValue API each time the value changes
|
|
58
|
+
subscribe(observable: Observable) {
|
|
59
|
+
this.unsubscribe();
|
|
60
|
+
if (typeof observable === "function") {
|
|
61
|
+
this.onAssign = () => {
|
|
62
|
+
this.setValue(observable());
|
|
63
|
+
};
|
|
64
|
+
} else {
|
|
65
|
+
this.onAssign = (v: unknown) => {
|
|
66
|
+
this.setValue(v);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
this.observables = getObservables(observable);
|
|
70
|
+
|
|
71
|
+
this.observables.forEach((publisher) => {
|
|
72
|
+
publisher.onAssign(this.onAssign);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
// When the directive is disconnected from the DOM, unsubscribe to ensure
|
|
76
|
+
// the directive instance can be garbage collected
|
|
77
|
+
disconnected() {
|
|
78
|
+
this.unsubscribe();
|
|
79
|
+
}
|
|
80
|
+
// If the subtree the directive is in was disconnected and subsequently
|
|
81
|
+
// re-connected, re-subscribe to make the directive operable again
|
|
82
|
+
reconnected() {
|
|
83
|
+
if (!this.observable) return;
|
|
84
|
+
this.subscribe(this.observable as Observable);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const dir = directive(ObserveDirective);
|
|
88
|
+
//
|
|
89
|
+
//autoUpdate directive
|
|
90
|
+
export const subscribe = dir;
|
|
91
|
+
export const sub = dir;
|
|
92
|
+
|
|
93
|
+
// get value
|
|
94
|
+
export const get = (id: Observable) => {
|
|
95
|
+
return getObservables(id).values().next().value.get();
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const deepee = (id: Observable, defaultValue?: any) => {
|
|
99
|
+
const value = getObservables(id).values().next().value;
|
|
100
|
+
if (defaultValue !== undefined) {
|
|
101
|
+
const innerValue = value.get();
|
|
102
|
+
if (Objects.isEmpty(innerValue)) {
|
|
103
|
+
value.set(defaultValue);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return value;
|
|
107
|
+
};
|
|
108
|
+
export const dataProvider = deepee;
|
|
109
|
+
export const dp = deepee;
|
|
110
|
+
|
|
111
|
+
export const set = (id: Observable, value: unknown) => {
|
|
112
|
+
getObservables(id).values().next().value.set(value);
|
|
113
|
+
};
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import {AsyncDirective} from "lit/async-directive.js";
|
|
2
|
+
import {directive} from "lit/directive.js";
|
|
3
|
+
import {PublisherManager} from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
4
|
+
import {dp} from "@supersoniks/concorde/core/directives/DataProvider";
|
|
5
|
+
import {noChange} from "lit";
|
|
6
|
+
import {APIConfiguration} from "@supersoniks/concorde/core/utils/api";
|
|
7
|
+
import API from "@supersoniks/concorde/core/utils/api";
|
|
8
|
+
import Objects from "../utils/Objects";
|
|
9
|
+
import HTML, {SearchableDomElement} from "../utils/HTML";
|
|
10
|
+
import {unsafeHTML} from "lit/directives/unsafe-html.js";
|
|
11
|
+
type ApiCallKey = {apiConfiguration: APIConfiguration; wordingProvider: string | null; wordingVersionProvider: string | null};
|
|
12
|
+
type ApiCallValue = {
|
|
13
|
+
api: API;
|
|
14
|
+
keysToTranslate: Set<string>;
|
|
15
|
+
translatedKeys: Set<string>;
|
|
16
|
+
wordingProvider: string | null;
|
|
17
|
+
callIndex: number;
|
|
18
|
+
wordingVersionProvider: string | null;
|
|
19
|
+
apiCallKey: ApiCallKey;
|
|
20
|
+
};
|
|
21
|
+
const apiCalls: Map<ApiCallKey, ApiCallValue> = new Map();
|
|
22
|
+
const getApiCall = (node: SearchableDomElement | null) => {
|
|
23
|
+
if (!node) return null;
|
|
24
|
+
const configuration = HTML.getApiConfiguration(node);
|
|
25
|
+
const wordingProvider = HTML.getAncestorAttributeValue(node, "wordingProvider");
|
|
26
|
+
const wordingVersionProvider = HTML.getAncestorAttributeValue(node, "wordingVersionProvider");
|
|
27
|
+
const searchedKey = {apiConfiguration: configuration, wordingProvider: wordingProvider, wordingVersionProvider: wordingVersionProvider};
|
|
28
|
+
//touver une api avec la même configuration en comparant les avec l'utilitaire Objects deepEqual
|
|
29
|
+
let apiCall = null;
|
|
30
|
+
for (const [key, value] of apiCalls) {
|
|
31
|
+
if (Objects.deepEqual(key, searchedKey)) {
|
|
32
|
+
apiCall = value;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (!apiCall) {
|
|
37
|
+
const api = new API(configuration);
|
|
38
|
+
apiCall = {
|
|
39
|
+
api,
|
|
40
|
+
keysToTranslate: new Set<string>(),
|
|
41
|
+
translatedKeys: new Set<string>(),
|
|
42
|
+
wordingProvider,
|
|
43
|
+
callIndex: 0,
|
|
44
|
+
wordingVersionProvider: wordingVersionProvider,
|
|
45
|
+
apiCallKey: searchedKey,
|
|
46
|
+
};
|
|
47
|
+
apiCalls.set(searchedKey, apiCall);
|
|
48
|
+
}
|
|
49
|
+
return apiCall;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const loadingString = "";
|
|
53
|
+
export const isWordingReady = (key: string) => {
|
|
54
|
+
const value = WordingDirective.publisher["wording_" + key].get();
|
|
55
|
+
return value !== loadingString && value != null;
|
|
56
|
+
};
|
|
57
|
+
export default class WordingDirective extends AsyncDirective {
|
|
58
|
+
static publisher = PublisherManager.get("sonic-wording", {localStorageMode: "enabled"});
|
|
59
|
+
unsubscribe(): void {
|
|
60
|
+
WordingDirective.publisher["wording_" + this.key].offAssign(this.onAssign);
|
|
61
|
+
}
|
|
62
|
+
key?: string;
|
|
63
|
+
node?: SearchableDomElement;
|
|
64
|
+
useUnsafeHTML = false;
|
|
65
|
+
|
|
66
|
+
/* eslint-disable @typescript-eslint/no-explicit-any*/
|
|
67
|
+
constructor(partInfo: any) {
|
|
68
|
+
super(partInfo);
|
|
69
|
+
this.node = partInfo.options.host; // options n'est pas déclaré sur PartInfo mais exist en réalité d'où le typage "any"
|
|
70
|
+
}
|
|
71
|
+
/* eslint-enable @typescript-eslint/no-explicit-any*/
|
|
72
|
+
|
|
73
|
+
render(key: string, useUnsafeHTML = false) {
|
|
74
|
+
this.useUnsafeHTML = useUnsafeHTML;
|
|
75
|
+
if (this.key !== key) {
|
|
76
|
+
this.key = key;
|
|
77
|
+
if (this.isConnected) {
|
|
78
|
+
this.subscribe(key);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return noChange;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static firstCall = true;
|
|
85
|
+
static async callApi(node: SearchableDomElement | null, key: string, relaunch = true, usedApiCall?: ApiCallValue) {
|
|
86
|
+
await PublisherManager.getInstance().isLocalStrorageReady;
|
|
87
|
+
|
|
88
|
+
if (WordingDirective.firstCall) {
|
|
89
|
+
WordingDirective.firstCall = false;
|
|
90
|
+
//clean keys of the publisher that are equivalent to the loading string
|
|
91
|
+
const keys = Object.keys(WordingDirective.publisher.get());
|
|
92
|
+
for (const key of keys) {
|
|
93
|
+
if (WordingDirective.publisher.get()[key] === loadingString) {
|
|
94
|
+
delete WordingDirective.publisher[key];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (node) {
|
|
100
|
+
const wordingVersionProvider = HTML.getAncestorAttributeValue(node, "wordingVersionProvider");
|
|
101
|
+
if (wordingVersionProvider) {
|
|
102
|
+
dp(wordingVersionProvider).onAssign(WordingDirective.handleVersionProvider(node));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
let hasWordingForKey = WordingDirective.publisher.get()["wording_" + key] != null;
|
|
107
|
+
const apiCall = usedApiCall || getApiCall(node);
|
|
108
|
+
if (!apiCall) return;
|
|
109
|
+
if (hasWordingForKey && key !== "") {
|
|
110
|
+
apiCall.translatedKeys.add(key);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
apiCall.callIndex++;
|
|
114
|
+
const callIndex = apiCall.callIndex;
|
|
115
|
+
const wordingProvider = apiCall.wordingProvider ?? "";
|
|
116
|
+
|
|
117
|
+
// if the wording provider is unfortunately not set, we don't call the api now.
|
|
118
|
+
// We will try later
|
|
119
|
+
if (!wordingProvider && relaunch) {
|
|
120
|
+
window.setTimeout(async () => {
|
|
121
|
+
WordingDirective.callApi(null, key, false, apiCall);
|
|
122
|
+
}, 1000);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
//
|
|
126
|
+
//
|
|
127
|
+
const api = apiCall.api;
|
|
128
|
+
window.queueMicrotask(async () => {
|
|
129
|
+
hasWordingForKey = WordingDirective.publisher["wording_" + key].get() != null;
|
|
130
|
+
if (!hasWordingForKey && key !== "") {
|
|
131
|
+
apiCall.keysToTranslate.add(key);
|
|
132
|
+
WordingDirective.publisher["wording_" + key] = loadingString;
|
|
133
|
+
}
|
|
134
|
+
if (callIndex !== apiCall.callIndex) return;
|
|
135
|
+
const wordings = Array.from(apiCall.keysToTranslate);
|
|
136
|
+
if (!wordings.length) return;
|
|
137
|
+
const splittedUrl = wordingProvider.split("?");
|
|
138
|
+
const locationURL = splittedUrl.shift();
|
|
139
|
+
const queryString = (splittedUrl.length > 0 ? splittedUrl.join("?") + "&" : "") + "labels[]=" + wordings.join("&labels[]=");
|
|
140
|
+
const calledURL = locationURL + "?" + queryString;
|
|
141
|
+
apiCall.translatedKeys = new Set([...apiCall.translatedKeys, ...apiCall.keysToTranslate]);
|
|
142
|
+
apiCall.keysToTranslate.clear();
|
|
143
|
+
const result = (await api.get(calledURL)) as Record<string, string>;
|
|
144
|
+
for (const key in result) {
|
|
145
|
+
WordingDirective.publisher["wording_" + key] = result[key];
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
static versionProviderHandlers: Map<ApiCallValue, (v: number) => void> = new Map();
|
|
151
|
+
//check if the wording version has changed
|
|
152
|
+
static handleVersionProvider(node: SearchableDomElement) {
|
|
153
|
+
const apiCall = getApiCall(node);
|
|
154
|
+
if (!apiCall) return;
|
|
155
|
+
if (WordingDirective.versionProviderHandlers.has(apiCall)) {
|
|
156
|
+
return WordingDirective.versionProviderHandlers.get(apiCall);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const versionProviderHandler = function (version: number) {
|
|
160
|
+
const wordingVersionProvider = apiCall.wordingVersionProvider;
|
|
161
|
+
if (!wordingVersionProvider) return;
|
|
162
|
+
//
|
|
163
|
+
const currentVersions: {serviceURL: string | null; version: number}[] = WordingDirective.publisher.get().__wording_versions__ ?? [];
|
|
164
|
+
|
|
165
|
+
if (version == null) return;
|
|
166
|
+
const currentVersionData = currentVersions.find((v) => v.serviceURL === apiCall.api.serviceURL) || {
|
|
167
|
+
serviceURL: apiCall.api.serviceURL,
|
|
168
|
+
version: 0,
|
|
169
|
+
};
|
|
170
|
+
if (!currentVersions.includes(currentVersionData)) currentVersions.push(currentVersionData);
|
|
171
|
+
if (version === currentVersionData.version) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
currentVersionData.version = version;
|
|
176
|
+
WordingDirective.publisher.set({__wording_versions__: currentVersions});
|
|
177
|
+
for (const apiCall of apiCalls.values()) {
|
|
178
|
+
apiCall.keysToTranslate = new Set(apiCall.translatedKeys);
|
|
179
|
+
if (apiCall.keysToTranslate.size > 0) {
|
|
180
|
+
WordingDirective.callApi(null, "", false, apiCall);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
WordingDirective.versionProviderHandlers.set(apiCall, versionProviderHandler);
|
|
185
|
+
return versionProviderHandler;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
onAssign = (v: unknown) => {
|
|
189
|
+
const value = this.useUnsafeHTML ? unsafeHTML(v as string) : v;
|
|
190
|
+
this.setValue(value);
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// Subscribes to the key, calling the directive's asynchronous
|
|
194
|
+
// setValue API each time the value changes
|
|
195
|
+
subscribe(key: string) {
|
|
196
|
+
this.unsubscribe();
|
|
197
|
+
// this.onAssign = (v: unknown) => {
|
|
198
|
+
// this.setValue(v);
|
|
199
|
+
// };
|
|
200
|
+
WordingDirective.publisher["wording_" + key].onAssign(this.onAssign);
|
|
201
|
+
WordingDirective.callApi(this.node as SearchableDomElement, key);
|
|
202
|
+
}
|
|
203
|
+
// When the directive is disconnected from the DOM, unsubscribe to ensure
|
|
204
|
+
// the directive instance can be garbage collected
|
|
205
|
+
disconnected() {
|
|
206
|
+
this.unsubscribe();
|
|
207
|
+
}
|
|
208
|
+
// If the subtree the directive is in was disconnected and subsequently
|
|
209
|
+
// re-connected, re-subscribe to make the directive operable again
|
|
210
|
+
reconnected() {
|
|
211
|
+
if (!this.key) return;
|
|
212
|
+
this.subscribe(this.key);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
//autoUpdate directive
|
|
217
|
+
export const wording = directive(WordingDirective);
|
|
218
|
+
export const unsafeWording = (key: string) => wording(key, true);
|
|
219
|
+
export const t = wording;
|
|
220
|
+
export const w = wording;
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import "@supersoniks/concorde/core/components/ui/button/button";
|
|
2
|
+
import {SonicToast} from "@supersoniks/concorde/core/components/ui/toast/toast";
|
|
3
|
+
import {SubscriberInterface} from "@supersoniks/concorde/core/mixins/Subscriber";
|
|
4
|
+
import API from "@supersoniks/concorde/core/utils/api";
|
|
5
|
+
import Objects from "@supersoniks/concorde/core/utils/Objects";
|
|
6
|
+
import {PublisherManager} from "@supersoniks/concorde/utils";
|
|
7
|
+
import {property} from "lit/decorators.js";
|
|
8
|
+
import {PublisherContentType} from "../_types/types";
|
|
9
|
+
import {MixinArgsType} from "../_types/types";
|
|
10
|
+
import {ResultTypeInterface} from "@supersoniks/concorde/core/utils/api";
|
|
11
|
+
type Constructor<T> = new (...args: MixinArgsType[]) => T;
|
|
12
|
+
|
|
13
|
+
const fetchersInError: Set<{_fetchData: () => void}> = new Set();
|
|
14
|
+
export const invalidateFetchersInError = () => {
|
|
15
|
+
const fetchersInErrorCopy = new Set(fetchersInError);
|
|
16
|
+
fetchersInError.clear();
|
|
17
|
+
for (const fetcher of fetchersInErrorCopy) {
|
|
18
|
+
fetcher._fetchData();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const errorsListeners = new Set<(apiResponse: Response) => void>();
|
|
23
|
+
|
|
24
|
+
export const onFetchError = (errorListener: (apiResponse: Response) => void) => {
|
|
25
|
+
errorsListeners.add(errorListener);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const offFetchError = (errorListener: (apiResponse: Response) => void) => {
|
|
29
|
+
errorsListeners.delete(errorListener);
|
|
30
|
+
};
|
|
31
|
+
const dispatchFetchError = (apiResponse: Response) => {
|
|
32
|
+
for (const listener of errorsListeners) {
|
|
33
|
+
listener(apiResponse);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const Fetcher = <T extends Constructor<SubscriberInterface<PropsType>>, PropsType extends PublisherContentType = PublisherContentType>(
|
|
38
|
+
superClass: T,
|
|
39
|
+
propsType?: PropsType
|
|
40
|
+
) => {
|
|
41
|
+
propsType;
|
|
42
|
+
class FetcherElement extends superClass {
|
|
43
|
+
api: API | null = null;
|
|
44
|
+
/**
|
|
45
|
+
* Après le chargement des données on traverse l'objet reçu en fonctione de la cible exprimées dans cette propriété avec la dot syntaxe.
|
|
46
|
+
* C'est cette donnée cible qui est injectée dans les pros et donc disponible via le publisher disponible globalement via PublisherManager.get(dataProvider)
|
|
47
|
+
*/
|
|
48
|
+
key = "";
|
|
49
|
+
/**
|
|
50
|
+
* isFirstLoad vaut true jusqu'au premier chargement de données
|
|
51
|
+
*/
|
|
52
|
+
isFirstLoad = true;
|
|
53
|
+
/**
|
|
54
|
+
* isLoading vaut true pendant le chargement des données
|
|
55
|
+
*/
|
|
56
|
+
isLoading = false;
|
|
57
|
+
lazyLoad?: boolean;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* IObserver est l'intersection observer qui permet de charger les données au scroll si l'attribut lazyload est renseigné
|
|
61
|
+
*/
|
|
62
|
+
iObserver: IntersectionObserver | null = null;
|
|
63
|
+
/**
|
|
64
|
+
* On peut désactiver le fetch programmatiquement via cette propriété.
|
|
65
|
+
* Cela est le cas pour le composant sonic-list qui ne fetch que si l'attribut fetch est renseigné
|
|
66
|
+
*/
|
|
67
|
+
isFetchEnabled = true;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Result of the fetch
|
|
71
|
+
*/
|
|
72
|
+
fetchedData: any = null;
|
|
73
|
+
|
|
74
|
+
constructor(...args: MixinArgsType[]) {
|
|
75
|
+
super();
|
|
76
|
+
args;
|
|
77
|
+
this.dataProvider = "";
|
|
78
|
+
}
|
|
79
|
+
_endPoint = "";
|
|
80
|
+
|
|
81
|
+
@property() get props(): (PropsType & ResultTypeInterface) | null {
|
|
82
|
+
return super.props as (PropsType & ResultTypeInterface) | null;
|
|
83
|
+
}
|
|
84
|
+
set props(value) {
|
|
85
|
+
super.props = value;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@property({type: String}) set endPoint(value: string) {
|
|
89
|
+
this._endPoint = value;
|
|
90
|
+
if (this.isConnected) this._fetchData();
|
|
91
|
+
}
|
|
92
|
+
get endPoint(): string {
|
|
93
|
+
return this._endPoint;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@property() requestId = 0;
|
|
97
|
+
@property({type: Number}) refetchEveryMs = 0;
|
|
98
|
+
refetchTimeOutId?: ReturnType<typeof setTimeout>;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
*
|
|
102
|
+
* C'est ici que les données sont chargées via l'utilitaire API
|
|
103
|
+
* Elles sont ensuite injectées dans le publisher en accord avec la cible définie dans la propriété key
|
|
104
|
+
* Un Toast est affiché si le chargement échoue
|
|
105
|
+
*/
|
|
106
|
+
async _fetchData() {
|
|
107
|
+
this.requestUpdate();
|
|
108
|
+
if (!this.isFetchEnabled) return;
|
|
109
|
+
this.api = new API(this.getApiConfiguration());
|
|
110
|
+
if (!this.api) return;
|
|
111
|
+
|
|
112
|
+
// if (!this.dataProvider) return;
|
|
113
|
+
this.dispatchEvent(new CustomEvent("loading", {detail: this}));
|
|
114
|
+
|
|
115
|
+
if (this.getAttribute("localStorage") === "enabled") {
|
|
116
|
+
await PublisherManager.getInstance().isLocalStrorageReady;
|
|
117
|
+
}
|
|
118
|
+
if (!this.isConnected) return;
|
|
119
|
+
const headerData = PublisherManager.getInstance().get(this.getAncestorAttributeValue("headersDataProvider")).get();
|
|
120
|
+
this.isLoading = true;
|
|
121
|
+
if (Objects.isObject(this.props) && Object.keys(this.props || {}).length > 0 && this.isFirstLoad) {
|
|
122
|
+
window.requestAnimationFrame(() => {
|
|
123
|
+
this.dispatchEvent(new CustomEvent("load", {detail: this}));
|
|
124
|
+
this.isFirstLoad = false;
|
|
125
|
+
this.isLoading = false;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
let data = await this.api.get<PropsType>(this.endPoint || this.dataProvider || "", headerData);
|
|
130
|
+
|
|
131
|
+
this.fetchedData = data;
|
|
132
|
+
if (this.api.lastResult && !this.api.lastResult.ok) {
|
|
133
|
+
fetchersInError.add(this);
|
|
134
|
+
dispatchFetchError(this.api.lastResult);
|
|
135
|
+
}
|
|
136
|
+
if (!this.isConnected) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (!data) {
|
|
141
|
+
// Cela n'arrive normalement que lorsque l'on quitte une page pendant un fetch on n'affiche donc pas de message
|
|
142
|
+
this.isLoading = false;
|
|
143
|
+
if (this.refetchEveryMs && this.isConnected) {
|
|
144
|
+
this.refetchTimeOutId = setTimeout(() => this._fetchData(), this.refetchEveryMs);
|
|
145
|
+
}
|
|
146
|
+
return;
|
|
147
|
+
} else if (data._sonic_http_response_ && !data._sonic_http_response_.ok && Object.keys(data).length === 1) {
|
|
148
|
+
// Si data ne contient que la réponse HTTP, avec un statut not ok, on affiche un message
|
|
149
|
+
SonicToast.add({text: "Network Error", status: "error"});
|
|
150
|
+
}
|
|
151
|
+
if (this.key) {
|
|
152
|
+
const response = data._sonic_http_response_;
|
|
153
|
+
/* preserveOtherKeys s'exprime lorsque le paramètre "key" est défini
|
|
154
|
+
* Conserve les autres propriétés de l'objet reçu, en plus des propriétés définies sous "key"
|
|
155
|
+
*/
|
|
156
|
+
const path = this.key.split(".");
|
|
157
|
+
data = Objects.traverse(data, path, this.hasAttribute("preserveOtherKeys"));
|
|
158
|
+
|
|
159
|
+
if (data && Objects.isObject(data) && response) data._sonic_http_response_ = response;
|
|
160
|
+
}
|
|
161
|
+
this.props = data;
|
|
162
|
+
this.dispatchEvent(new CustomEvent("load", {detail: this}));
|
|
163
|
+
this.isFirstLoad = false;
|
|
164
|
+
this.isLoading = false;
|
|
165
|
+
|
|
166
|
+
if (this.refetchEveryMs && this.isConnected) {
|
|
167
|
+
this.refetchTimeOutId = setTimeout(() => this._fetchData(), this.refetchEveryMs);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
onInvalidate?: () => void;
|
|
172
|
+
disconnectedCallback(): void {
|
|
173
|
+
super.disconnectedCallback();
|
|
174
|
+
this.publisher?.offInvalidate(this.onInvalidate);
|
|
175
|
+
clearTimeout(this.refetchTimeOutId);
|
|
176
|
+
this.isFirstLoad = false;
|
|
177
|
+
}
|
|
178
|
+
connectedCallback() {
|
|
179
|
+
// this.noShadowDom = "";
|
|
180
|
+
|
|
181
|
+
this.lazyLoad = this.lazyLoad !== undefined ? this.lazyLoad : this.hasAttribute("lazyload");
|
|
182
|
+
|
|
183
|
+
super.connectedCallback();
|
|
184
|
+
|
|
185
|
+
if (!this.isFetchEnabled) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
this.key = this.key != "" ? this.key : this.getAttribute("key");
|
|
189
|
+
|
|
190
|
+
if (this.props) {
|
|
191
|
+
this.publisher.set(this.props);
|
|
192
|
+
}
|
|
193
|
+
this.onInvalidate = () => this._fetchData();
|
|
194
|
+
this.publisher?.onInvalidate(this.onInvalidate);
|
|
195
|
+
|
|
196
|
+
if (!this.lazyLoad) {
|
|
197
|
+
this._fetchData();
|
|
198
|
+
} else {
|
|
199
|
+
this.handleLazyLoad();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Première update, le comportement de lazyload est géré ici a l'aide d'un intersection observer.
|
|
204
|
+
*/
|
|
205
|
+
lazyLoadSpan?: HTMLSpanElement;
|
|
206
|
+
handleLazyLoad() {
|
|
207
|
+
if (!this.lazyLoad) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const rect = this.getBoundingClientRect();
|
|
211
|
+
if (rect.x < window.innerWidth && rect.right > 0 && rect.y < window.innerHeight && rect.right > 0) {
|
|
212
|
+
this._fetchData();
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const boundsRatio = parseFloat(this.getAttribute("lazyBoundsRatio") || "1");
|
|
217
|
+
|
|
218
|
+
const options: IntersectionObserverInit = {
|
|
219
|
+
root: null,
|
|
220
|
+
rootMargin: Math.max(window.innerWidth * boundsRatio, window.innerHeight * boundsRatio) + "px",
|
|
221
|
+
threshold: 0.9,
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
this.iObserver = new IntersectionObserver((entries) => this.onIntersection(entries), options);
|
|
225
|
+
let elt = (this.shadowRoot ? this.shadowRoot.children[0] : this.children[0]) as HTMLElement;
|
|
226
|
+
if (elt?.nodeName.toLocaleLowerCase() == "slot") elt = elt.children[0] as HTMLElement;
|
|
227
|
+
if (!elt || elt.nodeName.toLocaleLowerCase() == "template") {
|
|
228
|
+
elt = document.createElement("span");
|
|
229
|
+
const style = elt.style;
|
|
230
|
+
/**
|
|
231
|
+
* !!! Pas de position absolute ici si on veut que le composant soit au bon endroit dans la page pour l'intersection observer
|
|
232
|
+
* En effest sinon il vpeut remonter en congugaison avec le style display="contents"
|
|
233
|
+
*/
|
|
234
|
+
style.pointerEvents = "none";
|
|
235
|
+
this.lazyLoadSpan = elt;
|
|
236
|
+
this.appendChild(elt);
|
|
237
|
+
}
|
|
238
|
+
if (elt) {
|
|
239
|
+
this.iObserver.observe(elt);
|
|
240
|
+
} else if (this.isFirstLoad) {
|
|
241
|
+
this._fetchData();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
onIntersection(entries: IntersectionObserverEntry[]) {
|
|
245
|
+
for (const e of entries) {
|
|
246
|
+
if (e.isIntersecting && this.isFirstLoad) {
|
|
247
|
+
this._fetchData();
|
|
248
|
+
this.lazyLoadSpan?.remove();
|
|
249
|
+
this.lazyLoadSpan = undefined;
|
|
250
|
+
this.iObserver?.disconnect();
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return FetcherElement; //as Constructor<SubscriberInterface> & T;
|
|
257
|
+
};
|
|
258
|
+
export default Fetcher;
|