@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,12 @@
|
|
|
1
|
+
export default class Utils {
|
|
2
|
+
static async queueTaskPromise() {
|
|
3
|
+
return new Promise((resolve) => {
|
|
4
|
+
window.queueMicrotask(()=>resolve(null));
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
static async delayPromise(timeoutMs: number) {
|
|
8
|
+
return new Promise((resolve) => {
|
|
9
|
+
setTimeout(resolve, timeoutMs);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
// on désactive une regle eslint pour ce fichier
|
|
2
|
+
/* eslint no-async-promise-executor: 0 */ // --> OFF
|
|
3
|
+
import HTML from "@supersoniks/concorde/core/utils/HTML";
|
|
4
|
+
import Objects from "@supersoniks/concorde/core/utils/Objects";
|
|
5
|
+
import {CoreJSType} from "@supersoniks/concorde/core/_types/types";
|
|
6
|
+
import {PublisherManager} from "./PublisherProxy";
|
|
7
|
+
|
|
8
|
+
export type APIConfiguration = {
|
|
9
|
+
serviceURL: string | null;
|
|
10
|
+
/** un flag pour indiquer de bloquer les appels suivant au même serviceurl tant que celuis-ci n'a pas terminé */
|
|
11
|
+
blockUntilDone?: boolean;
|
|
12
|
+
token: string | null;
|
|
13
|
+
userName: string | null;
|
|
14
|
+
password: string | null;
|
|
15
|
+
authToken: string | null;
|
|
16
|
+
tokenProvider: string | null;
|
|
17
|
+
addHTTPResponse?: boolean;
|
|
18
|
+
credentials?: RequestCredentials;
|
|
19
|
+
cache?: RequestCache;
|
|
20
|
+
};
|
|
21
|
+
export type CallState = "loading" | "done" | "error" | undefined;
|
|
22
|
+
export type ResultTypeInterface = CoreJSType & {_sonic_http_response_?: Response; text?: string};
|
|
23
|
+
export type APICall = {
|
|
24
|
+
apiMethod: "get" | "send" | "submitFormData";
|
|
25
|
+
path: string;
|
|
26
|
+
additionalHeaders: HeadersInit | undefined;
|
|
27
|
+
method?: string | undefined;
|
|
28
|
+
data?: unknown;
|
|
29
|
+
cache?: RequestCache;
|
|
30
|
+
};
|
|
31
|
+
class API {
|
|
32
|
+
/**
|
|
33
|
+
* Ce tableau static permet de ne pas appeler plusieurs fois le même service lors d'appel concurrents en GET.
|
|
34
|
+
*/
|
|
35
|
+
static loadingGetPromises: Map<string, Promise<unknown>> = new Map();
|
|
36
|
+
/**
|
|
37
|
+
* L'url de base du service sans endpoint
|
|
38
|
+
*/
|
|
39
|
+
serviceURL: string | null;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* le nom de l'utilisateur si basic auth est utilisé
|
|
43
|
+
*/
|
|
44
|
+
userName: string | null;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* le password de l'utilisateur si basic auth est utilisé
|
|
48
|
+
*/
|
|
49
|
+
password: string | null;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* le bearer token a passer pour les appels REST
|
|
53
|
+
*/
|
|
54
|
+
private _token: string | null | undefined;
|
|
55
|
+
set token(token: string | null | undefined) {
|
|
56
|
+
this._token = token;
|
|
57
|
+
|
|
58
|
+
if (!token) {
|
|
59
|
+
API.tokens.delete(this.serviceURL);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (API.invalidTokens.includes(token)) return;
|
|
64
|
+
|
|
65
|
+
API.tokens.set(this.serviceURL, token);
|
|
66
|
+
}
|
|
67
|
+
get token() {
|
|
68
|
+
// si le token est marqué invalide, on utilise utilise la dernière version valide connue du token pour ce serviceURL
|
|
69
|
+
return API.invalidTokens.includes(this._token) ? API.tokens.get(this.serviceURL) : this._token;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Le endPoint pour obtenir le bearer token qui sera concaténé à l'url du service
|
|
73
|
+
*/
|
|
74
|
+
tokenProvider: string | null;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* le bearer token à passer pour un éventuel renouvellement de token automatique
|
|
78
|
+
*/
|
|
79
|
+
authToken: string | null;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* credentials
|
|
83
|
+
*/
|
|
84
|
+
credentials?: RequestCredentials;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Tableau static des tokens stokés en memoire vive (comportement à revoir à l'occasion)
|
|
88
|
+
*/
|
|
89
|
+
static tokens = new Map<string | null, string | null | undefined>();
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Tableau stockant l'ensemble des tokens invalides
|
|
93
|
+
*/
|
|
94
|
+
static invalidTokens: (string | null | undefined)[] = [];
|
|
95
|
+
|
|
96
|
+
handleInvalidToken(token: string | null | undefined) {
|
|
97
|
+
if (!token) return;
|
|
98
|
+
|
|
99
|
+
if (API.invalidTokens.includes(token)) return;
|
|
100
|
+
|
|
101
|
+
API.invalidTokens.push(token);
|
|
102
|
+
this.token = null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Tableau static des tentatives échouées de récupération auto du token
|
|
107
|
+
*/
|
|
108
|
+
static failledTokenUpdates = new Map<string | null, true>();
|
|
109
|
+
/**
|
|
110
|
+
* Tableau static des flags pour savoir si le premier appel a été fait pour chaque serviceURL
|
|
111
|
+
*/
|
|
112
|
+
static firstCallDoneFlags = new Map<string | null, CallState>();
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Le endPoint pour obtenir le bearer token qui sera concaténé à l'url du service
|
|
116
|
+
*/
|
|
117
|
+
addHTTPResponse = false;
|
|
118
|
+
cache: RequestCache = "default";
|
|
119
|
+
lastResult?: Response;
|
|
120
|
+
isServiceSimulated = false;
|
|
121
|
+
blockUntilDone = false;
|
|
122
|
+
constructor(config: APIConfiguration) {
|
|
123
|
+
this.serviceURL = config.serviceURL;
|
|
124
|
+
this.blockUntilDone = config.blockUntilDone || false;
|
|
125
|
+
if (this.serviceURL == "publisher://") {
|
|
126
|
+
this.isServiceSimulated = true;
|
|
127
|
+
}
|
|
128
|
+
if (!this.serviceURL) this.serviceURL = document.location.origin;
|
|
129
|
+
this.userName = config.userName;
|
|
130
|
+
this.password = config.password;
|
|
131
|
+
if (config.token) this.token = config.token;
|
|
132
|
+
this.tokenProvider = config.tokenProvider;
|
|
133
|
+
this.authToken = config.authToken;
|
|
134
|
+
this.addHTTPResponse = config.addHTTPResponse || false;
|
|
135
|
+
this.credentials = config.credentials;
|
|
136
|
+
this.cache = config.cache || "default";
|
|
137
|
+
}
|
|
138
|
+
async handleResult(fetchResult: Response, lastCall: APICall): Promise<ResultTypeInterface> {
|
|
139
|
+
API.firstCallDoneFlags.set(this.serviceURL, "done");
|
|
140
|
+
this.lastResult = fetchResult;
|
|
141
|
+
const contentType = fetchResult.headers.get("content-type")?.toLowerCase();
|
|
142
|
+
const httpCode = fetchResult.status;
|
|
143
|
+
|
|
144
|
+
let result: ResultTypeInterface = {};
|
|
145
|
+
if (!contentType || contentType.indexOf("text/") == 0) {
|
|
146
|
+
const str = await fetchResult.text();
|
|
147
|
+
result = {text: str} as typeof result;
|
|
148
|
+
} else {
|
|
149
|
+
try {
|
|
150
|
+
result = await fetchResult.json();
|
|
151
|
+
} catch (e) {
|
|
152
|
+
result = {} as typeof result;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (this.addHTTPResponse && Objects.isObject(result)) {
|
|
156
|
+
result._sonic_http_response_ = fetchResult;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (httpCode === 498 && !API.failledTokenUpdates.has(this.serviceURL)) {
|
|
160
|
+
this.handleInvalidToken(this.token);
|
|
161
|
+
if (lastCall.apiMethod === "get") {
|
|
162
|
+
result = await this[lastCall.apiMethod](lastCall.path, lastCall.additionalHeaders);
|
|
163
|
+
} else {
|
|
164
|
+
result = await this[lastCall.apiMethod](lastCall.path, lastCall.data, lastCall.method, lastCall.additionalHeaders);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return result;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Basic auth
|
|
173
|
+
*/
|
|
174
|
+
async auth() {
|
|
175
|
+
if (this.token) return;
|
|
176
|
+
if (API.tokens.has(this.serviceURL)) {
|
|
177
|
+
this.token = API.tokens.get(this.serviceURL);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (!this.tokenProvider) return;
|
|
181
|
+
|
|
182
|
+
let headers = {};
|
|
183
|
+
if (this.userName && this.password) {
|
|
184
|
+
headers = {
|
|
185
|
+
Authorization: "Basic " + window.btoa(unescape(encodeURIComponent(this.userName + ":" + this.password))),
|
|
186
|
+
};
|
|
187
|
+
} else if (this.authToken) {
|
|
188
|
+
headers = {
|
|
189
|
+
Authorization: "Bearer " + this.authToken,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const serviceURL = new URL(this.serviceURL as string);
|
|
194
|
+
const serviceHost = serviceURL.protocol + "//" + serviceURL.host;
|
|
195
|
+
const result = await fetch(this.computeURL(this.tokenProvider as string, {serviceHost: serviceHost}), {
|
|
196
|
+
headers: headers,
|
|
197
|
+
credentials: this.credentials,
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
try {
|
|
201
|
+
const json = await result.json();
|
|
202
|
+
const newToken = json.token;
|
|
203
|
+
if (newToken) {
|
|
204
|
+
this.token = json.token;
|
|
205
|
+
} else {
|
|
206
|
+
API.failledTokenUpdates.set(this.serviceURL, true);
|
|
207
|
+
}
|
|
208
|
+
} catch (e) {
|
|
209
|
+
API.failledTokenUpdates.set(this.serviceURL, true);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* avec localget, on ne passe pas par le système de token
|
|
215
|
+
* on recupère path sans les searchparams nommée pathWithoutSearchParams
|
|
216
|
+
* on cherche dans PublisherManager.get(pathWithoutSearchParams).get() les données qui matchent les searchparams présents dans path
|
|
217
|
+
* on retourne les données selon le même format que le retour de get
|
|
218
|
+
*
|
|
219
|
+
* @todo netttoyer
|
|
220
|
+
*/
|
|
221
|
+
async localGet<T>(dataProvider: string, searchString: string) {
|
|
222
|
+
const publisher = PublisherManager.get(dataProvider);
|
|
223
|
+
|
|
224
|
+
console.log(publisher);
|
|
225
|
+
const searchParams = new URLSearchParams(searchString.split("?")[1] || "");
|
|
226
|
+
const dataObject = publisher.get();
|
|
227
|
+
let data = [];
|
|
228
|
+
if (!Array.isArray(dataObject)) {
|
|
229
|
+
data = [dataObject];
|
|
230
|
+
} else {
|
|
231
|
+
data = dataObject;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const result = [];
|
|
235
|
+
|
|
236
|
+
let limit = Number.POSITIVE_INFINITY;
|
|
237
|
+
let offset = 0;
|
|
238
|
+
let limitOffsetparams = 0;
|
|
239
|
+
if (searchParams.has("limit")) {
|
|
240
|
+
limit = parseInt(searchParams.get("limit") || "0");
|
|
241
|
+
limitOffsetparams++;
|
|
242
|
+
}
|
|
243
|
+
if (searchParams.has("offset")) {
|
|
244
|
+
offset = parseInt(searchParams.get("offset") || "0");
|
|
245
|
+
limitOffsetparams++;
|
|
246
|
+
}
|
|
247
|
+
if (limitOffsetparams > 0) {
|
|
248
|
+
searchParams.delete("limit");
|
|
249
|
+
searchParams.delete("offset");
|
|
250
|
+
}
|
|
251
|
+
if (searchParams.size === 0) return data.slice(offset, offset + limit) as T & ResultTypeInterface;
|
|
252
|
+
for (const [key, value] of searchParams.entries()) {
|
|
253
|
+
const values = value.split(",").map((s) => s.trim());
|
|
254
|
+
for (const v of values) {
|
|
255
|
+
for (const item of data) {
|
|
256
|
+
//si l'item est une valeur primitive on regarde si vaue correspond à item simplement
|
|
257
|
+
if (typeof item !== "object") {
|
|
258
|
+
if (!isNaN(+value)) {
|
|
259
|
+
if (item == value) {
|
|
260
|
+
result.push(item);
|
|
261
|
+
}
|
|
262
|
+
} else if (item.toString().includes(value)) {
|
|
263
|
+
result.push(item);
|
|
264
|
+
}
|
|
265
|
+
} else {
|
|
266
|
+
const record = item as Record<string, unknown>;
|
|
267
|
+
//si l'item est un objet
|
|
268
|
+
//faire un comparaison de la version string de la même clef dans item pour voir si elle contient value
|
|
269
|
+
if (!record[key]) continue;
|
|
270
|
+
|
|
271
|
+
//si la valeur est un nombre, on compare les valeurs directement
|
|
272
|
+
if (!isNaN(+v)) {
|
|
273
|
+
if (record[key] == v) {
|
|
274
|
+
result.push(item);
|
|
275
|
+
}
|
|
276
|
+
} else {
|
|
277
|
+
if (record[key]?.toString().toLowerCase().includes(v.toLowerCase())) {
|
|
278
|
+
result.push(item);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return result.slice(offset, offset + limit) as T & ResultTypeInterface;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* firstCallDone is a function that returns a promise that is resolved when the first call to the API is done for each serviceURL whatever api instance is used
|
|
290
|
+
*/
|
|
291
|
+
firstCallDone() {
|
|
292
|
+
return new Promise((resolve) => {
|
|
293
|
+
if (!API.firstCallDoneFlags.has(this.serviceURL)) {
|
|
294
|
+
API.firstCallDoneFlags.set(this.serviceURL, "loading");
|
|
295
|
+
resolve(true);
|
|
296
|
+
} else {
|
|
297
|
+
const loop = () => {
|
|
298
|
+
if (![undefined, "loading"].includes(API.firstCallDoneFlags.get(this.serviceURL))) {
|
|
299
|
+
resolve(true);
|
|
300
|
+
} else {
|
|
301
|
+
window.requestAnimationFrame(loop);
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
loop();
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
async get<T>(path: string, additionalHeaders?: HeadersInit) {
|
|
310
|
+
await this.firstCallDone();
|
|
311
|
+
if (this.blockUntilDone) {
|
|
312
|
+
API.firstCallDoneFlags.set(this.serviceURL, "loading");
|
|
313
|
+
}
|
|
314
|
+
const regExp = /dataProvider\((.*?)\)(.*?)$/;
|
|
315
|
+
if (regExp.test(path)) {
|
|
316
|
+
const match = path.match(regExp);
|
|
317
|
+
if (!match) throw new Error("dataProvider path is not valid");
|
|
318
|
+
return await this.localGet<T>(match[1], match[2]);
|
|
319
|
+
}
|
|
320
|
+
const lastCall: APICall = {
|
|
321
|
+
apiMethod: "get",
|
|
322
|
+
path: path,
|
|
323
|
+
additionalHeaders: additionalHeaders,
|
|
324
|
+
};
|
|
325
|
+
const headers = await this.createHeaders(additionalHeaders);
|
|
326
|
+
const url = this.computeURL(path);
|
|
327
|
+
const mapKey = JSON.stringify({
|
|
328
|
+
url: url,
|
|
329
|
+
headers: headers,
|
|
330
|
+
});
|
|
331
|
+
if (!API.loadingGetPromises.has(mapKey)) {
|
|
332
|
+
const promise = new Promise(async (resolve) => {
|
|
333
|
+
try {
|
|
334
|
+
const result = await fetch(url, {headers: headers, credentials: this.credentials, cache: this.cache});
|
|
335
|
+
const handledResult = await this.handleResult(result, lastCall);
|
|
336
|
+
resolve(handledResult);
|
|
337
|
+
} catch (e) {
|
|
338
|
+
resolve(null);
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
API.loadingGetPromises.set(mapKey, promise);
|
|
342
|
+
}
|
|
343
|
+
const result = (await API.loadingGetPromises.get(mapKey)) as T;
|
|
344
|
+
API.loadingGetPromises.delete(mapKey);
|
|
345
|
+
return result as T & ResultTypeInterface;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Création du header, avec authentification si besoin
|
|
349
|
+
* ajout du language via le header accept-language qui contient le langue du navigateur
|
|
350
|
+
*/
|
|
351
|
+
async createHeaders(additionalHeaders?: HeadersInit) {
|
|
352
|
+
await this.auth();
|
|
353
|
+
const headers: HeadersInit = {};
|
|
354
|
+
if (this.token) headers.Authorization = "Bearer " + this.token;
|
|
355
|
+
headers["Accept-Language"] = HTML.getLanguage();
|
|
356
|
+
if (additionalHeaders) {
|
|
357
|
+
Object.assign(headers, additionalHeaders);
|
|
358
|
+
}
|
|
359
|
+
return headers;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Concatène le serviceURL et le endpoint donné en paramètre
|
|
364
|
+
*/
|
|
365
|
+
computeURL(path: string, query: Record<string, string> = {}) {
|
|
366
|
+
let url = "";
|
|
367
|
+
if (path.startsWith("http")) url = path as string;
|
|
368
|
+
else url = this.serviceURL + "/" + path;
|
|
369
|
+
|
|
370
|
+
if (!url.startsWith("http")) url = window.location.origin + url;
|
|
371
|
+
|
|
372
|
+
const computedUrl = new URL(url);
|
|
373
|
+
for (const key in query) {
|
|
374
|
+
computedUrl.searchParams.set(key, query[key]);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
return computedUrl.toString().replace(/([^(https?:)])\/{2,}/g, "$1/");
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/*
|
|
381
|
+
* Envoie des données au endPoint passé en paramètre. par défaut en POST
|
|
382
|
+
*/
|
|
383
|
+
async send<T, SendType = CoreJSType>(path: string, data: SendType, method = "POST", additionalHeaders?: HeadersInit) {
|
|
384
|
+
const lastCall: APICall = {
|
|
385
|
+
apiMethod: "send",
|
|
386
|
+
path: path,
|
|
387
|
+
additionalHeaders: additionalHeaders,
|
|
388
|
+
method: method,
|
|
389
|
+
data: data,
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
const headers = await this.createHeaders(additionalHeaders);
|
|
393
|
+
headers["Accept"] = "application/json";
|
|
394
|
+
headers["Content-Type"] = "application/json";
|
|
395
|
+
const result = await fetch(this.computeURL(path), {
|
|
396
|
+
headers: headers,
|
|
397
|
+
credentials: this.credentials,
|
|
398
|
+
method: method,
|
|
399
|
+
body: JSON.stringify(data),
|
|
400
|
+
});
|
|
401
|
+
return (await this.handleResult(result, lastCall)) as T & ResultTypeInterface;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Agit comme une soumission de formulaire, mais attends un json en réponse
|
|
406
|
+
*/
|
|
407
|
+
async submitFormData<T, SendType = CoreJSType>(path: string, data: SendType, method = "POST", additionalHeaders?: HeadersInit) {
|
|
408
|
+
const lastCall: APICall = {
|
|
409
|
+
apiMethod: "submitFormData",
|
|
410
|
+
path: path,
|
|
411
|
+
additionalHeaders: additionalHeaders,
|
|
412
|
+
method: method,
|
|
413
|
+
data: data,
|
|
414
|
+
};
|
|
415
|
+
const headers = await this.createHeaders(additionalHeaders);
|
|
416
|
+
headers["Accept"] = "application/json";
|
|
417
|
+
const formData = new FormData();
|
|
418
|
+
const dynamicData = data as unknown as {[property: string]: string};
|
|
419
|
+
for (const z in dynamicData) formData.set(z, dynamicData[z]);
|
|
420
|
+
const result = await fetch(this.computeURL(path), {
|
|
421
|
+
headers: headers,
|
|
422
|
+
credentials: this.credentials,
|
|
423
|
+
method: method,
|
|
424
|
+
body: formData,
|
|
425
|
+
});
|
|
426
|
+
return (await this.handleResult(result, lastCall)) as T & ResultTypeInterface;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Appel send en utilisant le méthode PUT
|
|
431
|
+
*/
|
|
432
|
+
async put<T, SendType = CoreJSType>(path: string, data: SendType, additionalHeaders?: HeadersInit) {
|
|
433
|
+
return this.send<T, SendType>(path, data, "PUT", additionalHeaders);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Appel send en utilisant le méthode POST
|
|
438
|
+
*/
|
|
439
|
+
async post<T, SendType = CoreJSType>(path: string, data: SendType, additionalHeaders?: HeadersInit) {
|
|
440
|
+
return this.send<T, SendType>(path, data, "POST", additionalHeaders);
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Appel send en utilisant le méthode PATCH
|
|
444
|
+
*/
|
|
445
|
+
async patch<T, SendType = CoreJSType>(path: string, data: SendType, additionalHeaders?: HeadersInit) {
|
|
446
|
+
return this.send<T, SendType>(path, data, "PATCH", additionalHeaders);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Appel send en utilisant le méthode delete
|
|
451
|
+
*/
|
|
452
|
+
async delete<T, SendType = CoreJSType>(path: string, data: SendType, additionalHeaders?: HeadersInit) {
|
|
453
|
+
return this.send<T, SendType>(path, data, "delete", additionalHeaders);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
export default API;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import * as mySubscriber from "@supersoniks/concorde/core/decorators/Subscriber";
|
|
2
2
|
export const bind = mySubscriber.bind;
|
|
3
3
|
export const onAssign = mySubscriber.onAssign;
|
|
4
|
+
|
|
5
|
+
import {ConcordeWindow} from "./core/_types/types";
|
|
6
|
+
declare const window: ConcordeWindow;
|
|
7
|
+
|
|
4
8
|
window["concorde-decorator-subscriber"] = window["concorde-decorator-subscriber"] || {};
|
|
5
9
|
window["concorde-decorator-subscriber"] = {
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
bind: mySubscriber.bind,
|
|
11
|
+
onAssing: mySubscriber.onAssign,
|
|
8
12
|
};
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import * as myDataProvider from "@supersoniks/concorde/core/directives/DataProvider";
|
|
2
|
+
|
|
3
|
+
import {ConcordeWindow} from "./core/_types/types";
|
|
2
4
|
export const dp = myDataProvider.dp;
|
|
3
5
|
export const dataProvider = myDataProvider.dataProvider;
|
|
4
6
|
export const subscribe = myDataProvider.subscribe;
|
|
5
7
|
export const sub = myDataProvider.sub;
|
|
6
8
|
export const get = myDataProvider.get;
|
|
7
9
|
export const set = myDataProvider.set;
|
|
10
|
+
|
|
11
|
+
declare const window: ConcordeWindow;
|
|
12
|
+
|
|
8
13
|
window["concorde-directives-data-provider"] = window["concorde-directives-data-provider"] || {};
|
|
9
14
|
window["concorde-directives-data-provider"] = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
dp: myDataProvider.dp,
|
|
16
|
+
dataProvider: myDataProvider.dataProvider,
|
|
17
|
+
sub: myDataProvider.sub,
|
|
18
|
+
subscribe: myDataProvider.subscribe,
|
|
19
|
+
get: myDataProvider.get,
|
|
20
|
+
set: myDataProvider.set,
|
|
16
21
|
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# lit + tailwind + vite
|
|
2
|
+
|
|
3
|
+
**Some notes for an overview of Concorde's functioning**
|
|
4
|
+
|
|
5
|
+
## Standard Web components
|
|
6
|
+
A web component is simply a **custom HTML element** created using web standards:
|
|
7
|
+
|
|
8
|
+
**web component** = [Custom Elements](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements) + [shadowDom](https://developer.mozilla.org/fr/docs/Web/Web_Components/Using_shadow_DOM) + [HTML templates](https://developer.mozilla.org/fr/docs/Web/HTML/Element/template)
|
|
9
|
+
|
|
10
|
+
## Lit Library
|
|
11
|
+
|
|
12
|
+
Concorde components are written using the lightweight Lit library: https://lit.dev/.
|
|
13
|
+
|
|
14
|
+
A good portion of the elements documented on the Lit website are standard JavaScript concepts (e.g., [mixins](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes#mix-ins), [tagged template literals](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Template_literals#gabarits_%C3%A9tiquet%C3%A9s)).
|
|
15
|
+
|
|
16
|
+
The **library simplifies the writing of web components** by automating certain tasks:
|
|
17
|
+
|
|
18
|
+
- Creation of an **open mode shadow DOM** (the component is accessible from the outside via its shadow root property).
|
|
19
|
+
- [Rendering function](https://lit.dev/docs/components/rendering/) based on [tagged template literals](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Template_literals#gabarits_%C3%A9tiquet%C3%A9s)
|
|
20
|
+
- [Reactive properties](https://lit.dev/docs/components/properties/) that trigger rendering when modified.
|
|
21
|
+
|
|
22
|
+
Our use of Lit rarely goes beyond this [hello world](https://lit.dev/playground/#sample=examples/hello-world)
|
|
23
|
+
|
|
24
|
+
## Typescript Language
|
|
25
|
+
|
|
26
|
+
We write the components in [TypeScript](https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html), which is then compiled into JS.
|
|
27
|
+
|
|
28
|
+
Static and inferred typing provides stronger validation of the program's functioning during compilation.
|
|
29
|
+
However, we often use the "any" type due to time constraints.
|
|
30
|
+
|
|
31
|
+
Lit uses TypeScript to simplify development through metadata:
|
|
32
|
+
- Simplified declaration of `custom elements` via @customElement
|
|
33
|
+
- Generation of `reactive properties` via @property.
|
|
34
|
+
|
|
35
|
+
☢️**Warning**:
|
|
36
|
+
- During development, we operate in interpreted mode, which is faster but allows errors that won't pass during the build.
|
|
37
|
+
- It is important to **build a distribution before pushing the code** to ensure everything is fine.
|
|
38
|
+
|
|
39
|
+
## Compatibility with Classic JS Libraries
|
|
40
|
+
|
|
41
|
+
Compatibility issues may arise when using JS libraries, particularly regarding DOM traversal.
|
|
42
|
+
This is because these libraries are blocked from traversing the DOM due to the presence of the shadow DOM.
|
|
43
|
+
Here are some examples of things that may cause problems:
|
|
44
|
+
|
|
45
|
+
- Latest FontAwesome in SVG mode, icons are not replaced
|
|
46
|
+
- Libraries associated with jQuery
|
|
47
|
+
- document.getElementById
|
|
48
|
+
- ...
|
|
49
|
+
|
|
50
|
+
## Topics to Explore for Further Learning
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
[🧱 Creating components](#docs/_getting-started/create-a-component.md/create-a-component)
|
|
54
|
+
|
|
55
|
+
[🎨 Adding styles](#docs/_getting-started/theming.md/theming)
|
|
56
|
+
|
|
57
|
+
[🥨 Sharing data](#docs/_getting-started/pubsub.md/pubsub)
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# 🔔 The subscriber mixin
|
|
2
|
+
|
|
3
|
+
This is a mixin that is commonly extended by Concorde core components and destination components. Pure UI components usually don't extend it, especially those outside of form components.
|
|
4
|
+
|
|
5
|
+
## DataProvider Attribute: Automatic Filling of Subscriber Properties
|
|
6
|
+
|
|
7
|
+
Upon being added to the DOM (connectedCallback), subscribers search for the first occurrence of the `dataProvider` attribute in their parent's HTML structure.
|
|
8
|
+
|
|
9
|
+
The value of this attribute is used to obtain a publisher via the PublisherManager (see [🥨 Sharing Data](#docs/_getting-started/pubsub.md/pubsub)).
|
|
10
|
+
|
|
11
|
+
The subscriber then subscribes to the publisher as a data template to be filled.
|
|
12
|
+
|
|
13
|
+
The reactive properties of the component reflect in real-time the properties with the same name in the publisher.
|
|
14
|
+
|
|
15
|
+
This functionality is commonly used in the generic components [fetch](#core/components/functional/fetch/fetch.md/fetch), [queue](#core/components/functional/queue/queue.md/queue), and [list](#core/components/functional/list/list.md/list).
|
|
16
|
+
|
|
17
|
+
If the subscriber is inside another subscriber, it can subscribe to a data of its parent using the attribute `subDataProvider = 'address.of.my.data'` instead of the parent's data. This allows for dynamic behavior.
|
|
18
|
+
|
|
19
|
+
## Automated Translation
|
|
20
|
+
|
|
21
|
+
In a similar manner, searching for ancestor attributes can be used to configure automatic translation for any property starting with "wording" and ending with a label identifier recognized by the wordingProvider API.
|
|
22
|
+
|
|
23
|
+
Normally, this API is globally configured and not within the component. Therefore, remember to prefix translatable label identifiers present in the ticketing system, for example, with "wording".
|
|
24
|
+
|
|
25
|
+
## Reactive Property `props`
|
|
26
|
+
|
|
27
|
+
The value of this property can be provided as a JSON object or any other value. This value is then assigned to the associated publisher via the `dataProvider` attribute. As a result, the reactive properties of all subscribers associated with the same `dataProvider` are filled as mentioned above.
|
|
28
|
+
|
|
29
|
+
## Disabling Automatic Filling of Reactive Properties
|
|
30
|
+
|
|
31
|
+
It is possible to disable the automatic filling of reactive properties in a particular component. To do so, set the variable `noAutoFill = true` in the component's class. However, the reactive property `props` will still be updated.
|
|
32
|
+
|
|
33
|
+
For example, `sonic-subscriber` and `sonic-fetch` have this attribute because they do not have reactive properties.
|
|
34
|
+
|
|
35
|
+
**☢ CAUTION:** When creating an object of type Subscriber or Fetcher, make sure to use the mixins and not directly extend the concrete fetch component (`sonic-fetch`) and subscriber component (`sonic-subscriber`). This is because the `noAutofill = true` attribute is set in those components.
|
|
36
|
+
|
|
37
|
+
**TIPS:**
|
|
38
|
+
If you disable automatic filling, you will likely make the rendering dynamic by writing expressions like `this.props.my.subproperty`. If `props` is updated, the rendering will be triggered. However, if `this.props.my.subproperty` is directly modified, the rendering will not be triggered. To achieve more reactivity, you can enable rendering when any subproperty is modified. Simply set the variable `renderOnPropsInternalChange = true` in the class that implements the corresponding mixin.
|
|
39
|
+
|
|
40
|
+
## Data Binding
|
|
41
|
+
|
|
42
|
+
Suppose that:
|
|
43
|
+
|
|
44
|
+
- You have a subscriber subscribed to a publisher via its `dataProvider` attribute.
|
|
45
|
+
- The published data has the following structure:
|
|
46
|
+
|
|
47
|
+
<sonic-code language="javascript">
|
|
48
|
+
<template>
|
|
49
|
+
{"img": { "avatar": "my-avatar.jpg", "caption": "look at my smile" }, "email": "an.email@example.com" }
|
|
50
|
+
</template>
|
|
51
|
+
</sonic-code>
|
|
52
|
+
- We want to keep the display of an image and its `title` attribute up to date, as well as a "contact" button to email the person in the photo. The content of the subscriber could be as follows:
|
|
53
|
+
|
|
54
|
+
<sonic-code language="html">
|
|
55
|
+
<template>
|
|
56
|
+
<img data-bind ::src="$img.avatar" ::title="ucFirst|$img.caption" />
|
|
57
|
+
<a data-bind ::href="mailto:$email" ::inner-html="$email"></a>
|
|
58
|
+
</template>
|
|
59
|
+
</sonic-code>
|
|
60
|
+
|
|
61
|
+
This example also illustrates:
|
|
62
|
+
|
|
63
|
+
- Binding to subproperties using dot syntax, as done for the `src` attribute of the `img` tag.
|
|
64
|
+
- Using a simple expression to include the property within a string, as in creating a `mailto` link.
|
|
65
|
+
- Using formatting functions, as in the `title` attribute of the `img` tag. You can find (and add) formatting functions in the `core/utils/Format.ts` file.
|
|
66
|
+
- Writing for properties that are in camel case. Convert everything to lowercase and add hyphens. Note that `innerHTML` (or `outerHTML`) is a special case where no hyphens are added between each letter.
|
|
67
|
+
|
|
68
|
+
**Note:** Data binding implies that updating the `img.src` data via the publisher will change the photo without any additional calls.
|
|
69
|
+
|
|
70
|
+
**Special Variables:**
|
|
71
|
+
- `_self_` targets the root of the data. This is useful, for example, when the data is a pure string.
|
|
72
|
+
- `_parent_` targets the parent publisher of the current publisher, if any. For example, the subscribers of lists have the complete data of the list as their parent.
|
|
73
|
+
- `_metadata_` is only used in the case of *sonic-list* at the moment. In a simple list, `_metadata_` see the (list)[] component for further details
|
|
74
|
+
|
|
75
|
+
**Disabling this functionality:**
|
|
76
|
+
You can disable data binding if it is not needed by calling `DataBinding.disable()`.
|