@supersoniks/concorde 2.0.7 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-infos.json +1 -0
- package/concorde-core.bundle.js +387 -344
- package/concorde-core.es.js +8040 -11093
- package/index.html +44 -0
- package/notes de migration.md +21 -0
- package/package.json +23 -290
- package/scripts/postbuild.mjs +22 -0
- package/scripts/prebuild.mjs +22 -0
- package/{components.js → src/components.ts} +5 -2
- package/src/concorde-loaded.ts +3 -0
- package/src/core/_types/types.ts +55 -0
- package/src/core/components/functional/date/date.md +290 -0
- package/src/core/components/functional/date/date.ts +206 -0
- package/src/core/components/functional/example/example.ts +11 -0
- package/src/core/components/functional/fetch/fetch.md +117 -0
- package/{core/components/functional/fetch/fetch.js → src/core/components/functional/fetch/fetch.ts} +33 -37
- package/src/core/components/functional/if/if.md +16 -0
- package/src/core/components/functional/if/if.test.ts +40 -0
- package/src/core/components/functional/if/if.ts +23 -0
- package/src/core/components/functional/list/list.md +194 -0
- package/src/core/components/functional/list/list.ts +236 -0
- package/src/core/components/functional/mix/mix.md +41 -0
- package/src/core/components/functional/mix/mix.ts +95 -0
- package/src/core/components/functional/queue/queue.md +87 -0
- package/src/core/components/functional/queue/queue.ts +279 -0
- package/src/core/components/functional/router/redirect.ts +44 -0
- package/src/core/components/functional/router/router.md +112 -0
- package/src/core/components/functional/router/router.ts +108 -0
- package/src/core/components/functional/sdui/SDUIDescriptorTransformer.ts +229 -0
- package/{core → src/core}/components/functional/sdui/default-library.json +13 -13
- package/src/core/components/functional/sdui/example.json +99 -0
- package/src/core/components/functional/sdui/sdui-utils.ts +62 -0
- package/src/core/components/functional/sdui/sdui.md +356 -0
- package/src/core/components/functional/sdui/sdui.ts +230 -0
- package/src/core/components/functional/sdui/types.ts +34 -0
- package/src/core/components/functional/sonic-scope/sonic-scope.ts +13 -0
- package/src/core/components/functional/states/states.md +87 -0
- package/src/core/components/functional/states/states.ts +121 -0
- package/src/core/components/functional/submit/submit.md +48 -0
- package/src/core/components/functional/submit/submit.ts +265 -0
- package/src/core/components/functional/subscriber/subscriber.md +91 -0
- package/src/core/components/functional/subscriber/subscriber.ts +28 -0
- package/src/core/components/functional/value/value.md +35 -0
- package/src/core/components/functional/value/value.ts +18 -0
- package/{core/components/ui/_css/scroll.js → src/core/components/ui/_css/scroll.ts} +3 -2
- package/{core/components/ui/_css/size.js → src/core/components/ui/_css/size.ts} +5 -2
- package/{core/components/ui/_css/type.js → src/core/components/ui/_css/type.ts} +5 -3
- package/src/core/components/ui/alert/alert.md +121 -0
- package/src/core/components/ui/alert/alert.ts +177 -0
- package/src/core/components/ui/badge/badge.md +102 -0
- package/{core/components/ui/badge/badge.js → src/core/components/ui/badge/badge.ts} +36 -51
- package/src/core/components/ui/button/button.md +184 -0
- package/{core/components/ui/button/button.js → src/core/components/ui/button/button.ts} +258 -302
- package/src/core/components/ui/captcha/captcha.md +12 -0
- package/src/core/components/ui/captcha/captcha.ts +88 -0
- package/src/core/components/ui/card/card-footer.ts +19 -0
- package/src/core/components/ui/card/card-header-descripton.ts +24 -0
- package/{core/components/ui/card/card-header.js → src/core/components/ui/card/card-header.ts} +28 -38
- package/src/core/components/ui/card/card-main.ts +24 -0
- package/src/core/components/ui/card/card.md +96 -0
- package/{core/components/ui/card/card.js → src/core/components/ui/card/card.ts} +23 -34
- package/src/core/components/ui/divider/divider.md +35 -0
- package/{core/components/ui/divider/divider.js → src/core/components/ui/divider/divider.ts} +35 -65
- package/src/core/components/ui/form/checkbox/checkbox.md +96 -0
- package/{core/components/ui/form/checkbox/checkbox.js → src/core/components/ui/form/checkbox/checkbox.ts} +79 -98
- package/{core/components/ui/form/css/form-control.js → src/core/components/ui/form/css/form-control.ts} +9 -5
- package/src/core/components/ui/form/fieldset/fieldset.md +129 -0
- package/src/core/components/ui/form/fieldset/fieldset.ts +96 -0
- package/src/core/components/ui/form/fieldset/legend-description.ts +23 -0
- package/src/core/components/ui/form/fieldset/legend.ts +90 -0
- package/src/core/components/ui/form/form-actions/form-actions.md +77 -0
- package/src/core/components/ui/form/form-actions/form-actions.ts +32 -0
- package/src/core/components/ui/form/form-layout/form-layout.md +43 -0
- package/src/core/components/ui/form/form-layout/form-layout.ts +71 -0
- package/src/core/components/ui/form/input/input.md +168 -0
- package/src/core/components/ui/form/input/input.ts +227 -0
- package/src/core/components/ui/form/input/password-helper.ts +68 -0
- package/src/core/components/ui/form/input/same-value-helper.ts +48 -0
- package/src/core/components/ui/form/input-autocomplete/input-autocomplete.md +130 -0
- package/src/core/components/ui/form/input-autocomplete/input-autocomplete.ts +285 -0
- package/src/core/components/ui/form/radio/radio.md +86 -0
- package/src/core/components/ui/form/radio/radio.ts +44 -0
- package/src/core/components/ui/form/select/select.md +99 -0
- package/src/core/components/ui/form/select/select.ts +310 -0
- package/src/core/components/ui/form/textarea/textarea.md +66 -0
- package/src/core/components/ui/form/textarea/textarea.ts +119 -0
- package/src/core/components/ui/group/group.md +75 -0
- package/src/core/components/ui/group/group.ts +101 -0
- package/src/core/components/ui/icon/icon.md +125 -0
- package/src/core/components/ui/icon/icon.stories.ts +100 -0
- package/src/core/components/ui/icon/icon.ts +106 -0
- package/src/core/components/ui/icon/icons.json +1 -0
- package/src/core/components/ui/icon/icons.ts +130 -0
- package/src/core/components/ui/icon/svgs/cancel.svg +3 -0
- package/src/core/components/ui/icon/svgs/check-circled-outline.svg +4 -0
- package/src/core/components/ui/icon/svgs/check.svg +3 -0
- package/src/core/components/ui/icon/svgs/emoji-puzzled.svg +1 -0
- package/src/core/components/ui/icon/svgs/info-empty.svg +5 -0
- package/src/core/components/ui/icon/svgs/loader.svg +1 -0
- package/src/core/components/ui/icon/svgs/minus-small.svg +3 -0
- package/src/core/components/ui/icon/svgs/more-horiz.svg +5 -0
- package/src/core/components/ui/icon/svgs/more-vert.svg +5 -0
- package/src/core/components/ui/icon/svgs/nav-arrow-down.svg +3 -0
- package/src/core/components/ui/icon/svgs/warning-circled-outline.svg +5 -0
- package/src/core/components/ui/image/image.md +107 -0
- package/src/core/components/ui/image/image.ts +117 -0
- package/src/core/components/ui/link/link.md +43 -0
- package/src/core/components/ui/link/link.ts +108 -0
- package/src/core/components/ui/loader/loader.md +37 -0
- package/src/core/components/ui/loader/loader.stories.ts +25 -0
- package/src/core/components/ui/loader/loader.ts +81 -0
- package/{core/components/ui/loader/styles/fixed.js → src/core/components/ui/loader/styles/fixed.ts} +2 -1
- package/{core/components/ui/loader/styles/inline.js → src/core/components/ui/loader/styles/inline.ts} +3 -2
- package/src/core/components/ui/menu/menu-item.ts +30 -0
- package/src/core/components/ui/menu/menu.md +288 -0
- package/src/core/components/ui/menu/menu.ts +292 -0
- package/src/core/components/ui/modal/modal-actions.ts +35 -0
- package/src/core/components/ui/modal/modal-close.ts +36 -0
- package/src/core/components/ui/modal/modal-content.ts +19 -0
- package/src/core/components/ui/modal/modal-subtitle.ts +23 -0
- package/src/core/components/ui/modal/modal-title.ts +22 -0
- package/src/core/components/ui/modal/modal.md +123 -0
- package/src/core/components/ui/modal/modal.stories.ts +140 -0
- package/src/core/components/ui/modal/modal.ts +386 -0
- package/src/core/components/ui/pop/pop.md +79 -0
- package/src/core/components/ui/pop/pop.ts +291 -0
- package/src/core/components/ui/progress/progress.md +65 -0
- package/{core/components/ui/progress/progress.js → src/core/components/ui/progress/progress.ts} +31 -50
- package/src/core/components/ui/table/table-caption.ts +21 -0
- package/src/core/components/ui/table/table-tbody.ts +32 -0
- package/src/core/components/ui/table/table-td.ts +47 -0
- package/src/core/components/ui/table/table-tfoot.ts +20 -0
- package/src/core/components/ui/table/table-th.ts +56 -0
- package/src/core/components/ui/table/table-thead.ts +18 -0
- package/src/core/components/ui/table/table-tr.ts +48 -0
- package/src/core/components/ui/table/table.md +467 -0
- package/{core/components/ui/table/table.js → src/core/components/ui/table/table.ts} +32 -53
- package/{core/components/ui/theme/theme-collection/core-variables.js → src/core/components/ui/theme/theme-collection/core-variables.ts} +3 -2
- package/{core/components/ui/theme/theme-collection/dark.js → src/core/components/ui/theme/theme-collection/dark.ts} +5 -3
- package/{core/components/ui/theme/theme-collection/light.js → src/core/components/ui/theme/theme-collection/light.ts} +3 -2
- package/src/core/components/ui/theme/theme.ts +118 -0
- package/src/core/components/ui/toast/message-subscriber.stories.ts +43 -0
- package/src/core/components/ui/toast/message-subscriber.ts +37 -0
- package/{core/components/ui/toast/toast-item.js → src/core/components/ui/toast/toast-item.ts} +86 -113
- package/src/core/components/ui/toast/toast.ts +237 -0
- package/src/core/components/ui/toast/types.ts +14 -0
- package/src/core/components/ui/tooltip/tooltip.md +37 -0
- package/{core/components/ui/tooltip/tooltip.js → src/core/components/ui/tooltip/tooltip.ts} +26 -47
- package/{core/components/ui/ui.js → src/core/components/ui/ui.ts} +2 -0
- package/src/core/core.ts +22 -0
- package/src/core/decorators/Subscriber.ts +187 -0
- package/src/core/directives/DataProvider.ts +113 -0
- package/src/core/directives/Wording.ts +220 -0
- package/src/core/mixins/Fetcher.ts +258 -0
- package/src/core/mixins/FormCheckable.ts +287 -0
- package/src/core/mixins/FormElement.ts +275 -0
- package/src/core/mixins/FormInput.ts +135 -0
- package/src/core/mixins/Subscriber.ts +352 -0
- package/src/core/mixins/TemplatesContainer.ts +70 -0
- package/{core/mixins/mixins.d.ts → src/core/mixins/mixins.ts} +1 -1
- package/src/core/utils/Arrays.ts +161 -0
- package/src/core/utils/DataBindObserver.ts +286 -0
- package/src/core/utils/Electron.ts +15 -0
- package/src/core/utils/Format.ts +58 -0
- package/src/core/utils/HTML.ts +126 -0
- package/src/core/utils/LocationHandler.ts +139 -0
- package/src/core/utils/Objects.ts +103 -0
- package/src/core/utils/PublisherProxy.ts +786 -0
- package/src/core/utils/Utils.ts +12 -0
- package/src/core/utils/api.ts +456 -0
- package/{core/utils/url-pattern.d.ts → src/core/utils/url-pattern.ts} +1 -0
- package/{decorators.js → src/decorators.ts} +6 -2
- package/{directives.js → src/directives.ts} +11 -6
- package/src/docs/_core-concept/overview.md +57 -0
- package/src/docs/_core-concept/subscriber.md +76 -0
- package/src/docs/_getting-started/concorde-outside.md +141 -0
- package/src/docs/_getting-started/create-a-component.md +137 -0
- package/src/docs/_getting-started/pubsub.md +150 -0
- package/src/docs/_getting-started/start.md +37 -0
- package/src/docs/_getting-started/theming.md +91 -0
- package/src/docs/code.ts +281 -0
- package/src/docs/docs.ts +6 -0
- package/src/docs/example/users.ts +64 -0
- package/src/docs/navigation/navigation.ts +101 -0
- package/src/docs/prism/index.ts +6 -0
- package/src/docs/prism/prism.css +158 -0
- package/src/docs/prism/prism.js +1022 -0
- package/src/docs/search/docs-search.json +3767 -0
- package/src/docs/search/markdown-renderer.ts +40 -0
- package/src/docs/search/page.ts +40 -0
- package/src/docs/search/search.ts +184 -0
- package/src/docs.ts +2 -0
- package/src/index.ts +7 -0
- package/{mixins.js → src/mixins.ts} +10 -6
- package/src/tag-list.json +1 -0
- package/src/test-utils/TestUtils.ts +13 -0
- package/src/tsconfig.json +113 -0
- package/{utils.js → src/utils.ts} +15 -11
- package/test-utils/TestUtils.ts +13 -0
- package/vite/config.js +136 -0
- package/vite.config.mts +87 -0
- package/README.md +0 -27
- package/cli.js +0 -75
- package/components.d.ts +0 -4
- package/core/_types/types.d.ts +0 -28
- package/core/_types/types.js +0 -2
- package/core/components/functional/date/date.d.ts +0 -45
- package/core/components/functional/date/date.js +0 -243
- package/core/components/functional/example/example.d.ts +0 -7
- package/core/components/functional/example/example.js +0 -26
- package/core/components/functional/fetch/fetch.d.ts +0 -93
- package/core/components/functional/functional.js +0 -15
- package/core/components/functional/if/if.d.ts +0 -12
- package/core/components/functional/if/if.js +0 -38
- package/core/components/functional/if/if.test.d.ts +0 -1
- package/core/components/functional/if/if.test.js +0 -35
- package/core/components/functional/list/list.d.ts +0 -117
- package/core/components/functional/list/list.js +0 -214
- package/core/components/functional/mix/mix.d.ts +0 -22
- package/core/components/functional/mix/mix.js +0 -102
- package/core/components/functional/queue/queue.d.ts +0 -67
- package/core/components/functional/queue/queue.js +0 -310
- package/core/components/functional/router/redirect.d.ts +0 -18
- package/core/components/functional/router/redirect.js +0 -53
- package/core/components/functional/router/router.d.ts +0 -27
- package/core/components/functional/router/router.js +0 -119
- package/core/components/functional/sdui/SDUIDescriptorTransformer.d.ts +0 -58
- package/core/components/functional/sdui/SDUIDescriptorTransformer.js +0 -215
- package/core/components/functional/sdui/sdui-utils.d.ts +0 -5
- package/core/components/functional/sdui/sdui-utils.js +0 -63
- package/core/components/functional/sdui/sdui.d.ts +0 -136
- package/core/components/functional/sdui/sdui.js +0 -254
- package/core/components/functional/sdui/types.d.ts +0 -37
- package/core/components/functional/sdui/types.js +0 -1
- package/core/components/functional/sonic-scope/sonic-scope.d.ts +0 -5
- package/core/components/functional/sonic-scope/sonic-scope.js +0 -21
- package/core/components/functional/states/states.d.ts +0 -29
- package/core/components/functional/states/states.js +0 -134
- package/core/components/functional/submit/submit.d.ts +0 -30
- package/core/components/functional/submit/submit.js +0 -236
- package/core/components/functional/subscriber/subscriber.d.ts +0 -12
- package/core/components/functional/subscriber/subscriber.js +0 -38
- package/core/components/functional/value/value.d.ts +0 -7
- package/core/components/functional/value/value.js +0 -27
- package/core/components/ui/_css/scroll.d.ts +0 -1
- package/core/components/ui/_css/size.d.ts +0 -2
- package/core/components/ui/_css/type.d.ts +0 -2
- package/core/components/ui/alert/alert.d.ts +0 -34
- package/core/components/ui/alert/alert.js +0 -202
- package/core/components/ui/badge/badge.d.ts +0 -26
- package/core/components/ui/button/button.d.ts +0 -171
- package/core/components/ui/captcha/captcha.d.ts +0 -30
- package/core/components/ui/captcha/captcha.js +0 -93
- package/core/components/ui/card/card-footer.d.ts +0 -4
- package/core/components/ui/card/card-footer.js +0 -24
- package/core/components/ui/card/card-header-descripton.d.ts +0 -5
- package/core/components/ui/card/card-header-descripton.js +0 -32
- package/core/components/ui/card/card-header.d.ts +0 -8
- package/core/components/ui/card/card-main.d.ts +0 -4
- package/core/components/ui/card/card-main.js +0 -28
- package/core/components/ui/card/card.d.ts +0 -12
- package/core/components/ui/divider/divider.d.ts +0 -15
- package/core/components/ui/form/checkbox/checkbox.d.ts +0 -181
- package/core/components/ui/form/css/form-control.d.ts +0 -4
- package/core/components/ui/form/fieldset/fieldset.d.ts +0 -23
- package/core/components/ui/form/fieldset/fieldset.js +0 -118
- package/core/components/ui/form/fieldset/legend-description.d.ts +0 -5
- package/core/components/ui/form/fieldset/legend-description.js +0 -30
- package/core/components/ui/form/fieldset/legend.d.ts +0 -16
- package/core/components/ui/form/fieldset/legend.js +0 -112
- package/core/components/ui/form/form-actions/form-actions.d.ts +0 -7
- package/core/components/ui/form/form-actions/form-actions.js +0 -46
- package/core/components/ui/form/form-layout/form-layout.d.ts +0 -12
- package/core/components/ui/form/form-layout/form-layout.js +0 -83
- package/core/components/ui/form/input/input.d.ts +0 -106
- package/core/components/ui/form/input/input.js +0 -268
- package/core/components/ui/form/input/password-helper.d.ts +0 -25
- package/core/components/ui/form/input/password-helper.js +0 -119
- package/core/components/ui/form/input/same-value-helper.d.ts +0 -16
- package/core/components/ui/form/input/same-value-helper.js +0 -77
- package/core/components/ui/form/input-autocomplete/input-autocomplete.d.ts +0 -136
- package/core/components/ui/form/input-autocomplete/input-autocomplete.js +0 -296
- package/core/components/ui/form/radio/radio.d.ts +0 -12
- package/core/components/ui/form/radio/radio.js +0 -50
- package/core/components/ui/form/select/select.d.ts +0 -58
- package/core/components/ui/form/select/select.js +0 -298
- package/core/components/ui/form/textarea/textarea.d.ts +0 -84
- package/core/components/ui/form/textarea/textarea.js +0 -150
- package/core/components/ui/group/group.d.ts +0 -16
- package/core/components/ui/group/group.js +0 -118
- package/core/components/ui/icon/icon.d.ts +0 -26
- package/core/components/ui/icon/icon.js +0 -113
- package/core/components/ui/icon/icons.d.ts +0 -10
- package/core/components/ui/icon/icons.js +0 -126
- package/core/components/ui/icon/icons.json +0 -1
- package/core/components/ui/image/image.d.ts +0 -15
- package/core/components/ui/image/image.js +0 -153
- package/core/components/ui/link/link.d.ts +0 -29
- package/core/components/ui/link/link.js +0 -124
- package/core/components/ui/loader/loader.d.ts +0 -23
- package/core/components/ui/loader/loader.js +0 -97
- package/core/components/ui/loader/styles/fixed.d.ts +0 -1
- package/core/components/ui/loader/styles/inline.d.ts +0 -1
- package/core/components/ui/menu/menu-item.d.ts +0 -5
- package/core/components/ui/menu/menu-item.js +0 -34
- package/core/components/ui/menu/menu.d.ts +0 -41
- package/core/components/ui/menu/menu.js +0 -313
- package/core/components/ui/modal/modal-actions.d.ts +0 -7
- package/core/components/ui/modal/modal-actions.js +0 -42
- package/core/components/ui/modal/modal-close.d.ts +0 -7
- package/core/components/ui/modal/modal-close.js +0 -43
- package/core/components/ui/modal/modal-content.d.ts +0 -5
- package/core/components/ui/modal/modal-content.js +0 -26
- package/core/components/ui/modal/modal-subtitle.d.ts +0 -5
- package/core/components/ui/modal/modal-subtitle.js +0 -30
- package/core/components/ui/modal/modal-title.d.ts +0 -5
- package/core/components/ui/modal/modal-title.js +0 -29
- package/core/components/ui/modal/modal.d.ts +0 -58
- package/core/components/ui/modal/modal.js +0 -401
- package/core/components/ui/pop/pop.d.ts +0 -37
- package/core/components/ui/pop/pop.js +0 -299
- package/core/components/ui/progress/progress.d.ts +0 -10
- package/core/components/ui/table/table-caption.d.ts +0 -5
- package/core/components/ui/table/table-caption.js +0 -28
- package/core/components/ui/table/table-tbody.d.ts +0 -5
- package/core/components/ui/table/table-tbody.js +0 -39
- package/core/components/ui/table/table-td.d.ts +0 -12
- package/core/components/ui/table/table-td.js +0 -68
- package/core/components/ui/table/table-tfoot.d.ts +0 -5
- package/core/components/ui/table/table-tfoot.js +0 -27
- package/core/components/ui/table/table-th.d.ts +0 -11
- package/core/components/ui/table/table-th.js +0 -73
- package/core/components/ui/table/table-thead.d.ts +0 -5
- package/core/components/ui/table/table-thead.js +0 -25
- package/core/components/ui/table/table-tr.d.ts +0 -13
- package/core/components/ui/table/table-tr.js +0 -66
- package/core/components/ui/table/table.d.ts +0 -17
- package/core/components/ui/theme/theme-collection/core-variables.d.ts +0 -1
- package/core/components/ui/theme/theme-collection/dark.d.ts +0 -1
- package/core/components/ui/theme/theme-collection/light.d.ts +0 -1
- package/core/components/ui/theme/theme.d.ts +0 -19
- package/core/components/ui/theme/theme.js +0 -124
- package/core/components/ui/toast/message-subscriber.d.ts +0 -18
- package/core/components/ui/toast/message-subscriber.js +0 -40
- package/core/components/ui/toast/toast-item.d.ts +0 -19
- package/core/components/ui/toast/toast.d.ts +0 -25
- package/core/components/ui/toast/toast.js +0 -226
- package/core/components/ui/toast/types.d.ts +0 -11
- package/core/components/ui/toast/types.js +0 -1
- package/core/components/ui/tooltip/tooltip.d.ts +0 -10
- package/core/components/ui/ui.d.ts +0 -32
- package/core/core.d.ts +0 -4
- package/core/core.js +0 -19
- package/core/decorators/Subscriber.d.ts +0 -4
- package/core/decorators/Subscriber.js +0 -166
- package/core/directives/DataProvider.d.ts +0 -23
- package/core/directives/DataProvider.js +0 -102
- package/core/directives/Wording.d.ts +0 -42
- package/core/directives/Wording.js +0 -202
- package/core/mixins/Fetcher.d.ts +0 -90
- package/core/mixins/Fetcher.js +0 -242
- package/core/mixins/FormCheckable.d.ts +0 -88
- package/core/mixins/FormCheckable.js +0 -306
- package/core/mixins/FormElement.d.ts +0 -32
- package/core/mixins/FormElement.js +0 -272
- package/core/mixins/FormInput.d.ts +0 -70
- package/core/mixins/FormInput.js +0 -81
- package/core/mixins/Subscriber.d.ts +0 -36
- package/core/mixins/Subscriber.js +0 -333
- package/core/mixins/TemplatesContainer.d.ts +0 -13
- package/core/mixins/TemplatesContainer.js +0 -69
- package/core/mixins/mixins.js +0 -6
- package/core/utils/Arrays.d.ts +0 -97
- package/core/utils/Arrays.js +0 -140
- package/core/utils/DataBindObserver.d.ts +0 -83
- package/core/utils/DataBindObserver.js +0 -264
- package/core/utils/Electron.d.ts +0 -7
- package/core/utils/Electron.js +0 -11
- package/core/utils/Format.d.ts +0 -12
- package/core/utils/Format.js +0 -38
- package/core/utils/HTML.d.ts +0 -42
- package/core/utils/HTML.js +0 -119
- package/core/utils/LocationHandler.d.ts +0 -46
- package/core/utils/LocationHandler.js +0 -133
- package/core/utils/Objects.d.ts +0 -28
- package/core/utils/Objects.js +0 -102
- package/core/utils/PublisherProxy.d.ts +0 -176
- package/core/utils/PublisherProxy.js +0 -709
- package/core/utils/Utils.d.ts +0 -4
- package/core/utils/Utils.js +0 -12
- package/core/utils/api.d.ts +0 -139
- package/core/utils/api.js +0 -391
- package/core/utils/url-pattern.js +0 -2
- package/decorators.d.ts +0 -3
- package/directives.d.ts +0 -40
- package/img/concorde-logo.svg +0 -1
- package/img/concorde.png +0 -0
- package/img/concorde_def.png +0 -0
- package/mixins.d.ts +0 -181
- package/svg/regular/plane.svg +0 -1
- package/svg/solid/plane.svg +0 -1
- package/test-utils/TestUtils.d.ts +0 -4
- package/test-utils/TestUtils.js +0 -12
- package/utils.d.ts +0 -20
- /package/{core/components/functional/functional.d.ts → src/core/components/functional/functional.ts} +0 -0
- /package/{core → src/core}/components/ui/theme/css/tailwind.css +0 -0
- /package/{core → src/core}/components/ui/theme/css/tailwind.d.ts +0 -0
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import {APIConfiguration} from "@supersoniks/concorde/core/utils/api";
|
|
2
|
+
import DataBindObserver from "@supersoniks/concorde/core/utils/DataBindObserver";
|
|
3
|
+
import HTML from "@supersoniks/concorde/core/utils/HTML";
|
|
4
|
+
import Objects from "@supersoniks/concorde/core/utils/Objects";
|
|
5
|
+
import {PublisherManager} from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
6
|
+
import {LitElement, PropertyValues} from "lit";
|
|
7
|
+
import {property} from "lit/decorators.js";
|
|
8
|
+
import WordingDirective from "../directives/Wording";
|
|
9
|
+
import {PublisherInterface, TypeAndRecordOfType, ConcordeWindow, MixinArgsType, CoreJSType} from "@supersoniks/concorde/core/_types/types";
|
|
10
|
+
declare const window: ConcordeWindow;
|
|
11
|
+
type Constructor<T> = new (...args: MixinArgsType[]) => T;
|
|
12
|
+
let keepDebugOnMouseOut = false;
|
|
13
|
+
let debugs = new Set<HTMLElement>();
|
|
14
|
+
export interface SubscriberInterface<PropsType = CoreJSType> {
|
|
15
|
+
props: PropsType | null;
|
|
16
|
+
propertyMap: object;
|
|
17
|
+
isConnected: boolean;
|
|
18
|
+
children: HTMLCollection;
|
|
19
|
+
appendChild(node: Node): Node;
|
|
20
|
+
getAncestorAttributeValue(attributeName: string): string;
|
|
21
|
+
hasAncestorAttribute(attributeName: string): boolean;
|
|
22
|
+
querySelectorAll(selector: string): NodeListOf<Element>;
|
|
23
|
+
publisher: TypeAndRecordOfType<PublisherInterface<PropsType>>;
|
|
24
|
+
dataProvider: string | null;
|
|
25
|
+
noShadowDom: string | null;
|
|
26
|
+
debug: HTMLElement | null;
|
|
27
|
+
defferedDebug: boolean | null;
|
|
28
|
+
displayContents: boolean;
|
|
29
|
+
shadowRoot?: ShadowRoot;
|
|
30
|
+
dispatchEvent(event: Event): void;
|
|
31
|
+
setAttribute(name: string, value: string): void;
|
|
32
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
33
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
34
|
+
removeAttribute(name: string): void;
|
|
35
|
+
initPublisher(): void;
|
|
36
|
+
getApiConfiguration(): APIConfiguration;
|
|
37
|
+
connectedCallback(): void;
|
|
38
|
+
requestUpdate(): void;
|
|
39
|
+
getAttribute(name: string): string;
|
|
40
|
+
hasAttribute(attributeName: string): boolean;
|
|
41
|
+
disconnectedCallback(): void;
|
|
42
|
+
getBoundingClientRect(): DOMRect;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const Subscriber = <PropsType = CoreJSType, T extends Constructor<LitElement> = Constructor<LitElement>>(
|
|
46
|
+
superClass: T,
|
|
47
|
+
type?: PropsType
|
|
48
|
+
) => {
|
|
49
|
+
/**
|
|
50
|
+
* La mixin Subscriber permet lier un composant à un publisher.
|
|
51
|
+
* La liaison à un publisher se fait via l'attribut *dataProvider* du composant qui représente ce que l'on obtient en appellant PublisherManager.get(dataProvider).
|
|
52
|
+
* les propriétés du composant sont automatiquement remplies avec les propriétés du même nom dans les données du publisher.
|
|
53
|
+
* Le composant est automatiquement mis à jour lorsque les données du publisher sont mises à jour.
|
|
54
|
+
*/
|
|
55
|
+
type;
|
|
56
|
+
class SubscriberElement extends superClass {
|
|
57
|
+
static instanceCounter = 0;
|
|
58
|
+
|
|
59
|
+
publisher?: TypeAndRecordOfType<PublisherInterface<PropsType>>;
|
|
60
|
+
constructor(...args: MixinArgsType[]) {
|
|
61
|
+
super();
|
|
62
|
+
args;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@property({type: Number}) collectDependenciesVersion = 0;
|
|
66
|
+
|
|
67
|
+
@property({type: Boolean}) displayContents = false;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* noAutoFill permet de désactiver le remplissage automatique des propriétés par le publisher dans le cas ou on utilise "props" seulement ou le dataBinding par exemple
|
|
71
|
+
*/
|
|
72
|
+
@property({type: Boolean}) noAutoFill = false;
|
|
73
|
+
|
|
74
|
+
@property({type: Boolean}) forceAutoFill = false;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Passer ce paramètre à true permet de ne pas mettre à jour le composant lors d'un changement de interne de la propriété nommé props.
|
|
78
|
+
*/
|
|
79
|
+
renderOnPropsInternalChange = false;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Par défaut on chée un shadow dom mais on peut demander à ne pas en avoir via cette propriété et un attribut associé.
|
|
83
|
+
* Cela se fait à l'initialisation uniquement et n'est pas modifiable lors de la vie du composant.
|
|
84
|
+
*/
|
|
85
|
+
noShadowDom: string | null = null;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Permet de mapper un nom de propriété de donnée source vars une propriété du subscriber à la volée
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
@property({type: Object}) propertyMap: object | null = null;
|
|
92
|
+
@property({type: String, attribute: "data-title"}) title = "";
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* va de parent en parent pour trouver un attribut
|
|
96
|
+
* @param attributeName nom de l'attribut
|
|
97
|
+
* @returns true si l'attribut est trouvé
|
|
98
|
+
*/
|
|
99
|
+
hasAncestorAttribute(attributeName: string) {
|
|
100
|
+
return this.getAncestorAttributeValue(attributeName) != null;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Va de parent en parent pour trouver un attribut
|
|
104
|
+
* @param attributeName nom de l'attribut
|
|
105
|
+
* @returns valeur de l'attribut ou null si l'attribut n'est pas trouvé
|
|
106
|
+
*/
|
|
107
|
+
getAncestorAttributeValue(attributeName: string) {
|
|
108
|
+
return HTML.getAncestorAttributeValue(this, attributeName);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* L'id / l'adresse du publisher accessible via PublisherManager.get(dataProvider)
|
|
113
|
+
*/
|
|
114
|
+
@property({reflect: true}) dataProvider: string | null = null;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* On peut utiliser cette fonction pour lier un publisher spécifique au composant si besoin.
|
|
118
|
+
* voir l'utilisation dans list.ts
|
|
119
|
+
*/
|
|
120
|
+
@property() bindPublisher: (() => PublisherInterface<PropsType>) | null = null;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Les props du composant.
|
|
124
|
+
* Elles sont injectées en profondeur dans le publisher pour permettre la mutualisation des données entre les composants.
|
|
125
|
+
* Par conséquent l'assignation de ces propriété avec une chaine json (html classic), ou un objet / un tableaun remplie les données du publisher.
|
|
126
|
+
* Les propriétés des subscribers associés au même dataProvider sont donc "remplies" avec ces données, voir aussi le dataBinding à ce sujet.
|
|
127
|
+
*/
|
|
128
|
+
protected _props: PropsType | null = null;
|
|
129
|
+
@property() get props() {
|
|
130
|
+
if (this._props !== null || !this.publisher) return this._props;
|
|
131
|
+
return this.publisher.get();
|
|
132
|
+
}
|
|
133
|
+
set props(value) {
|
|
134
|
+
if (typeof value == "string" && ["{", "["].includes(value.trim().charAt(0))) {
|
|
135
|
+
value = JSON.parse(value);
|
|
136
|
+
}
|
|
137
|
+
if (value == this._props) return;
|
|
138
|
+
|
|
139
|
+
this._props = value;
|
|
140
|
+
|
|
141
|
+
// if (!this.publisher) this.initPublisher();
|
|
142
|
+
|
|
143
|
+
if (this.publisher && this.publisher.get() != value) {
|
|
144
|
+
this.publisher.set(value);
|
|
145
|
+
}
|
|
146
|
+
this.requestUpdate();
|
|
147
|
+
}
|
|
148
|
+
protected updated(_changedProperties: PropertyValues): void {
|
|
149
|
+
super.updated(_changedProperties);
|
|
150
|
+
const ref = this.shadowRoot || this;
|
|
151
|
+
const children = [...ref.children].filter((child) => child.tagName != "STYLE");
|
|
152
|
+
const display = this.displayContents ? "contents" : children.length == 0 ? "none" : null;
|
|
153
|
+
if (display) this.style.display = display;
|
|
154
|
+
else this.style.removeProperty("display");
|
|
155
|
+
}
|
|
156
|
+
connectedCallback() {
|
|
157
|
+
SubscriberElement.instanceCounter++;
|
|
158
|
+
if (this.hasAttribute("lazyRendering")) {
|
|
159
|
+
const options: IntersectionObserverInit = {
|
|
160
|
+
root: null,
|
|
161
|
+
// rootMargin: Math.max(window.innerWidth, window.innerHeight) + "px",
|
|
162
|
+
threshold: 0.9,
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
let firstView = true;
|
|
166
|
+
const iObserver = new IntersectionObserver((entries) => {
|
|
167
|
+
for (const e of entries) {
|
|
168
|
+
if (firstView && e.isIntersecting) {
|
|
169
|
+
this.addDebugger();
|
|
170
|
+
firstView = false;
|
|
171
|
+
this.initWording();
|
|
172
|
+
this.initPublisher();
|
|
173
|
+
iObserver.disconnect();
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}, options);
|
|
178
|
+
iObserver.observe(this);
|
|
179
|
+
} else {
|
|
180
|
+
this.initWording();
|
|
181
|
+
this.initPublisher();
|
|
182
|
+
this.addDebugger();
|
|
183
|
+
}
|
|
184
|
+
super.connectedCallback();
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
disconnectedCallback() {
|
|
188
|
+
this.removeDebugger();
|
|
189
|
+
super.disconnectedCallback();
|
|
190
|
+
if (this.publisher) {
|
|
191
|
+
this.publisher.stopTemplateFilling(this);
|
|
192
|
+
this.publisher.offInternalMutation(this.requestUpdate);
|
|
193
|
+
}
|
|
194
|
+
WordingDirective.publisher.stopTemplateFilling(this);
|
|
195
|
+
if (this.onAssign) this.publisher?.offAssign(this.onAssign);
|
|
196
|
+
}
|
|
197
|
+
defferedDebug: true | null = null;
|
|
198
|
+
/**
|
|
199
|
+
* Ajoute un debugger au composant pour afficher en temps réel les données présentes dans sont publisher
|
|
200
|
+
*/
|
|
201
|
+
debug: HTMLElement | null = null;
|
|
202
|
+
addDebugger() {
|
|
203
|
+
if (this.hasAttribute("debug") && !this.defferedDebug) {
|
|
204
|
+
if (!this.debug) {
|
|
205
|
+
this.debug = document.createElement("div");
|
|
206
|
+
const style = this.debug.style;
|
|
207
|
+
style.position = "fixed";
|
|
208
|
+
style.top = "0";
|
|
209
|
+
style.right = "0";
|
|
210
|
+
style.margin = "auto";
|
|
211
|
+
style.borderRadius = ".7rem";
|
|
212
|
+
style.backgroundColor = "#0f1729";
|
|
213
|
+
style.color = "#c5d4f9";
|
|
214
|
+
style.padding = "16px 16px";
|
|
215
|
+
style.margin = "16px 16px";
|
|
216
|
+
style.boxShadow = "0 10px 30px -18px rgba(0,0,0,.3)";
|
|
217
|
+
style.overflowY = "auto";
|
|
218
|
+
style.zIndex = "99999999";
|
|
219
|
+
style.maxHeight = "calc(100vh - 32px)";
|
|
220
|
+
style.fontFamily = "Consolas, monospace";
|
|
221
|
+
style.maxWidth = "min(50vw,25rem)";
|
|
222
|
+
style.fontSize = "12px";
|
|
223
|
+
style.minWidth = "300px";
|
|
224
|
+
style.overflowWrap = "break-word";
|
|
225
|
+
style.resize = "vertical";
|
|
226
|
+
}
|
|
227
|
+
this.addEventListener("click", (e: MouseEvent) => {
|
|
228
|
+
if (!e.ctrlKey) return;
|
|
229
|
+
e.preventDefault();
|
|
230
|
+
keepDebugOnMouseOut = !keepDebugOnMouseOut;
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
if (this.dataProvider) {
|
|
234
|
+
window[this.dataProvider] = this.publisher;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
this.addEventListener("mouseover", () => {
|
|
238
|
+
if (!keepDebugOnMouseOut) this.removeDebugger();
|
|
239
|
+
document.body.appendChild(this.debug as Node);
|
|
240
|
+
debugs.add(this.debug as HTMLElement);
|
|
241
|
+
});
|
|
242
|
+
this.addEventListener("mouseout", () => {
|
|
243
|
+
if (!keepDebugOnMouseOut) this.removeDebugger();
|
|
244
|
+
});
|
|
245
|
+
this.publisher?.onInternalMutation(() => {
|
|
246
|
+
(this.debug as HTMLElement).innerHTML = `🤖 DataProvider : "<b style="font-weight:bold;color:#fff;">${this.dataProvider}</b>"<br>
|
|
247
|
+
<div style="font-size:10px;border-top:1px dashed;margin-top:5px;padding-left:23px;opacity:.6;padding-top:5px;">
|
|
248
|
+
Variable disponible dans la console<br>
|
|
249
|
+
ctrl + Clique : épingler / désépingler
|
|
250
|
+
</div>
|
|
251
|
+
<pre style="margin-top:10px;background:transparent;padding:0;font-size:inherit;color:inherit;">${JSON.stringify(
|
|
252
|
+
this.publisher?.get(),
|
|
253
|
+
null,
|
|
254
|
+
" "
|
|
255
|
+
)}</pre>`;
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
removeDebugger() {
|
|
260
|
+
debugs.forEach((debug) => {
|
|
261
|
+
if (document.body.contains(debug)) document.body.removeChild(debug);
|
|
262
|
+
});
|
|
263
|
+
debugs = new Set();
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Petite fonction utilitaire pour retourner la configuration a passer à l'utilitaire API
|
|
267
|
+
* Utilisée pour la configuration du wording / de la traduction ainsi que par le mixin fetcher par exemple
|
|
268
|
+
* A voir si on le bouge dans un utilitaire
|
|
269
|
+
*/
|
|
270
|
+
getApiConfiguration(): APIConfiguration {
|
|
271
|
+
return HTML.getApiConfiguration(this);
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Initialise le remplisage automatique des traductions / du wording
|
|
275
|
+
* Un publisher spécifique est créé pour le composant à l'adresse "sonic-wording"
|
|
276
|
+
* Le composant recherche la valeur de l'attribute "wordingProvider" que contient le point d'accès à l'api de traduction / libellés
|
|
277
|
+
* Il utilise ce service et le publisher créé pour remplir automatiquement toutes les propriétés préfixées avec "wording_".
|
|
278
|
+
*/
|
|
279
|
+
async initWording() {
|
|
280
|
+
const propNames = Object.getOwnPropertyNames(this.constructor.prototype);
|
|
281
|
+
for (const p of propNames) {
|
|
282
|
+
if (p.indexOf("wording_") == 0) {
|
|
283
|
+
WordingDirective.callApi(this, p.substring(8));
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
WordingDirective.publisher.startTemplateFilling(this);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
*
|
|
290
|
+
* Fonction native de lit surchargée pour la gestion du mode noShadowDom
|
|
291
|
+
* Le comportement de data binding est également créé ici va l'utilitaire DataBindObserver
|
|
292
|
+
*/
|
|
293
|
+
createRenderRoot() {
|
|
294
|
+
if (this.noShadowDom === "" || this.getAttribute("noShadowDom") === "") {
|
|
295
|
+
return this;
|
|
296
|
+
}
|
|
297
|
+
const shadowRoot = super.createRenderRoot();
|
|
298
|
+
DataBindObserver.observe(shadowRoot as HTMLElement);
|
|
299
|
+
return shadowRoot;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* On assign est enregistré car c'est un écouteur du publisher qui doit être délié lorsque l'objet est déconnecté du dom.
|
|
303
|
+
*/
|
|
304
|
+
private onAssign = (v: PropsType) => {
|
|
305
|
+
this.props = v;
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
initPublisher() {
|
|
309
|
+
if (!document) return;
|
|
310
|
+
if (this.publisher) {
|
|
311
|
+
this.publisher.stopTemplateFilling(this);
|
|
312
|
+
this.publisher.offInternalMutation(this.requestUpdate);
|
|
313
|
+
if (this.onAssign) this.publisher.offAssign(this.onAssign);
|
|
314
|
+
}
|
|
315
|
+
const mng = PublisherManager.getInstance();
|
|
316
|
+
if (!this.dataProvider) this.dataProvider = this.getAncestorAttributeValue("dataProvider");
|
|
317
|
+
let publisherId = this.dataProvider;
|
|
318
|
+
if (!publisherId && this._props) {
|
|
319
|
+
this.dataProvider = publisherId = "__subscriber__" + SubscriberElement.instanceCounter;
|
|
320
|
+
}
|
|
321
|
+
if (publisherId) {
|
|
322
|
+
if (this.bindPublisher) {
|
|
323
|
+
mng.set(publisherId, this.bindPublisher());
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
let pub = mng.get(publisherId, {localStorageMode: this.getAttribute("localStorage") || "disabled"});
|
|
327
|
+
this.dataProvider = publisherId;
|
|
328
|
+
|
|
329
|
+
if (this.hasAttribute("subDataProvider")) {
|
|
330
|
+
const dataPath: string = this.getAttribute("subDataProvider") as string;
|
|
331
|
+
this.dataProvider = publisherId + "/" + dataPath;
|
|
332
|
+
pub = Objects.traverse(pub, dataPath.split("."));
|
|
333
|
+
mng.set(this.dataProvider, pub);
|
|
334
|
+
this.publisher = pub;
|
|
335
|
+
}
|
|
336
|
+
this.publisher = pub;
|
|
337
|
+
}
|
|
338
|
+
if (this.publisher) {
|
|
339
|
+
if (this._props) {
|
|
340
|
+
this.publisher.set(this._props);
|
|
341
|
+
}
|
|
342
|
+
if (!this.noAutoFill) this.publisher.startTemplateFilling(this);
|
|
343
|
+
if (this.renderOnPropsInternalChange) this.publisher.onInternalMutation(this.requestUpdate);
|
|
344
|
+
this.publisher.onAssign(this.onAssign);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return SubscriberElement as Constructor<SubscriberInterface<PropsType>> & T;
|
|
349
|
+
};
|
|
350
|
+
export default Subscriber;
|
|
351
|
+
|
|
352
|
+
if (!window.SonicPublisherManager) window.SonicPublisherManager = PublisherManager;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {property} from "lit/decorators.js";
|
|
2
|
+
import {LitElement} from "lit";
|
|
3
|
+
import {MixinArgsType} from "../_types/types";
|
|
4
|
+
type Constructor<T> = new (...args: MixinArgsType[]) => T;
|
|
5
|
+
|
|
6
|
+
export declare class TemplatesContainerInterface extends LitElement {
|
|
7
|
+
connectedCallback(): void;
|
|
8
|
+
templateParts: Record<string, HTMLTemplateElement>;
|
|
9
|
+
templatePartsList: HTMLTemplateElement[];
|
|
10
|
+
templates: HTMLTemplateElement[];
|
|
11
|
+
templateList: HTMLTemplateElement[];
|
|
12
|
+
templateValueAttribute: string;
|
|
13
|
+
}
|
|
14
|
+
const TemplatesContainer = <T extends Constructor<LitElement>>(superClass: T) => {
|
|
15
|
+
/**
|
|
16
|
+
* Mixin pour mutualiser la gestion des templates dans différents composants (list, router, date, states...)
|
|
17
|
+
* Les templates sont soit dans aus sein du composant dans la déclaration html, soit renseignés via l'attribut "templates"
|
|
18
|
+
*/
|
|
19
|
+
class TemplatesContainerElement extends superClass {
|
|
20
|
+
/**
|
|
21
|
+
* On peut passer directement un tableu de template au composant via sont attribut.
|
|
22
|
+
* Voir utilisation dans le composant queue qui permet de ne pas doubler les balises templates à la déclaration.
|
|
23
|
+
*/
|
|
24
|
+
@property({type: Array}) templates: Array<HTMLTemplateElement> | null = null;
|
|
25
|
+
/**
|
|
26
|
+
* C'est le nom de l'attribut qui permet de regrouper les templates possédant cet attributs dans templateParts et templatePartsList.
|
|
27
|
+
* Ceux qui n'ont pas cet attribut sont stockés dans templateList
|
|
28
|
+
*/
|
|
29
|
+
templateValueAttribute = "data-value";
|
|
30
|
+
/**
|
|
31
|
+
* Tableau contenant tous les templates qui n'on pas d'attribut templateValueAttribute
|
|
32
|
+
*/
|
|
33
|
+
templateList: HTMLTemplateElement[] = [];
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Objet contenant tous les templates qui ont un attribut templateValueAttribute.
|
|
37
|
+
* Les clefs sont la valeur de l'attribut du template dont le nom est la valeur de templateValueAttribute.
|
|
38
|
+
*/
|
|
39
|
+
templateParts: Record<string, HTMLTemplateElement> = {};
|
|
40
|
+
/**
|
|
41
|
+
* Comme template parts mais sous forme de tableau, sans les clefs.
|
|
42
|
+
*/
|
|
43
|
+
templatePartsList: HTMLTemplateElement[] = [];
|
|
44
|
+
connectedCallback() {
|
|
45
|
+
const templates = this.templates || ([...this.querySelectorAll("template")] as HTMLTemplateElement[]);
|
|
46
|
+
|
|
47
|
+
for (const t of templates) {
|
|
48
|
+
if (t.hasAttribute(this.templateValueAttribute)) {
|
|
49
|
+
this.templateParts[t.getAttribute(this.templateValueAttribute) as string] = t;
|
|
50
|
+
this.templatePartsList.push(t);
|
|
51
|
+
}
|
|
52
|
+
if (t.hasAttribute("skeleton")) {
|
|
53
|
+
this.templateParts["skeleton"] = t;
|
|
54
|
+
}
|
|
55
|
+
if (t.hasAttribute("no-result")) {
|
|
56
|
+
this.templateParts["no-result"] = t;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (t.hasAttribute("no-item")) {
|
|
60
|
+
this.templateParts["no-item"] = t;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
this.templateList = templates.filter((t) => !t.getAttribute("data-value"));
|
|
64
|
+
if (this.templateList.length == 0) this.templateList = templates;
|
|
65
|
+
super.connectedCallback();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return TemplatesContainerElement as Constructor<TemplatesContainerInterface> & T;
|
|
69
|
+
};
|
|
70
|
+
export default TemplatesContainer;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
class Arrays {
|
|
2
|
+
/**
|
|
3
|
+
* Vérifie si les deux tableaux ont le même contenu
|
|
4
|
+
*/
|
|
5
|
+
static areEqual<U>(array1: Array<U>, array2: Array<U>) {
|
|
6
|
+
if (array1.length === array2.length) {
|
|
7
|
+
return array1.every((element, index) => {
|
|
8
|
+
if (element === array2[index]) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return false;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Fournie une fonction to1D qui transforme un tableau 2D en un tableau 1D par concaténation
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/*eslint-disable @typescript-eslint/no-explicit-any*/
|
|
24
|
+
static from2d(source: any) {
|
|
25
|
+
return {
|
|
26
|
+
to1D: () => {
|
|
27
|
+
let result: Array<any> = [];
|
|
28
|
+
source.forEach((elt: Array<any>) => (result = result.concat(elt)));
|
|
29
|
+
return this.from(result);
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/*eslint-enable @typescript-eslint/no-explicit-any*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Fournie des méthodes pour manipuler un tableau
|
|
37
|
+
* A l'écriture cela permet d'avoir des phrases du type:
|
|
38
|
+
* let data = Arrays.from(mon tableau)
|
|
39
|
+
* puis data.everyItem().has().same().value().forkey("key");
|
|
40
|
+
* Peu mieux faire. ou voir a remplacer un jour par loadHash par exemple.
|
|
41
|
+
**/
|
|
42
|
+
|
|
43
|
+
/*eslint-disable @typescript-eslint/no-explicit-any*/
|
|
44
|
+
static from(source: any) {
|
|
45
|
+
return {
|
|
46
|
+
/**Obtenir le tableau final*/
|
|
47
|
+
get: () => source || [],
|
|
48
|
+
everyItem: () => {
|
|
49
|
+
return {
|
|
50
|
+
has: () => {
|
|
51
|
+
return {
|
|
52
|
+
same: () => {
|
|
53
|
+
return {
|
|
54
|
+
value: () => {
|
|
55
|
+
return {
|
|
56
|
+
forKey: (key: string) => {
|
|
57
|
+
if (source.length < 1) return true;
|
|
58
|
+
const first = (source[0] || {})[key];
|
|
59
|
+
return source.every(
|
|
60
|
+
(item: any) => (item || {})[key] == first
|
|
61
|
+
);
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
value: () => {
|
|
70
|
+
return {
|
|
71
|
+
forKey: (key: string) => {
|
|
72
|
+
return Arrays.from(source.map((item: any) => item[key]));
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
copy: () => {
|
|
77
|
+
return {
|
|
78
|
+
fromKey: (atKey: string) => {
|
|
79
|
+
return {
|
|
80
|
+
toKey: (toKey: string) => {
|
|
81
|
+
source.forEach((item: any) => {
|
|
82
|
+
item[toKey] = Array.isArray(item[atKey])
|
|
83
|
+
? [...item[atKey]]
|
|
84
|
+
: typeof item[atKey] === "object" && item[atKey] != null
|
|
85
|
+
? {...item[atKey]}
|
|
86
|
+
: item[atKey];
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
map: (f: (elt: Record<string, any>) => any) => Arrays.from(source.map(f)),
|
|
96
|
+
filter: (f: (elt: any) => any) => Arrays.from(source.filter(f)),
|
|
97
|
+
find: (f: (elt: Record<string, any>) => any) => source.find(f),
|
|
98
|
+
some: (f: (elt: Record<string, any>) => any) => source.some(f),
|
|
99
|
+
every: (f: (elt: Record<string, any>) => any) => source.every(f),
|
|
100
|
+
group: () => {
|
|
101
|
+
return {
|
|
102
|
+
byKey: (key: string) => {
|
|
103
|
+
const result: Array<Record<string, any>> = [];
|
|
104
|
+
const keys: Map<any, number> = new Map();
|
|
105
|
+
for (const item of source) {
|
|
106
|
+
const value = item[key];
|
|
107
|
+
if (!keys.has(value)) {
|
|
108
|
+
const idx = result.length;
|
|
109
|
+
keys.set(value, idx);
|
|
110
|
+
const pushable: Record<string, any> = {items: []};
|
|
111
|
+
pushable[key] = value;
|
|
112
|
+
result.push(pushable);
|
|
113
|
+
}
|
|
114
|
+
result[keys.get(value) as number].items.push(item);
|
|
115
|
+
}
|
|
116
|
+
return Arrays.from(result);
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
without: () => {
|
|
121
|
+
return {
|
|
122
|
+
duplicates: () => {
|
|
123
|
+
return {
|
|
124
|
+
forKey: (key: string) => {
|
|
125
|
+
const set = [...new Set(source.map((item: any) => item[key]))];
|
|
126
|
+
return Arrays.from(
|
|
127
|
+
set.map((value) =>
|
|
128
|
+
source.find((item: any) => item[key] == value)
|
|
129
|
+
) as Array<Record<string, any>>
|
|
130
|
+
);
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
},
|
|
134
|
+
itemsIn: (toRemoveFromSource: Array<Record<string, any>>) => {
|
|
135
|
+
return {
|
|
136
|
+
havingSameValue: () => {
|
|
137
|
+
return {
|
|
138
|
+
forKey: (key: string) => {
|
|
139
|
+
const areValuesDifferentForKey =
|
|
140
|
+
(compared1: Record<string, any>, key: string) =>
|
|
141
|
+
(compared2: Record<string, any>) =>
|
|
142
|
+
compared1[key] != compared2[key];
|
|
143
|
+
return Arrays.from(
|
|
144
|
+
source.filter((elt: any) =>
|
|
145
|
+
toRemoveFromSource.every(
|
|
146
|
+
areValuesDifferentForKey(elt, key)
|
|
147
|
+
)
|
|
148
|
+
)
|
|
149
|
+
);
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
/*eslint-enable @typescript-eslint/no-explicit-any*/
|
|
160
|
+
}
|
|
161
|
+
export default Arrays;
|