@supersoniks/concorde 2.0.7 → 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 -290
- 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/concorde-core.bundle.js +0 -3427
- package/concorde-core.es.js +0 -14372
- 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
package/{core/components/functional/fetch/fetch.js → src/core/components/functional/fetch/fetch.ts}
RENAMED
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
1
|
import { css, html, LitElement, nothing } from "lit";
|
|
8
2
|
import { customElement, property } from "lit/decorators.js";
|
|
9
3
|
import Subscriber from "@supersoniks/concorde/core/mixins/Subscriber";
|
|
10
4
|
import Fetcher from "@supersoniks/concorde/core/mixins/Fetcher";
|
|
5
|
+
import { LoaderMode } from "../../ui/loader/loader";
|
|
11
6
|
import { TemplatesContainer } from "@supersoniks/concorde/mixins";
|
|
12
7
|
import { templateContent } from "lit/directives/template-content.js";
|
|
8
|
+
import { DirectiveResult } from "lit/async-directive.js";
|
|
13
9
|
const tagName = "sonic-fetch"; // For Astro.build
|
|
14
10
|
/**
|
|
15
11
|
* ###Fetch charge un contenu via un appel d'api web.
|
|
16
12
|
* Extends mixins : Fetcher, [Subscriber](./?path=/docs/miscallenous-🔔-subscriber--page)
|
|
17
|
-
*
|
|
13
|
+
*
|
|
18
14
|
* #### Configuration via les attributs
|
|
19
|
-
*
|
|
15
|
+
*
|
|
20
16
|
* | nom | sur quelle balise | Description | Exemple de valeur | défaut / requis |
|
|
21
17
|
* | -------------------------------------------------------------------------------------- |
|
|
22
18
|
* | serviceURL |Fetcher ou un de ses parents | URL de base des services. | http://la-billetterie.net/api/v2 | domain du site |
|
|
@@ -24,10 +20,10 @@ const tagName = "sonic-fetch"; // For Astro.build
|
|
|
24
20
|
* | dataProvider |Fetcher ou un de ses parents | Identifiant d'un publisher qui stock les données, voir [subscriber](./?path=/docs/miscallenous-🔔-subscriber--page). | billetterie/user/2 | *REQUIS* |
|
|
25
21
|
* | headersDataProvider |Fetcher ou un de ses parents | Identifiant d'un publisher qui stock les données destinées à être envoyées en entêtes de la requetes | MyCoockieHEaders | null |
|
|
26
22
|
* | key |Fetcher | extrait une sous propriété de la donnée chargée avant de l'assignée à son publisher | ma.data | null |
|
|
27
|
-
*
|
|
23
|
+
*
|
|
28
24
|
* *Si la données est `{ma:{data:{a:1,b:2}}}` et `key="ma.data"`, la données disponible dans le composant sera `{a:1, b:2}`*
|
|
29
25
|
|
|
30
|
-
#### Intégration auto de basic auth (pour tester une api qui nécessite une authentification)
|
|
26
|
+
#### Intégration auto de basic auth (pour tester une api qui nécessite une authentification)
|
|
31
27
|
|
|
32
28
|
* Fetch utilise le service pour générer le token et l'ajoute au header de l'appel qui récupère les données.
|
|
33
29
|
|
|
@@ -42,34 +38,34 @@ const tagName = "sonic-fetch"; // For Astro.build
|
|
|
42
38
|
* * On peut appeler la methode invalidate() sur le publisher associé au composant pour declencher le rechargement des données.
|
|
43
39
|
* * endPoint est une propriété réctive, par conséquent, sa modification, manuelle via template ou data binbding provoque la mise à jour du contenu.
|
|
44
40
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return html `<sonic-loader mode=${loader}></sonic-loader>`;
|
|
51
|
-
}
|
|
52
|
-
renderSkeleton() {
|
|
53
|
-
const template = this.templateParts["skeleton"];
|
|
54
|
-
if (!(this.isLoading && template))
|
|
55
|
-
return nothing;
|
|
56
|
-
return templateContent(template);
|
|
57
|
-
}
|
|
58
|
-
render() {
|
|
59
|
-
return html ` ${this.renderSkeleton()} ${this.renderLoader()} ${!this.isLoading ? html `<slot></slot>` : nothing} `;
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
Fetch.styles = [
|
|
63
|
-
css `
|
|
41
|
+
|
|
42
|
+
@customElement(tagName)
|
|
43
|
+
export class Fetch extends Fetcher(Subscriber(TemplatesContainer(LitElement))) {
|
|
44
|
+
static styles = [
|
|
45
|
+
css`
|
|
64
46
|
:host {
|
|
65
47
|
display: contents;
|
|
66
48
|
}
|
|
67
49
|
`,
|
|
68
|
-
];
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
50
|
+
];
|
|
51
|
+
@property() loader?: LoaderMode | true | "";
|
|
52
|
+
|
|
53
|
+
renderLoader() {
|
|
54
|
+
if (!(this.isLoading && this.loader !== undefined)) return nothing;
|
|
55
|
+
const loader =
|
|
56
|
+
this.loader === true || this.loader === "" ? "fixed" : this.loader;
|
|
57
|
+
return html`<sonic-loader mode=${loader}></sonic-loader>`;
|
|
58
|
+
}
|
|
59
|
+
renderSkeleton() {
|
|
60
|
+
const template = this.templateParts["skeleton"];
|
|
61
|
+
if (!(this.isLoading && template)) return nothing;
|
|
62
|
+
return templateContent(template) as DirectiveResult;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
render() {
|
|
66
|
+
return html`
|
|
67
|
+
${this.renderSkeleton()} ${this.renderLoader()}
|
|
68
|
+
${!this.isLoading ? html`<slot></slot>` : nothing}
|
|
69
|
+
`;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# if / condition
|
|
2
|
+
|
|
3
|
+
The **sonic-if** component shows its content based on the value of its reactive property names **condition**
|
|
4
|
+
|
|
5
|
+
<sonic-code>
|
|
6
|
+
<template>
|
|
7
|
+
<div dataProvider="visibilitySettings" formDataProvider="visibilitySettings">
|
|
8
|
+
<sonic-checkbox label="Show evacuation plan" name="togglePlan" unique checked value="true"></sonic-checkbox>
|
|
9
|
+
<sonic-if data-bind ::condition="$togglePlan" class="mt-4 block">
|
|
10
|
+
<sonic-image src="https://www.thebaron.info/assets/mail/concorde-evacuation.jpg" rounded="md" ratio="654/463"></sonic-image>
|
|
11
|
+
</sonic-if>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
</sonic-code>
|
|
15
|
+
|
|
16
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {expect} from "@jest/globals";
|
|
2
|
+
import TestUtils from "@supersoniks/concorde/test-utils/TestUtils";
|
|
3
|
+
import "./if";
|
|
4
|
+
|
|
5
|
+
function create() {
|
|
6
|
+
return TestUtils.bootstrap(`<sonic-if>Some Content</sonic-if>`)[0];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
test("shows ''Some Content'' condition = true set by property accessor", async () => {
|
|
10
|
+
const elt: any = create();
|
|
11
|
+
elt.condition = true;
|
|
12
|
+
await elt.updated();
|
|
13
|
+
const renderedText = elt.shadowRoot.children[0].assignedNodes()[0].textContent;
|
|
14
|
+
expect(renderedText).toBe("Some Content");
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("shows nothing condition = false set by property accessor", async () => {
|
|
18
|
+
const elt: any = create();
|
|
19
|
+
elt.condition = false;
|
|
20
|
+
await elt.updated();
|
|
21
|
+
const children = Array.from(elt.shadowRoot.children).filter((elt: any) => elt.nodeName.toLowerCase() != "style");
|
|
22
|
+
const length = children.length;
|
|
23
|
+
expect(length).toBe(0);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test("shows ''Some Content'' condition = true set by attribute", async () => {
|
|
27
|
+
const elt: any = create();
|
|
28
|
+
elt.setAttribute("condition", "");
|
|
29
|
+
await elt.updated();
|
|
30
|
+
const renderedText = elt.shadowRoot.children[0].assignedNodes()[0].textContent;
|
|
31
|
+
expect(renderedText).toBe("Some Content");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("shows nothing condition not set", async () => {
|
|
35
|
+
const elt: any = create();
|
|
36
|
+
await elt.updated();
|
|
37
|
+
const children = Array.from(elt.shadowRoot.children).filter((elt: any) => elt.nodeName.toLowerCase() != "style");
|
|
38
|
+
const length = children.length;
|
|
39
|
+
expect(length).toBe(0);
|
|
40
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {css, html, LitElement, nothing} from "lit";
|
|
2
|
+
import {customElement, property} from "lit/decorators.js";
|
|
3
|
+
const tagName = "sonic-if"; // For Astro.build
|
|
4
|
+
/**
|
|
5
|
+
* Le composant *sonic-if* affiche son contenu dans le slot principal si sa propriété .condition est évaluée à true
|
|
6
|
+
*/
|
|
7
|
+
@customElement(tagName)
|
|
8
|
+
export class SonicIF extends LitElement {
|
|
9
|
+
static styles = css`
|
|
10
|
+
:host {
|
|
11
|
+
display: contents;
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Le contenu s'affiche si la condition est évaluée à true.
|
|
17
|
+
*/
|
|
18
|
+
@property({type: Boolean}) condition = false;
|
|
19
|
+
render() {
|
|
20
|
+
if (!this.condition) return nothing;
|
|
21
|
+
return html` <slot></slot> `;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# List
|
|
2
|
+
|
|
3
|
+
The **sonic-list** component creates list items.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
List extends the mixins [Subscriber](#docs/_core-concept/subscriber.md/subscriber) and Fetcher :
|
|
7
|
+
* As a Subscriber it as a **props** reactive property (basically an array of data) and its data is associated to a publisher via its dataProvider attribute.
|
|
8
|
+
* List doesn't Fetch by default (see below for activation).
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## Template
|
|
12
|
+
|
|
13
|
+
The list component loops over its template children to render each items of its props data.
|
|
14
|
+
Consider the following example using **2 templates** and **9 items** :
|
|
15
|
+
- First template will render the first item.
|
|
16
|
+
- Second template will render the second item.
|
|
17
|
+
- Then back to the first template and so on and so forth.
|
|
18
|
+
|
|
19
|
+
Note that for each line there is a dataProvider found at *[list dataProvider name]/liste-item/[line index or key]*
|
|
20
|
+
You can hover the list items in the examples to see it.
|
|
21
|
+
|
|
22
|
+
<sonic-code>
|
|
23
|
+
<template>
|
|
24
|
+
<sonic-list dataProvider="listTemplateExample" class="grid grid-cols-3 gap-4" props='[{"id": "1"}, {"id": "2"}, {"id": "3"}, {"id": "4"}, {"id": "5"}, {"id": "6"}, {"id": "7"}, {"id": "8"}, {"id": "9"}]' debug>
|
|
25
|
+
<template>
|
|
26
|
+
<div class="bg-neutral-100 text-center p-3">
|
|
27
|
+
<sonic-value key="id"></sonic-value>
|
|
28
|
+
<div class="text-xs">1st template</div>
|
|
29
|
+
</div>
|
|
30
|
+
</template>
|
|
31
|
+
<template>
|
|
32
|
+
<div class="bg-neutral-100 text-info text-center p-3">
|
|
33
|
+
<sonic-value key="id"></sonic-value>
|
|
34
|
+
<div class="text-xs">2nd template</div>
|
|
35
|
+
</div>
|
|
36
|
+
</template>
|
|
37
|
+
</sonic-list>
|
|
38
|
+
</template>
|
|
39
|
+
</sonic-code>
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## TemplateKey / data-value
|
|
44
|
+
|
|
45
|
+
The **templateKey** attribute allows you to bind a template to a props item.
|
|
46
|
+
Consider the following example :
|
|
47
|
+
- The list **templateKey** attribute is set to the value **tpl** (any name would do)
|
|
48
|
+
- Items 4,5 and 6 are each one **referencing** a templates with a matching **data-value** attribute
|
|
49
|
+
|
|
50
|
+
<sonic-code>
|
|
51
|
+
<template>
|
|
52
|
+
<sonic-list
|
|
53
|
+
templateKey="tpl"
|
|
54
|
+
class="grid gap-3"
|
|
55
|
+
dataProvider="TemplateKeyExample"
|
|
56
|
+
props='[
|
|
57
|
+
{"id":"1", "default": "The first template with no data-value is used"},
|
|
58
|
+
{"id":"2", "default": "The second template with no data-value is used"},
|
|
59
|
+
{"id":"3", "default": "Back to the first template with no data-value"},
|
|
60
|
+
{"id":"4", "tpl":"custom-tpl-danger"},
|
|
61
|
+
{"id":"5", "tpl":"custom-tpl-info"},
|
|
62
|
+
{"id":"6", "tpl":"custom-tpl-success"},
|
|
63
|
+
{"id":"7", "tpl": "Non-valid tpl name, Back to the first template with no data-value"}
|
|
64
|
+
]'
|
|
65
|
+
debug
|
|
66
|
+
>
|
|
67
|
+
<template>
|
|
68
|
+
<div class="p-2 border rounded text-neutral-900">
|
|
69
|
+
<sonic-value key="id"> : </sonic-value>
|
|
70
|
+
<b>First</b> template with no <b>data-value</b> attribute
|
|
71
|
+
</div>
|
|
72
|
+
</template>
|
|
73
|
+
<template data-value="custom-tpl-danger">
|
|
74
|
+
<div class="p-2 border rounded text-danger">
|
|
75
|
+
<sonic-value key="id"> : </sonic-value>
|
|
76
|
+
data-value : <b>custom-tpl-danger</b>
|
|
77
|
+
</div>
|
|
78
|
+
</template>
|
|
79
|
+
<template data-value="custom-tpl-info">
|
|
80
|
+
<div class="p-2 border rounded text-info">
|
|
81
|
+
<sonic-value key="id"> : </sonic-value>
|
|
82
|
+
data-value : <b>custom-tpl-info</b>
|
|
83
|
+
</div>
|
|
84
|
+
</template>
|
|
85
|
+
<template data-value="custom-tpl-success">
|
|
86
|
+
<div class="p-2 border rounded text-success">
|
|
87
|
+
<sonic-value key="id"> : </sonic-value>
|
|
88
|
+
data-value : <b>custom-tpl-success</b>
|
|
89
|
+
</div>
|
|
90
|
+
</template>
|
|
91
|
+
<template>
|
|
92
|
+
<div class="p-2 border rounded text-neutral-400">
|
|
93
|
+
<sonic-value key="id"> : </sonic-value>
|
|
94
|
+
<b>Second</b> template with no <b>data-value</b> attribute <br>
|
|
95
|
+
This one is used if it <b>follows another data-item</b> with <b>no tpl</b> specified in the props
|
|
96
|
+
</div>
|
|
97
|
+
</template>
|
|
98
|
+
</sonic-list>
|
|
99
|
+
</template>
|
|
100
|
+
</sonic-code>
|
|
101
|
+
|
|
102
|
+
## Special templates : list item separator / empty list view
|
|
103
|
+
|
|
104
|
+
A special template with attribute **data-value="separator"** will act as a separator between each list item
|
|
105
|
+
|
|
106
|
+
<sonic-code>
|
|
107
|
+
<template>
|
|
108
|
+
<sonic-list props='[{"id":"1"},{"id":"2"},{"id":"3"}]' dataProvider="ListSeparatorDemo">
|
|
109
|
+
<template><sonic-value key="id"></sonic-value></template>
|
|
110
|
+
<template data-value="separator"> 🤜 </template>
|
|
111
|
+
</sonic-list>
|
|
112
|
+
</template>
|
|
113
|
+
</sonic-code>
|
|
114
|
+
|
|
115
|
+
The same principle can be used to handle empty lists using a template with attribute **data-value="no-item"**
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
## Fetch
|
|
119
|
+
|
|
120
|
+
Enables the list to get data from an external API in order to fill its **props** attribute with an **array of items**
|
|
121
|
+
See the [Fetch] web component(#core/components/functional/fetch/fetch.md/fetch)
|
|
122
|
+
<sonic-code>
|
|
123
|
+
<template>
|
|
124
|
+
<sonic-list props='["a", "b", "c"]' debug fetch serviceURL="https://reqres.in" dataProvider="api/users" key="data" class="grid grid-cols-1">
|
|
125
|
+
<template>
|
|
126
|
+
<docs-preview-user-item></docs-preview-user-item>
|
|
127
|
+
</template>
|
|
128
|
+
</sonic-list>
|
|
129
|
+
</template>
|
|
130
|
+
</sonic-code>
|
|
131
|
+
|
|
132
|
+
## Extract Values
|
|
133
|
+
|
|
134
|
+
Example of using the `extractValues` attribute with a service.
|
|
135
|
+
As in the previous example, the `fetch` attribute indicates that a service call should be made.
|
|
136
|
+
Note that we use:
|
|
137
|
+
* the property `_metadata_` added by the list component to display the key of the extracted value
|
|
138
|
+
* the special property `_self_` that allows targeting the item itself. This is useful here because there is no sub-property; we are directly dealing with a string.
|
|
139
|
+
<sonic-code>
|
|
140
|
+
<template>
|
|
141
|
+
<sonic-list
|
|
142
|
+
debug
|
|
143
|
+
fetch
|
|
144
|
+
serviceURL="https://reqres.in"
|
|
145
|
+
dataProvider="list-extract-values-test"
|
|
146
|
+
endPoint="api/users/2"
|
|
147
|
+
key="data"
|
|
148
|
+
extractValues
|
|
149
|
+
>
|
|
150
|
+
<template>
|
|
151
|
+
<div class="flex items-center">
|
|
152
|
+
<span data-bind ::inner-html="$_metadata_.key : " class="bold w-24"></span>
|
|
153
|
+
<span data-bind ::inner-html="$_self_"></span>
|
|
154
|
+
<sonic-if data-bind ::condition="|'$_metadata_.key' == 'avatar'">
|
|
155
|
+
<sonic-image data-bind ::src="$_self_" rounded="full" ratio="1/1" class="w-20 block"></sonic-image>
|
|
156
|
+
</sonic-if>
|
|
157
|
+
</div>
|
|
158
|
+
</template>
|
|
159
|
+
</sonic-list>
|
|
160
|
+
</template>
|
|
161
|
+
</sonic-code>
|
|
162
|
+
|
|
163
|
+
## Additionnal tips
|
|
164
|
+
|
|
165
|
+
* If the result of the request is an object, it is nested within an array to ensure functionality.
|
|
166
|
+
* The invalidate() method can be called on its publisher to trigger data reloading.
|
|
167
|
+
* Each list item publisher has a "_parent_" property pointing to the list publisher
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
<!--
|
|
172
|
+
## FormDataProvider
|
|
173
|
+
|
|
174
|
+
<sonic-alert status="error" background>À déplacer dans la bonne doc</sonic-alert>
|
|
175
|
+
|
|
176
|
+
<sonic-code>
|
|
177
|
+
<template>
|
|
178
|
+
<div formDataProvider="profileInfos">
|
|
179
|
+
<form>
|
|
180
|
+
<sonic-fieldset label="Edit profile">
|
|
181
|
+
<sonic-form-layout>
|
|
182
|
+
<sonic-input label="First name" type="text" name="first_name" value="Sponge" size="sm"></sonic-input>
|
|
183
|
+
<sonic-input label="Last name" type="text" name="last_name" value="Bob" size="sm"></sonic-input>
|
|
184
|
+
<sonic-input label="email" type="email" name="email" value="bob@krustykrab.com" size="sm"></sonic-input>
|
|
185
|
+
<sonic-input label="Image url" type="text" name="avatar" value="http://www.bobleponge.fr/goodies/avatars/avatar-bob-eponge_Bob-Eponge-coiffure.jpg" size="sm"></sonic-input>
|
|
186
|
+
</sonic-form-layout>
|
|
187
|
+
</sonic-fieldset>
|
|
188
|
+
</form>
|
|
189
|
+
</div>
|
|
190
|
+
<sonic-card dataProvider="profileInfos">
|
|
191
|
+
<docs-preview-user-item ></docs-preview-user-item>
|
|
192
|
+
</sonic-card>
|
|
193
|
+
</template>
|
|
194
|
+
</sonic-code> -->
|
|
@@ -0,0 +1,236 @@
|
|
|
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 Fetcher from "@supersoniks/concorde/core/mixins/Fetcher";
|
|
5
|
+
import { templateContent } from "lit/directives/template-content.js";
|
|
6
|
+
import "@supersoniks/concorde/core/components/ui/loader/loader";
|
|
7
|
+
import "@supersoniks/concorde/core/components/functional/subscriber/subscriber";
|
|
8
|
+
import Objects from "@supersoniks/concorde/core/utils/Objects";
|
|
9
|
+
import TemplatesContainer from "@supersoniks/concorde/core/mixins/TemplatesContainer";
|
|
10
|
+
import { DirectiveResult } from "lit/directive.js";
|
|
11
|
+
import { TemplateContentDirective } from "lit/directives/template-content.js";
|
|
12
|
+
import { TemplateResult } from "lit";
|
|
13
|
+
import { LoaderMode } from "@supersoniks/concorde/core/components/ui/loader/loader";
|
|
14
|
+
const tagName = "sonic-list";
|
|
15
|
+
/**
|
|
16
|
+
* ### List boucle sur sa propriété "props" et crée des éléments a partir des données en bouclant également sur ses templates.
|
|
17
|
+
*
|
|
18
|
+
* Extends mixins : Fetcher, [Subscriber](./?path=/docs/miscallenous-🔔-subscriber--page)
|
|
19
|
+
*
|
|
20
|
+
* * Si le composant possède un attribut *fetch*, il charge un contenu via un appel d'api web.<br>
|
|
21
|
+
* Voir [fetcher](./?path=/docs/core-components-functional-fetch--basic) pour la configuration des autres attributs.
|
|
22
|
+
* * Chaque élément créé est englobé dans un objet [Subscriber](./?path=/docs/miscallenous-🔔-subscriber--page).<br>
|
|
23
|
+
* Un dataProvider y est associé a l'adresse suivante *dataProvider-de-la-liste$/*index-de-la-ligne-courante*
|
|
24
|
+
* Les données de la ligne sont donc disponible pour les élements internes (subscribers, data-binding)
|
|
25
|
+
* * Lors du chargement un objet loader inline est affiché.
|
|
26
|
+
* * Si le résultat de la requête est un objet, il est imbriqué dans un tableau pour garantir le fonctionnement.<br>
|
|
27
|
+
* Cependant, si l'attribut `extractValues` est présent, les valeurs des propriétés de l'objet sont mises dans dans un tableau pour le rendu.
|
|
28
|
+
* * La propriété _metadata_ est ajoutés à la donnée de chaque item. Elle contient les informations suivantes :
|
|
29
|
+
* * key : l'index de l'item dans la liste
|
|
30
|
+
* * even : true si l'index est pair
|
|
31
|
+
* * odd : true si l'index est impair
|
|
32
|
+
* * onlyChild : true si la liste ne contient qu'un seul item
|
|
33
|
+
* * firstChild : true si l'item est le premier de la liste
|
|
34
|
+
* * lastChild : true si l'item est le dernier de la liste
|
|
35
|
+
* * Si la liste ne contient aucun item, le template "no-item" est utilisé si il est défini.
|
|
36
|
+
* * On peut appler la methode invalidate() sur son publishe pour declencher le rechargement des données
|
|
37
|
+
* *
|
|
38
|
+
*/
|
|
39
|
+
export type ListItemMetadata = {
|
|
40
|
+
key?: string;
|
|
41
|
+
even?: boolean;
|
|
42
|
+
odd?: boolean;
|
|
43
|
+
onlyChild?: boolean;
|
|
44
|
+
firstChild?: boolean;
|
|
45
|
+
lastChild?: boolean;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
@customElement(tagName)
|
|
49
|
+
export class List extends Fetcher(Subscriber(TemplatesContainer(LitElement))) {
|
|
50
|
+
@property({ type: Object }) itemPropertyMap?: object;
|
|
51
|
+
/**
|
|
52
|
+
* La propriété templateKey contient le nom de la propriété qui sera utilisé pour identifier le template à utiliser dans la donnée de la ligne.
|
|
53
|
+
* Par exemple si templateIdentifier = "name" et que la donnée de la ligne est {name: "myTemplate" ... }, alors le template possédant l'attribut data-value="myTemplate" sera utilisé.
|
|
54
|
+
*/
|
|
55
|
+
@property({ type: String }) templateKey = "template";
|
|
56
|
+
/**
|
|
57
|
+
* La propriété idKey est utilisé repérer les lignes de manière unique si pour les item de la liste item[this.idKey] n'existe pas, alors l'index est utilisé
|
|
58
|
+
*/
|
|
59
|
+
@property({ type: String }) idKey = "id";
|
|
60
|
+
|
|
61
|
+
@property() loader?: LoaderMode | true | "";
|
|
62
|
+
|
|
63
|
+
@property() limit = Number.POSITIVE_INFINITY;
|
|
64
|
+
@property() offset = 0;
|
|
65
|
+
|
|
66
|
+
connectedCallback() {
|
|
67
|
+
this.noShadowDom = "";
|
|
68
|
+
this.defferedDebug = this.hasAttribute("debug") || null;
|
|
69
|
+
this.isFetchEnabled = this.hasAttribute("fetch");
|
|
70
|
+
if (this.isFetchEnabled) this.isLoading = true;
|
|
71
|
+
super.connectedCallback();
|
|
72
|
+
}
|
|
73
|
+
disconnectedCallback(): void {
|
|
74
|
+
super.disconnectedCallback();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
renderLoader() {
|
|
78
|
+
if (!(this.isLoading && this.loader !== undefined)) return nothing;
|
|
79
|
+
const template = this.templateParts["skeleton"];
|
|
80
|
+
if (template) return nothing;
|
|
81
|
+
const loader =
|
|
82
|
+
this.loader === true || this.loader === "" ? "fixed" : this.loader;
|
|
83
|
+
return html`<sonic-loader mode=${loader}></sonic-loader>`;
|
|
84
|
+
}
|
|
85
|
+
renderSkeleton() {
|
|
86
|
+
const template = this.templateParts["skeleton"];
|
|
87
|
+
if (!(this.isLoading && template)) return nothing;
|
|
88
|
+
return templateContent(template) as DirectiveResult;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
renderLoadingState():
|
|
92
|
+
| DirectiveResult<typeof TemplateContentDirective>
|
|
93
|
+
| TemplateResult {
|
|
94
|
+
return html`${this.renderSkeleton()} ${this.renderLoader()}`;
|
|
95
|
+
}
|
|
96
|
+
renderNoResultState() {
|
|
97
|
+
return html` <div
|
|
98
|
+
style="color: var(--sc-base-400);
|
|
99
|
+
font-size: 1.5em;
|
|
100
|
+
margin: 4rem 0;
|
|
101
|
+
display: flex;
|
|
102
|
+
gap: 0.5rem;"
|
|
103
|
+
>
|
|
104
|
+
<sonic-icon name="emoji-puzzled" size="lg"></sonic-icon
|
|
105
|
+
><span class="sonic-no-result-text"
|
|
106
|
+
>${typeof this.props === "string" && this.props == ""
|
|
107
|
+
? "Aucun résultat"
|
|
108
|
+
: this.props}</span
|
|
109
|
+
>
|
|
110
|
+
</div>`;
|
|
111
|
+
}
|
|
112
|
+
formatProps() {
|
|
113
|
+
let props = this.props;
|
|
114
|
+
if (props == null) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
const response = props._sonic_http_response_;
|
|
118
|
+
const extractValues = this.hasAttribute("extractValues");
|
|
119
|
+
//si props n'est pas un tableau on l'adapte
|
|
120
|
+
if (!Array.isArray(props)) {
|
|
121
|
+
if (extractValues) {
|
|
122
|
+
props = Object.entries(props).map(([k, v]) => ({ key: k, value: v }));
|
|
123
|
+
} else {
|
|
124
|
+
if (
|
|
125
|
+
Objects.isObject(props) &&
|
|
126
|
+
Object.keys(props).length > 0 &&
|
|
127
|
+
(!response || response.ok)
|
|
128
|
+
)
|
|
129
|
+
props = [props];
|
|
130
|
+
else {
|
|
131
|
+
props = [];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
props = props.filter((e) => e != null);
|
|
136
|
+
if (response) props._sonic_http_response_ = response;
|
|
137
|
+
return props;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
render() {
|
|
141
|
+
/**
|
|
142
|
+
* Loading
|
|
143
|
+
*/
|
|
144
|
+
const isLoadingState = this.isLoading && !Array.isArray(this.props);
|
|
145
|
+
|
|
146
|
+
if (isLoadingState) return this.renderLoadingState();
|
|
147
|
+
/**
|
|
148
|
+
* Si props est une string on considère qu'il n'y a pas de résultats
|
|
149
|
+
*/
|
|
150
|
+
const isString = typeof this.props === "string";
|
|
151
|
+
if (isString) return this.renderNoResultState();
|
|
152
|
+
/**
|
|
153
|
+
* si props mal formé ou null on retourne une div vide (nécessaire pour le lazyload)
|
|
154
|
+
*/
|
|
155
|
+
const propsIsBaddlyFormatted = !Objects.isObject(this.props);
|
|
156
|
+
if (propsIsBaddlyFormatted) return html`<div></div>`;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* On format les props pour les rendre compatibles avec le fonctionnement du rendu en fonction du paramétrage du composant (cf : "extractValues" )
|
|
160
|
+
*/
|
|
161
|
+
|
|
162
|
+
const props = this.formatProps();
|
|
163
|
+
/**
|
|
164
|
+
* On peut définir un template spécifique si le résultat est un tableau vide
|
|
165
|
+
*/
|
|
166
|
+
if ((props?.length || 0) == 0 && this.templateParts["no-item"]) {
|
|
167
|
+
return templateContent(this.templateParts["no-item"]);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Rendu des lignes
|
|
171
|
+
* */
|
|
172
|
+
const templateCount = this.templateList.length;
|
|
173
|
+
let counter = -1;
|
|
174
|
+
const extractValues = this.hasAttribute("extractValues");
|
|
175
|
+
const separator = this.templateParts["separator"];
|
|
176
|
+
const length = props?.length || 0;
|
|
177
|
+
|
|
178
|
+
const items = props?.slice(this.offset, this.offset + this.limit);
|
|
179
|
+
|
|
180
|
+
return html`
|
|
181
|
+
${items?.map((item, index: number) => {
|
|
182
|
+
if (item == null) return nothing;
|
|
183
|
+
let templatePart: HTMLTemplateElement | null = null;
|
|
184
|
+
let key: number | string = index;
|
|
185
|
+
|
|
186
|
+
if (typeof item == "object" && !Array.isArray(item)) {
|
|
187
|
+
const templatePartName = item[this.templateKey];
|
|
188
|
+
if (templatePartName && typeof templatePartName == "string") {
|
|
189
|
+
templatePart = this.templateParts[templatePartName];
|
|
190
|
+
}
|
|
191
|
+
if (extractValues) key = item?.["key"] as number | string;
|
|
192
|
+
}
|
|
193
|
+
if (key == "_sonic_http_response_") return nothing;
|
|
194
|
+
if (typeof key != "string" && typeof key != "number") return nothing;
|
|
195
|
+
const isLastChild = index >= length - 1;
|
|
196
|
+
const indexMod2 = index % 2;
|
|
197
|
+
const childPublisher = this.publisher[key];
|
|
198
|
+
/**
|
|
199
|
+
* Ajout de metatdonnées au publisher de l'enfant
|
|
200
|
+
*/
|
|
201
|
+
//La prop key est gardée pour le moment pour compatibilité
|
|
202
|
+
//TODO : supprimer la prop key cquand c'est ok côté covoit.
|
|
203
|
+
childPublisher._key_ = key + "";
|
|
204
|
+
childPublisher._metadata_ = {
|
|
205
|
+
...childPublisher._metadata_.get(), //Si il y a d'autres données.
|
|
206
|
+
key: key,
|
|
207
|
+
even: indexMod2 == 0,
|
|
208
|
+
odd: indexMod2 == 1,
|
|
209
|
+
onlyChild: length == 1,
|
|
210
|
+
firstChild: index == 0,
|
|
211
|
+
lastChild: isLastChild,
|
|
212
|
+
};
|
|
213
|
+
counter++;
|
|
214
|
+
if (templatePart) counter = -1;
|
|
215
|
+
return (
|
|
216
|
+
item &&
|
|
217
|
+
html`
|
|
218
|
+
<sonic-subscriber
|
|
219
|
+
?debug=${this.defferedDebug === true}
|
|
220
|
+
.bindPublisher=${function () {
|
|
221
|
+
return childPublisher;
|
|
222
|
+
}}
|
|
223
|
+
.propertyMap?=${this.itemPropertyMap}
|
|
224
|
+
dataProvider="${this.dataProvider}/list-item/${key}"
|
|
225
|
+
>
|
|
226
|
+
${templatePart
|
|
227
|
+
? templateContent(templatePart)
|
|
228
|
+
: templateContent(this.templateList[counter % templateCount])}
|
|
229
|
+
</sonic-subscriber>
|
|
230
|
+
${separator && !isLastChild ? templateContent(separator) : nothing}
|
|
231
|
+
`
|
|
232
|
+
);
|
|
233
|
+
})}
|
|
234
|
+
`;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Mix
|
|
2
|
+
|
|
3
|
+
Mix allows you to mix several subsets of dataProvider in a new key/value structure which is itself associated with a new dataProvider. The data update is then bidirectional.
|
|
4
|
+
|
|
5
|
+
Dot notation is supported to extract a sub-part of the data.
|
|
6
|
+
|
|
7
|
+
For example, if we declare dataproviders as follows :
|
|
8
|
+
<sonic-code>
|
|
9
|
+
<template>
|
|
10
|
+
<sonic-subscriber dataProvider="dataToMixA" props='{"foo":{"bar":2}}'></sonic-subscriber>
|
|
11
|
+
<sonic-subscriber dataProvider="dataToMixB" props='{"baz":3}'></sonic-subscriber>
|
|
12
|
+
</template>
|
|
13
|
+
</sonic-code>
|
|
14
|
+
We can rearrange the data as follows
|
|
15
|
+
<sonic-code>
|
|
16
|
+
<template>
|
|
17
|
+
<sonic-mix dataProvider="mixedData" composition='{"either":"dataToMixB","orThat":"dataToMixA.foo.bar"}'>
|
|
18
|
+
<div>Value of dataToMixA.foo.bar and mixedData.orThat : <sonic-value key="orThat"></sonic-value></div>
|
|
19
|
+
<div>Value of dataToMixB.baz and mixedData.either.baz : <sonic-value key="either.baz"></sonic-value></div>
|
|
20
|
+
</sonic-mix>
|
|
21
|
+
</template>
|
|
22
|
+
</sonic-code>
|
|
23
|
+
Then we can change values in both dataProviders programaticaly this way, they will stay in sync
|
|
24
|
+
<sonic-code language="javascript">
|
|
25
|
+
<template>
|
|
26
|
+
SonicPublisherManager.get("mixedData").either.baz=6;
|
|
27
|
+
SonicPublisherManager.get("dataToMixB").baz=8;
|
|
28
|
+
SonicPublisherManager.get("dataToMixA").foo.bar=8;
|
|
29
|
+
SonicPublisherManager.get("mixedData").orThat=6;
|
|
30
|
+
</template>
|
|
31
|
+
</sonic-code>
|
|
32
|
+
Or by using a form element
|
|
33
|
+
<sonic-code>
|
|
34
|
+
<template>
|
|
35
|
+
<sonic-input label="mixedData.orThat" formDataProvider="mixedData" name="orThat"></sonic-input>
|
|
36
|
+
</template>
|
|
37
|
+
</sonic-code>
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|