@supersoniks/concorde 2.0.6 → 3.0.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/build-infos.json +1 -0
- package/index.html +44 -0
- package/notes de migration.md +21 -0
- package/package.json +23 -287
- 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 -74
- package/components.d.ts +0 -4
- package/concorde-core.bundle.js +0 -3427
- package/concorde-core.es.js +0 -14199
- 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,95 @@
|
|
|
1
|
+
import {PublisherProxy} from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
2
|
+
import {Subscriber} from "@supersoniks/concorde/mixins";
|
|
3
|
+
import {Objects, PublisherManager} from "@supersoniks/concorde/utils";
|
|
4
|
+
import {LitElement, html, css} from "lit";
|
|
5
|
+
import {customElement, property} from "lit/decorators.js";
|
|
6
|
+
import {PublisherInterface, PublisherContentType} from "@supersoniks/concorde/core/_types/types";
|
|
7
|
+
|
|
8
|
+
type Composition = Record<string, object | string>;
|
|
9
|
+
type Listener = {publisher: PublisherInterface; subscriber: <T>(v: T) => void};
|
|
10
|
+
@customElement("sonic-mix")
|
|
11
|
+
export default class SonicMix extends Subscriber(LitElement) {
|
|
12
|
+
static styles = [
|
|
13
|
+
css`
|
|
14
|
+
:host {
|
|
15
|
+
display: contents;
|
|
16
|
+
}
|
|
17
|
+
`,
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
private _composition: Composition = {};
|
|
21
|
+
@property({type: Object}) get composition() {
|
|
22
|
+
return this._composition;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
set composition(value: Composition) {
|
|
26
|
+
this._composition = value;
|
|
27
|
+
this.updateComposition();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
connectedCallback(): void {
|
|
31
|
+
super.connectedCallback();
|
|
32
|
+
this.updateComposition();
|
|
33
|
+
}
|
|
34
|
+
disconnectedCallback(): void {
|
|
35
|
+
this.removePublisherListeners();
|
|
36
|
+
super.disconnectedCallback();
|
|
37
|
+
}
|
|
38
|
+
updateComposition() {
|
|
39
|
+
this.removePublisherListeners();
|
|
40
|
+
if (!this.publisher) return;
|
|
41
|
+
this.publisher.set({});
|
|
42
|
+
this.parseComposition(this.composition, this.publisher);
|
|
43
|
+
}
|
|
44
|
+
listeners: Listener[] = [];
|
|
45
|
+
removePublisherListeners() {
|
|
46
|
+
const listeners = this.listeners;
|
|
47
|
+
this.listeners = [];
|
|
48
|
+
listeners.forEach((listener) => {
|
|
49
|
+
this.publisher.offAssign(listener.subscriber);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
parseComposition<T extends PublisherContentType = PublisherContentType>(
|
|
53
|
+
composition: Composition,
|
|
54
|
+
publisher: PublisherInterface<T>
|
|
55
|
+
) {
|
|
56
|
+
if (!composition) return;
|
|
57
|
+
for (const z in composition) {
|
|
58
|
+
const value = composition[z];
|
|
59
|
+
if (typeof value === "string") {
|
|
60
|
+
const split = value.split(".");
|
|
61
|
+
const first = split.shift();
|
|
62
|
+
if (!first) continue;
|
|
63
|
+
let publisherSource = PublisherManager.get(first);
|
|
64
|
+
publisherSource = Objects.traverse(publisherSource, split);
|
|
65
|
+
const publisherSubscriber = {
|
|
66
|
+
publisher: publisherSource,
|
|
67
|
+
subscriber: <T>(v: T) => {
|
|
68
|
+
publisher[z] = v;
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
this.listeners.push(publisherSubscriber);
|
|
72
|
+
publisherSource.onAssign(publisherSubscriber.subscriber);
|
|
73
|
+
|
|
74
|
+
publisher._proxies_.set(z, publisherSource);
|
|
75
|
+
} else {
|
|
76
|
+
this.publisher[z] = {};
|
|
77
|
+
const newPublisher: PublisherInterface<T> = new PublisherProxy({}, publisher);
|
|
78
|
+
publisher._proxies_.set(z, newPublisher);
|
|
79
|
+
const publisherSubscriber = {
|
|
80
|
+
publisher: newPublisher,
|
|
81
|
+
subscriber: <T>(v: T) => {
|
|
82
|
+
publisher[z] = v;
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
this.listeners.push(publisherSubscriber);
|
|
86
|
+
newPublisher.onAssign(publisherSubscriber.subscriber);
|
|
87
|
+
this.parseComposition(value as Composition, newPublisher);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
render() {
|
|
93
|
+
return html`<slot></slot>`;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Queue
|
|
2
|
+
|
|
3
|
+
**sonic-queue** loads content in batches based on the expression provided in the dataProviderExpression attribute.
|
|
4
|
+
|
|
5
|
+
* Each batch is loaded by a [List component](#core/components/functional/list/list.md/list) whose dataProvider is created from the dataProviderExpression attribute.
|
|
6
|
+
* Upon initialization, it looks at the dataFilterProvider attribute, which provides the address of a publisher.
|
|
7
|
+
If this attribute is found, Queue listens to the provided publisher and resets itself whenever the content of the publisher is modified.
|
|
8
|
+
The values provided in this publisher are added as parameters to each request.
|
|
9
|
+
* The key property can be used to target a specific property in the API response as fetch does.
|
|
10
|
+
|
|
11
|
+
List extends the mixin [Subscriber](#docs/_core-concept/subscriber.md/subscriber)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
<sonic-code>
|
|
15
|
+
<template>
|
|
16
|
+
<sonic-queue
|
|
17
|
+
class="grid grid-cols-3 gap-3"
|
|
18
|
+
dataProviderExpression="communes?limit=$limit"
|
|
19
|
+
limit="30"
|
|
20
|
+
serviceURL="https://geo.api.gouv.fr/"
|
|
21
|
+
debug
|
|
22
|
+
>
|
|
23
|
+
<template>
|
|
24
|
+
<div data-bind ::inner-html="$nom" class="bg-neutral-100 p-2">
|
|
25
|
+
queue
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
</sonic-queue>
|
|
29
|
+
</template>
|
|
30
|
+
</sonic-code>
|
|
31
|
+
|
|
32
|
+
<sonic-code>
|
|
33
|
+
<template>
|
|
34
|
+
<sonic-queue
|
|
35
|
+
lazyload
|
|
36
|
+
dataProviderExpression="api/users?page=$offset&per_page=$limit"
|
|
37
|
+
offset="2"
|
|
38
|
+
limit="5"
|
|
39
|
+
dataFilterProvider="filter"
|
|
40
|
+
targetRequestDuration="500"
|
|
41
|
+
serviceURL="https://reqres.in"
|
|
42
|
+
key="data"
|
|
43
|
+
debug
|
|
44
|
+
>
|
|
45
|
+
<template>
|
|
46
|
+
<div class="flex px-4 py-3 items-center gap-4">
|
|
47
|
+
<sonic-image data-bind ::src="$avatar" rounded="full" ratio="1/1" class="w-20 block"></sonic-image>
|
|
48
|
+
<div>
|
|
49
|
+
<div class="text-bold text-2xl mb-2">
|
|
50
|
+
<span data-bind ::inner-html="$first_name"></span>
|
|
51
|
+
<span data-bind ::inner-html="$last_name"></span>
|
|
52
|
+
</div>
|
|
53
|
+
<sonic-button data-bind ::href="mailto|$email" size="xs" variant="outline"> Contact </sonic-button>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
<div class="border-0 border-t-2 border-t-neutral-200 w-full border-solid"></div>
|
|
57
|
+
</template>
|
|
58
|
+
</sonic-queue>
|
|
59
|
+
</template>
|
|
60
|
+
</sonic-code>
|
|
61
|
+
|
|
62
|
+
<sonic-code>
|
|
63
|
+
<template>
|
|
64
|
+
<sonic-list
|
|
65
|
+
lazyload
|
|
66
|
+
fetch
|
|
67
|
+
dataProvider="api/users?page=2&per_page=5"
|
|
68
|
+
serviceURL="https://reqres.in"
|
|
69
|
+
key="data"
|
|
70
|
+
debug
|
|
71
|
+
>
|
|
72
|
+
<template>
|
|
73
|
+
<div class="flex px-4 py-3 items-center gap-4">
|
|
74
|
+
<sonic-image data-bind ::src="$avatar" rounded="full" ratio="1/1" class="w-20 block"></sonic-image>
|
|
75
|
+
<div>
|
|
76
|
+
<div class="text-bold text-2xl mb-2">
|
|
77
|
+
<span data-bind ::inner-html="$first_name"></span>
|
|
78
|
+
<span data-bind ::inner-html="$last_name"></span>
|
|
79
|
+
</div>
|
|
80
|
+
<sonic-button data-bind ::href="mailto|$email" size="xs" variant="outline"> Contact </sonic-button>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
<div class="border-0 border-t-2 border-t-neutral-200 w-full border-solid"></div>
|
|
84
|
+
</template>
|
|
85
|
+
</sonic-list>
|
|
86
|
+
</template>
|
|
87
|
+
</sonic-code>
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import {html, LitElement, nothing} from "lit";
|
|
2
|
+
import {customElement, property} from "lit/decorators.js";
|
|
3
|
+
import Subscriber from "@supersoniks/concorde/core/mixins/Subscriber";
|
|
4
|
+
import {map} from "lit/directives/map.js";
|
|
5
|
+
import {PublisherManager} from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
6
|
+
import "@supersoniks/concorde/core/components/functional/list/list";
|
|
7
|
+
import {PublisherProxy} from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
8
|
+
import {HTML} from "@supersoniks/concorde/utils";
|
|
9
|
+
|
|
10
|
+
type QueueItem = {
|
|
11
|
+
id: string;
|
|
12
|
+
endPoint: string;
|
|
13
|
+
dataProvider: string;
|
|
14
|
+
offset: number;
|
|
15
|
+
limit: number;
|
|
16
|
+
};
|
|
17
|
+
type QueueProps = QueueItem[] & {resultCount?: number; lastFetchedData?: unknown};
|
|
18
|
+
|
|
19
|
+
const tagName = "sonic-queue";
|
|
20
|
+
/**
|
|
21
|
+
*### Une Queue charge du contenu par lot selon l'expression renseignée dans l'attribut *dataProviderExpression*.
|
|
22
|
+
* * Chaque lot est chargé par un composant [List](./?path=/docs/core-components-functional-list-list--basic) dont le dataProvider créé à partir de l'attribut dataProviderExpression
|
|
23
|
+
* * A l'initialisation elle regarde l'attribut dataFilterProvider qui donne l'adresse d'un publisher
|
|
24
|
+
* Si cet attribut est touvé, Queue écoute le publisher fourni et se réinitialise à chaque modification du contenu de celui-ci.
|
|
25
|
+
* Les valeurs renseignées dans ce publisher sont ajoutées en get à chaque requête
|
|
26
|
+
* * la proriété *key* peut être utilisé pour cibler une propriété particulière du retour de l'api.
|
|
27
|
+
*/
|
|
28
|
+
@customElement(tagName)
|
|
29
|
+
export default class Queue extends Subscriber(LitElement, {} as QueueProps) {
|
|
30
|
+
@property({type: Array}) templates: Array<HTMLTemplateElement> | null = null;
|
|
31
|
+
lastRequestTime = 0;
|
|
32
|
+
key = "";
|
|
33
|
+
|
|
34
|
+
@property({type: Object}) itemPropertyMap: object | null = null;
|
|
35
|
+
/**
|
|
36
|
+
* Durée cible en ms d'une requête pour afficher 1 lot.
|
|
37
|
+
*/
|
|
38
|
+
@property() cache: RequestCache = "default";
|
|
39
|
+
@property() targetRequestDuration = 500;
|
|
40
|
+
/*
|
|
41
|
+
* Quantité d'éléments devant être chargés dans le premier lot.
|
|
42
|
+
* Cette valeur est mise à jour ensuite par Queue pour chauq lot pour se rapprocher tanque possible de *targetRequestDuration*
|
|
43
|
+
*/
|
|
44
|
+
@property() limit = 5;
|
|
45
|
+
@property() lazyBoundsRatio = 1;
|
|
46
|
+
|
|
47
|
+
@property() offset = 0;
|
|
48
|
+
@property() resultCount = 0;
|
|
49
|
+
@property({type: Boolean}) noLazyload = false;
|
|
50
|
+
|
|
51
|
+
@property() filteredFields = "";
|
|
52
|
+
disconnectedCallback() {
|
|
53
|
+
for (const dataProvider of this.listDataProviders) {
|
|
54
|
+
PublisherManager.delete(dataProvider);
|
|
55
|
+
this.listDataProviders = [];
|
|
56
|
+
}
|
|
57
|
+
this.filterPublisher?.offInternalMutation(this.updateFilteredContent);
|
|
58
|
+
// reset internal state
|
|
59
|
+
this.props = null;
|
|
60
|
+
this.limit = 5;
|
|
61
|
+
this.offset = 0;
|
|
62
|
+
this.resultCount = 0;
|
|
63
|
+
this.searchHash = "";
|
|
64
|
+
this.requestId = 0;
|
|
65
|
+
this.isFirstRequest = true;
|
|
66
|
+
this.nextHadEvent = false;
|
|
67
|
+
this.publisher.set({});
|
|
68
|
+
super.disconnectedCallback();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
static instanceCounter = 0;
|
|
72
|
+
instanceId = 0;
|
|
73
|
+
localStorage = "disabled";
|
|
74
|
+
async connectedCallback() {
|
|
75
|
+
this.instanceId = Queue.instanceCounter++;
|
|
76
|
+
this.localStorage = this.getAttribute("localStorage") || this.localStorage;
|
|
77
|
+
this.filterTimeoutMs = parseInt(this.getAttribute("filterTimeoutMs") || "400");
|
|
78
|
+
//On supprime l'attribut car une queue ne doi pas être en localstorage, ce sont ses sous composants list qui doivent l'être
|
|
79
|
+
this.removeAttribute("localStorage");
|
|
80
|
+
this.noShadowDom = "";
|
|
81
|
+
this.defferedDebug = this.hasAttribute("debug") || null;
|
|
82
|
+
/**Compat avec states et routing **/
|
|
83
|
+
if (!this.dataProvider)
|
|
84
|
+
this.dataProvider = this.dataProviderExpression || "sonic-queue-" + this.instanceId + "-" + Math.random().toString(36).substring(7);
|
|
85
|
+
if (!this.dataProviderExpression) {
|
|
86
|
+
this.dataProviderExpression = HTML.getAncestorAttributeValue(this.parentElement, "dataProvider") || "";
|
|
87
|
+
}
|
|
88
|
+
super.connectedCallback();
|
|
89
|
+
this.publisher.set({});
|
|
90
|
+
this.key = this.getAttribute("key");
|
|
91
|
+
await PublisherManager.getInstance().isLocalStrorageReady;
|
|
92
|
+
if (!this.templates) this.templates = Array.from(this.querySelectorAll("template")) as Array<HTMLTemplateElement>;
|
|
93
|
+
this.lastRequestTime = new Date().getTime();
|
|
94
|
+
this.configFilter();
|
|
95
|
+
}
|
|
96
|
+
filterPublisher: PublisherProxy | null = null;
|
|
97
|
+
configFilter() {
|
|
98
|
+
const dataFilterProvider = this.getAncestorAttributeValue("dataFilterProvider");
|
|
99
|
+
if (!dataFilterProvider) {
|
|
100
|
+
this.next();
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
this.filterPublisher = PublisherManager.getInstance().get(dataFilterProvider);
|
|
105
|
+
this.filterPublisher?.onInternalMutation(this.updateFilteredContent);
|
|
106
|
+
}
|
|
107
|
+
filterTimeoutId?: ReturnType<typeof setTimeout>;
|
|
108
|
+
filterTimeoutMs = 400;
|
|
109
|
+
searchHash = "";
|
|
110
|
+
requestId = 0;
|
|
111
|
+
isFirstRequest = true;
|
|
112
|
+
updateFilteredContent = () => {
|
|
113
|
+
/**
|
|
114
|
+
* On ne lance la recherche que si le hash de recherche est différent
|
|
115
|
+
*/
|
|
116
|
+
const dataProvider = this.dataProviderExpression;
|
|
117
|
+
const split = dataProvider.split("?");
|
|
118
|
+
split.shift();
|
|
119
|
+
const searchParams = new URLSearchParams(split.join("?"));
|
|
120
|
+
const filterData: Record<string, string | string[]> = this.filterPublisher?.get();
|
|
121
|
+
const filteredFieldsArray = this.filteredFields.split(" ");
|
|
122
|
+
for (const f in filterData) {
|
|
123
|
+
let value = filterData[f];
|
|
124
|
+
if (Array.isArray(value)) value = value.filter((v: string | null) => v !== null);
|
|
125
|
+
if ((this.filteredFields && !filteredFieldsArray.includes(f)) || value == null || value.toString() === "") continue;
|
|
126
|
+
searchParams.set(f, filterData[f].toString());
|
|
127
|
+
}
|
|
128
|
+
const searchHash = searchParams.toString();
|
|
129
|
+
if (searchHash == this.searchHash && !this.isFirstRequest) return;
|
|
130
|
+
this.searchHash = searchHash;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* on reset les données avant de lancer la requète
|
|
134
|
+
*/
|
|
135
|
+
|
|
136
|
+
for (const dataProvider of this.listDataProviders) {
|
|
137
|
+
PublisherManager.delete(dataProvider);
|
|
138
|
+
// this.publisher.lastFetchedData = {};
|
|
139
|
+
}
|
|
140
|
+
this.listDataProviders = [];
|
|
141
|
+
clearTimeout(this.filterTimeoutId);
|
|
142
|
+
this.filterTimeoutId = setTimeout(
|
|
143
|
+
async () => {
|
|
144
|
+
const count = this.resultCount;
|
|
145
|
+
this.props = null;
|
|
146
|
+
//On garde le décompte au cas ou il n'y aurait pas rechargement
|
|
147
|
+
this.requestId++;
|
|
148
|
+
this.resultCount = count;
|
|
149
|
+
await PublisherManager.getInstance().isLocalStrorageReady;
|
|
150
|
+
window.requestAnimationFrame(() => this.next());
|
|
151
|
+
},
|
|
152
|
+
this.isFirstRequest ? 0 : this.filterTimeoutMs
|
|
153
|
+
);
|
|
154
|
+
this.isFirstRequest = false;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Cette expression est utilisée comme modèle par le composant Queue pour renseigngner le dataProvider de la [liste](./?path=/docs/core-components-functional-list-list--basic) créée.
|
|
159
|
+
* * l'expression *$offset* est alors remplacée par le numéro de l'élément à partir duquel démarrer
|
|
160
|
+
* * l'expression *$limit* est remplacée par la valeur représentant le nombre d'éléments à charger
|
|
161
|
+
* * Si pas d'expression *$offset* le composant se comporte un peu comme une liste, il ne va pas essayer de charger les éléments suivants
|
|
162
|
+
*/
|
|
163
|
+
@property({type: String}) dataProviderExpression = "";
|
|
164
|
+
|
|
165
|
+
@property({type: String}) idKey = "id";
|
|
166
|
+
|
|
167
|
+
resetDuration() {
|
|
168
|
+
this.lastRequestTime = new Date().getTime();
|
|
169
|
+
}
|
|
170
|
+
listDataProviders: string[] = [];
|
|
171
|
+
|
|
172
|
+
nextHadEvent = false;
|
|
173
|
+
next(e?: CustomEvent) {
|
|
174
|
+
let offset = this.offset;
|
|
175
|
+
const newTime = new Date().getTime();
|
|
176
|
+
const requestDuration = newTime - this.lastRequestTime;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Le rechargement n'est pas garanti si pas de changement dans les filtres
|
|
180
|
+
* Un ne repasse donc à 0 qu'à partir du premier chargement.
|
|
181
|
+
* */
|
|
182
|
+
if (!this.nextHadEvent && e) {
|
|
183
|
+
this.publisher.resultCount = 0;
|
|
184
|
+
// this.publisher.lastFetchedData = {};
|
|
185
|
+
this.resultCount = 0;
|
|
186
|
+
}
|
|
187
|
+
this.nextHadEvent = !!e;
|
|
188
|
+
|
|
189
|
+
if (e) {
|
|
190
|
+
this.publisher.lastFetchedData = e.detail.fetchedData;
|
|
191
|
+
if (e.detail.requestId < this.requestId) return;
|
|
192
|
+
this.resultCount += e.detail.props.length;
|
|
193
|
+
|
|
194
|
+
if (!e.detail.isFirstLoad || !e.detail.props.length || this.dataProviderExpression.indexOf("$offset") == -1) {
|
|
195
|
+
this.publisher.resultCount = this.resultCount;
|
|
196
|
+
// this.publisher.lastFetchedData = {};
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (!Array.isArray(this.props)) {
|
|
201
|
+
const newProps: QueueProps = [];
|
|
202
|
+
newProps.resultCount = this.resultCount;
|
|
203
|
+
newProps.lastFetchedData = e?.detail.fetchedData || {};
|
|
204
|
+
this.props = newProps;
|
|
205
|
+
} else {
|
|
206
|
+
const props: Array<{offset: number; limit: number}> = this.props;
|
|
207
|
+
const item = props[props.length - 1];
|
|
208
|
+
offset = parseInt(item.offset.toString()) + parseInt(item.limit.toString());
|
|
209
|
+
}
|
|
210
|
+
if (requestDuration > 0 && e && !this.localStorage) {
|
|
211
|
+
this.limit = Math.round((this.limit / requestDuration) * this.targetRequestDuration);
|
|
212
|
+
}
|
|
213
|
+
if (this.limit < 1) this.limit = 1;
|
|
214
|
+
if (this.limit > 15) this.limit = 15;
|
|
215
|
+
let dataProvider = this.dataProviderExpression.replace("$offset", offset + "").replace("$limit", this.limit + "");
|
|
216
|
+
const split = dataProvider.split("?");
|
|
217
|
+
let endpoint = split.shift();
|
|
218
|
+
const searchParams = new URLSearchParams(split.join("?"));
|
|
219
|
+
const filterData: Record<string, string> = this.filterPublisher?.get();
|
|
220
|
+
const filteredFieldsArray = this.filteredFields.split(" ");
|
|
221
|
+
|
|
222
|
+
for (const f in filterData) {
|
|
223
|
+
if ((this.filteredFields && filteredFieldsArray.includes(f)) || filterData[f] == null || filterData[f] == "") continue;
|
|
224
|
+
searchParams.set(f, filterData[f]);
|
|
225
|
+
}
|
|
226
|
+
if (!this.searchHash) this.searchHash = searchParams.toString();
|
|
227
|
+
endpoint = endpoint + "?" + searchParams.toString();
|
|
228
|
+
dataProvider = dataProvider + "_item_from_queue_" + this.instanceId;
|
|
229
|
+
this.listDataProviders.push(dataProvider);
|
|
230
|
+
const newProps: QueueProps = [
|
|
231
|
+
...this.props,
|
|
232
|
+
{
|
|
233
|
+
id: searchParams.toString() + "/" + this.props.length,
|
|
234
|
+
dataProvider: dataProvider,
|
|
235
|
+
endPoint: endpoint,
|
|
236
|
+
offset: offset,
|
|
237
|
+
limit: this.limit,
|
|
238
|
+
},
|
|
239
|
+
];
|
|
240
|
+
newProps.resultCount = this.resultCount;
|
|
241
|
+
newProps.lastFetchedData = e?.detail.fetchedData || {};
|
|
242
|
+
this.props = newProps;
|
|
243
|
+
this.lastRequestTime = new Date().getTime();
|
|
244
|
+
}
|
|
245
|
+
render() {
|
|
246
|
+
if (!Array.isArray(this.props)) return nothing;
|
|
247
|
+
let lazyload = !this.noLazyload;
|
|
248
|
+
if (this.props.length == 1) {
|
|
249
|
+
lazyload = false;
|
|
250
|
+
}
|
|
251
|
+
return html`
|
|
252
|
+
${map(this.props, (item, index) => {
|
|
253
|
+
const templates = index == 0 ? this.templates : this.templates?.filter((elt) => elt.getAttribute("data-value") != "no-item");
|
|
254
|
+
return html`
|
|
255
|
+
<sonic-list
|
|
256
|
+
fetch
|
|
257
|
+
loader="inline"
|
|
258
|
+
cache=${this.cache}
|
|
259
|
+
displayContents
|
|
260
|
+
lazyBoundsRatio=${this.lazyBoundsRatio}
|
|
261
|
+
?lazyload=${lazyload}
|
|
262
|
+
localStorage=${this.localStorage}
|
|
263
|
+
requestId=${this.requestId}
|
|
264
|
+
.itemPropertyMap=${this.itemPropertyMap}
|
|
265
|
+
?debug=${this.defferedDebug === true}
|
|
266
|
+
@load=${this.next}
|
|
267
|
+
key=${this.key}
|
|
268
|
+
@loading=${this.resetDuration}
|
|
269
|
+
dataProvider="${item.dataProvider}"
|
|
270
|
+
endPoint="${item.endPoint}"
|
|
271
|
+
idKey=${this.idKey}
|
|
272
|
+
.templates=${templates}
|
|
273
|
+
>
|
|
274
|
+
</sonic-list>
|
|
275
|
+
`;
|
|
276
|
+
})}
|
|
277
|
+
`;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {LitElement} from "lit";
|
|
2
|
+
import {customElement} from "lit/decorators.js";
|
|
3
|
+
import Subscriber from "@supersoniks/concorde/core/mixins/Subscriber";
|
|
4
|
+
import LocationHandler from "@supersoniks/concorde/core/utils/LocationHandler";
|
|
5
|
+
import Objects from "@supersoniks/concorde/core/utils/Objects";
|
|
6
|
+
const tagName = "sonic-redirect";
|
|
7
|
+
/**
|
|
8
|
+
* sonic-redirect permet d'effectuer une redirection.
|
|
9
|
+
* * L'URL de redirection fournie dans l'attribut *to*.
|
|
10
|
+
* * La redirection est effectuée en fonction de la disponibilité d'une donnée issue du publisher à l'adresse fournie par l'attribut dataProvider
|
|
11
|
+
* * La donnée a trouver est renseignées via l'attribut *onData* qui peur repésenter un chemin dans la donnée via la dot syntaxe
|
|
12
|
+
* * Si la données est trouvée et qu'elle peut être évaluée à true alors la redirection est effectuée
|
|
13
|
+
* Par exemple : la données vaut {user:{id:2}} si onData="user.id"la redirection est effectuée.
|
|
14
|
+
* * Si l'attribut pushState est défini, alors la redirection est effectuée via pushState, sinon c'est document.location qui est modifié.
|
|
15
|
+
*/
|
|
16
|
+
@customElement(tagName)
|
|
17
|
+
export class SonicRedirect extends Subscriber(LitElement) {
|
|
18
|
+
udpateCallBack?: VoidFunction;
|
|
19
|
+
connectedCallback() {
|
|
20
|
+
this.noShadowDom = "";
|
|
21
|
+
this.style.display = "none";
|
|
22
|
+
super.connectedCallback();
|
|
23
|
+
this.udpateCallBack = () => this.update();
|
|
24
|
+
if (this.publisher) this.publisher.onInternalMutation(this.udpateCallBack);
|
|
25
|
+
}
|
|
26
|
+
disconnectedCallback(): void {
|
|
27
|
+
if (this.publisher) this.publisher.offInternalMutation(this.udpateCallBack);
|
|
28
|
+
super.disconnectedCallback();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
update() {
|
|
32
|
+
if (this.hasAttribute("onAdded")) {
|
|
33
|
+
LocationHandler.changeFromComponent(this);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (!this.props) return;
|
|
37
|
+
const onDataPath = this.getAttribute("onData").split(".");
|
|
38
|
+
const searchedData = Objects.traverse(this.props, onDataPath);
|
|
39
|
+
|
|
40
|
+
if (searchedData && !(Objects.isObject(searchedData) && searchedData)) {
|
|
41
|
+
LocationHandler.changeFromComponent(this);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Router
|
|
2
|
+
|
|
3
|
+
The router observes the document.location changes and updates its view as follows
|
|
4
|
+
|
|
5
|
+
## Data-route / Basic
|
|
6
|
+
|
|
7
|
+
When the data-route attribute of a template matches the current url, the content of this template is rendered
|
|
8
|
+
|
|
9
|
+
<sonic-code>
|
|
10
|
+
<template>
|
|
11
|
+
<div class="flex gap-2 items-center">
|
|
12
|
+
<sonic-button href="#core/components/functional/router/router.md/router#home" size="xs">Home</sonic-button>
|
|
13
|
+
<sonic-button href="#core/components/functional/router/router.md/router#about" size="xs">About</sonic-button>
|
|
14
|
+
<sonic-button href="#core/components/functional/router/router.md/router#work" size="xs">Work</sonic-button>
|
|
15
|
+
<sonic-button href="#core/components/functional/router/router.md/router#contact" size="xs">Contact</sonic-button>
|
|
16
|
+
</div>
|
|
17
|
+
<sonic-router>
|
|
18
|
+
<template data-route="#home">
|
|
19
|
+
<div class="text-center text-neutral-700 border rounded text-4xl my-6 p-3 ">Home</div>
|
|
20
|
+
</template>
|
|
21
|
+
<template data-route="#about">
|
|
22
|
+
<div class="text-center text-neutral-700 border rounded text-4xl my-6 p-3 ">About</div>
|
|
23
|
+
</template>
|
|
24
|
+
<template data-route="#work">
|
|
25
|
+
<div class="text-center text-neutral-700 border rounded text-4xl my-6 p-3 ">Work</div>
|
|
26
|
+
</template>
|
|
27
|
+
<template data-route="#contact">
|
|
28
|
+
<div class="text-center text-neutral-700 border rounded text-4xl my-6 p-3 ">Contact</div>
|
|
29
|
+
</template>
|
|
30
|
+
</sonic-router>
|
|
31
|
+
</template>
|
|
32
|
+
</sonic-code>
|
|
33
|
+
|
|
34
|
+
## Data-route / Regexp
|
|
35
|
+
|
|
36
|
+
You can use any RegExp in the data-route attribute of your templates to match the current location and to extract variables from it using capturing groups.
|
|
37
|
+
A dataProvider attribute is generated using the dataProviderExpression where $1, $2... are replaced with this variables.
|
|
38
|
+
|
|
39
|
+
**e.g.**, data-route="#couleur_<b class="text-danger">(\d+)</b>" => dataProviderExpression="api/unknown/<b class="text-danger">$1</b>"
|
|
40
|
+
|
|
41
|
+
The rendered content of the matching template is scoped with this **dataProvider**.
|
|
42
|
+
You can make creative usage on this feature to generate dynamic content based on services.
|
|
43
|
+
|
|
44
|
+
<sonic-code>
|
|
45
|
+
<template>
|
|
46
|
+
<sonic-theme theme="light" serviceURL="https://reqres.in">
|
|
47
|
+
<sonic-list fetch dataProvider="api/unknown" key="data" class="flex gap-2 items-center" >
|
|
48
|
+
<template>
|
|
49
|
+
<sonic-button radio size="xs" data-bind ::href="#core/components/functional/router/router.md/router#couleur_$id">
|
|
50
|
+
<span data-bind ::inner-html="ucFirst|$name"></span>
|
|
51
|
+
</sonic-button>
|
|
52
|
+
</template>
|
|
53
|
+
</sonic-list>
|
|
54
|
+
<sonic-router>
|
|
55
|
+
<template data-route="#couleur_(\d+)" dataProviderExpression="api/unknown/$1">
|
|
56
|
+
<sonic-fetch>
|
|
57
|
+
<input type="color" disabled data-bind ::value="$data.color" class=" w-full h-10 my-3" />
|
|
58
|
+
</sonic-fetch>
|
|
59
|
+
</template>
|
|
60
|
+
</sonic-router>
|
|
61
|
+
</sonic-theme>
|
|
62
|
+
</template>
|
|
63
|
+
</sonic-code>
|
|
64
|
+
|
|
65
|
+
## Data-route / Url-pattern
|
|
66
|
+
|
|
67
|
+
Same as RegExp but using <a href="https://www.npmjs.com/package/url-pattern" target="_blank">url patterns</a>
|
|
68
|
+
**e.g.**, data-route="#couleur_<b class="text-danger">:id</b>" => dataProviderExpression="api/unknown/<b class="text-danger">:id</b>"
|
|
69
|
+
|
|
70
|
+
<sonic-code>
|
|
71
|
+
<template>
|
|
72
|
+
<sonic-theme theme="light" serviceURL="https://reqres.in">
|
|
73
|
+
<sonic-list fetch dataProvider="api/unknown" key="data" class="flex gap-2 items-center" >
|
|
74
|
+
<template>
|
|
75
|
+
<sonic-button radio size="xs" data-bind ::href="#core/components/functional/router/router.md/router#couleur_$id">
|
|
76
|
+
<span data-bind ::inner-html="ucFirst|$name"></span>
|
|
77
|
+
</sonic-button>
|
|
78
|
+
</template>
|
|
79
|
+
</sonic-list>
|
|
80
|
+
<sonic-router>
|
|
81
|
+
<template data-route="/*#couleur_:id" dataProviderExpression="api/unknown/:id">
|
|
82
|
+
<sonic-fetch>
|
|
83
|
+
<input type="color" disabled data-bind ::value="$data.color" class=" w-full h-10 my-3" />
|
|
84
|
+
</sonic-fetch>
|
|
85
|
+
</template>
|
|
86
|
+
</sonic-router>
|
|
87
|
+
</sonic-theme>
|
|
88
|
+
</template>
|
|
89
|
+
</sonic-code>
|
|
90
|
+
|
|
91
|
+
## Redirect
|
|
92
|
+
|
|
93
|
+
Redirect allows to redirect to a url when a data is provided.
|
|
94
|
+
Here Redirect waits that a data is available in the property *theData* of the dataProvider *stupid-data-set-id*
|
|
95
|
+
We are then redirected to the url *#data-is-set* which does nothing in itself.
|
|
96
|
+
|
|
97
|
+
<sonic-code>
|
|
98
|
+
<template>
|
|
99
|
+
<sonic-redirect to="#core/components/functional/router/router.md/router#data-is-set" dataProvider="stupid-data-set-id" onData="theData"></sonic-redirect>
|
|
100
|
+
<div class="flex gap-2 mb-4" formDataProvider="stupid-data-set-id">
|
|
101
|
+
<sonic-button radio name="theData" value="Some Data" size="xs">
|
|
102
|
+
Enter data
|
|
103
|
+
</sonic-button>
|
|
104
|
+
<sonic-button radio name="theData" value="" href="javascript:history.back();" size="xs">
|
|
105
|
+
Delete the data and do a history.back()
|
|
106
|
+
</sonic-button>
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
</template>
|
|
110
|
+
</sonic-code>
|
|
111
|
+
|
|
112
|
+
Example of use : use with a router and a submit to manage the steps of login/logout, display of user info.
|