@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,87 @@
|
|
|
1
|
+
# States
|
|
2
|
+
|
|
3
|
+
### sonic-states displays different states depending on the value of a sub-property of its dataProvider (data-path attribute in dot notation):
|
|
4
|
+
* It loops over its child templates and tests if the regexp contained in the *data-value* attribute matches the value of the property
|
|
5
|
+
* If so, the content of the corresponding template is displayed as a state.
|
|
6
|
+
* If the attribute dataProviderExpression is provided the content is surrounded by a div:
|
|
7
|
+
* The "dataProvider" attribute of this div is the result of calling the replace function on the property value with the regexp and dataproviderExpression as parameters.
|
|
8
|
+
* The subscribers/fetch... of the template will refer to this dataProvider
|
|
9
|
+
* You can also use url-pattern expressions for the route parameters, see the examples
|
|
10
|
+
*
|
|
11
|
+
**Examples**
|
|
12
|
+
* With ma.property= 2 :
|
|
13
|
+
* RegExp data-value = (\d+) and dataproviderExpression = /user/$1 the dataProvider attribute will be "/user/2"
|
|
14
|
+
* url-pattern data-value = :id and dataproviderExpression = /user/:id the dataProvider attribute will be "/user/2
|
|
15
|
+
|
|
16
|
+
## Basic
|
|
17
|
+
|
|
18
|
+
<sonic-code>
|
|
19
|
+
<template>
|
|
20
|
+
<div class="flex gap-2 items-center" formDataProvider="states-basic-example">
|
|
21
|
+
<sonic-button radio name="selection" value="#home" checked size="xs">Home</sonic-button>
|
|
22
|
+
<sonic-button radio name="selection" value="#about" size="xs">About</sonic-button>
|
|
23
|
+
<sonic-button radio name="selection" value="#work" size="xs">Work</sonic-button>
|
|
24
|
+
<sonic-button radio name="selection" value="#contact" size="xs">Contact</sonic-button>
|
|
25
|
+
</div>
|
|
26
|
+
<div class="text-center text-neutral-700 border rounded text-4xl my-6 p-3 ">
|
|
27
|
+
<sonic-states dataProvider="states-basic-example" data-path="selection">
|
|
28
|
+
<template data-value="#home">Home</template>
|
|
29
|
+
<template data-value="#about">About</template>
|
|
30
|
+
<template data-value="#work">Work</template>
|
|
31
|
+
<template data-value="#contact">Contact</template>
|
|
32
|
+
</sonic-states>
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
35
|
+
</sonic-code>
|
|
36
|
+
|
|
37
|
+
## Regexp
|
|
38
|
+
|
|
39
|
+
When using **capturing groups ()** the stored values are accessible via the **dataProviderExpression**
|
|
40
|
+
**e.g.**, data-value="#couleur_<b class="text-danger">(\d+)</b>" => dataProviderExpression="api/unknown/<b class="text-danger">$1</b>"
|
|
41
|
+
|
|
42
|
+
<sonic-code>
|
|
43
|
+
<template>
|
|
44
|
+
<sonic-theme theme="light" serviceURL="https://reqres.in">
|
|
45
|
+
<sonic-list formDataProvider="states-regexp-example" fetch dataProvider="api/unknown" key="data" class="flex gap-2 items-center" >
|
|
46
|
+
<template>
|
|
47
|
+
<sonic-button radio size="xs" name="selection" data-bind ::value="#couleur_$id">
|
|
48
|
+
<span data-bind ::inner-html="ucFirst|$name"></span>
|
|
49
|
+
</sonic-button>
|
|
50
|
+
</template>
|
|
51
|
+
</sonic-list>
|
|
52
|
+
<sonic-states dataProvider="states-regexp-example" data-path="selection">
|
|
53
|
+
<template data-value="#couleur_(\d+)" dataProviderExpression="api/unknown/$1">
|
|
54
|
+
<sonic-fetch>
|
|
55
|
+
<input type="color" disabled data-bind ::value="$data.color" class=" w-full h-10 my-3" />
|
|
56
|
+
</sonic-fetch>
|
|
57
|
+
</template>
|
|
58
|
+
</sonic-states>
|
|
59
|
+
</sonic-theme>
|
|
60
|
+
</template>
|
|
61
|
+
</sonic-code>
|
|
62
|
+
|
|
63
|
+
## Url-pattern
|
|
64
|
+
|
|
65
|
+
Same as RegExp but using <a href="https://www.npmjs.com/package/url-pattern" target="_blank">url patterns</a>
|
|
66
|
+
**e.g.**, data-value="#couleur_<b class="text-danger">:id</b>" => dataProviderExpression="api/unknown/<b class="text-danger">:id</b>"
|
|
67
|
+
|
|
68
|
+
<sonic-code>
|
|
69
|
+
<template>
|
|
70
|
+
<sonic-theme theme="light" serviceURL="https://reqres.in">
|
|
71
|
+
<sonic-list formDataProvider="states-regexp-example" fetch dataProvider="api/unknown" key="data" class="flex gap-2 items-center" >
|
|
72
|
+
<template>
|
|
73
|
+
<sonic-button radio size="xs" name="selection" data-bind ::value="#couleur_$id">
|
|
74
|
+
<span data-bind ::inner-html="ucFirst|$name"></span>
|
|
75
|
+
</sonic-button>
|
|
76
|
+
</template>
|
|
77
|
+
</sonic-list>
|
|
78
|
+
<sonic-states dataProvider="states-regexp-example" data-path="selection">
|
|
79
|
+
<template data-value="#couleur_:id" dataProviderExpression="api/unknown/:id">
|
|
80
|
+
<sonic-fetch>
|
|
81
|
+
<input type="color" disabled data-bind ::value="$data.color" class=" w-full h-10 my-3" />
|
|
82
|
+
</sonic-fetch>
|
|
83
|
+
</template>
|
|
84
|
+
</sonic-states>
|
|
85
|
+
</sonic-theme>
|
|
86
|
+
</template>
|
|
87
|
+
</sonic-code>
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import {LitElement, html} from "lit";
|
|
2
|
+
import {customElement, property} from "lit/decorators.js";
|
|
3
|
+
import Subscriber from "@supersoniks/concorde/core/mixins/Subscriber";
|
|
4
|
+
import {templateContent} from "lit/directives/template-content.js";
|
|
5
|
+
import {repeat} from "lit/directives/repeat.js";
|
|
6
|
+
import Objects from "@supersoniks/concorde/core/utils/Objects";
|
|
7
|
+
import UrlPattern from "url-pattern";
|
|
8
|
+
import TemplatesContainer from "@supersoniks/concorde/core/mixins/TemplatesContainer";
|
|
9
|
+
import {PublisherInterface, TypeAndRecordOfType} from "@supersoniks/concorde/core/_types/types";
|
|
10
|
+
type UrlPatternExtended = {names: string[]} & UrlPattern;
|
|
11
|
+
|
|
12
|
+
const tagName = "sonic-states";
|
|
13
|
+
/**
|
|
14
|
+
* ### sonic-states affiche des états différents en fonction de la valeur d'une sous propriété de son dataProvider (attribut data-path en dot notation):
|
|
15
|
+
* * Il boucle sur ses template enfants et test si la regexp contenue dans l'attribut *data-value* match la valeur de la propriété
|
|
16
|
+
* * Si oui le contenu du template correspontant est affiché comme état.
|
|
17
|
+
* * Si l'attribut dataProviderExpression est fourni le contenu est entouré d'une div :
|
|
18
|
+
* * L'attribut "dataProvider" de cette div est le resultat de l'appel à la fonction replace sur valeur de la propriété avec comme paramettres la regexp et dataproviderExpression.
|
|
19
|
+
* * Les subscribers/fetch... du template se réfèrerons à ce dataProvider
|
|
20
|
+
* * On peut également utiliser les des expressions du type url-pattern pour les paramètres de la route voir les exemples
|
|
21
|
+
*
|
|
22
|
+
* **Exemples**
|
|
23
|
+
* Avec ma.propriete= 2 :
|
|
24
|
+
* * RegExp data-value = (\d+) et dataproviderExpression = /user/$1 l'attribut dataProvider vaudra "/user/2"
|
|
25
|
+
* * url-pattern data-value = :id et dataproviderExpression = /user/:id l'attribut dataProvider vaudra "/user/2"
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
@customElement(tagName)
|
|
30
|
+
export class SonicStates extends Subscriber(TemplatesContainer(LitElement)) {
|
|
31
|
+
@property() state = "";
|
|
32
|
+
@property({type: Boolean, reflect: true}) inverted = false;
|
|
33
|
+
statePath = "";
|
|
34
|
+
onAssign = (value: string) => {
|
|
35
|
+
this.state = value;
|
|
36
|
+
this.requestUpdate();
|
|
37
|
+
};
|
|
38
|
+
statePublisher?: TypeAndRecordOfType<PublisherInterface<string & object>>;
|
|
39
|
+
connectedCallback(): void {
|
|
40
|
+
this.noShadowDom = "";
|
|
41
|
+
super.connectedCallback();
|
|
42
|
+
if (this.hasAttribute("data-path")) {
|
|
43
|
+
this.statePath = this.getAttribute("data-path");
|
|
44
|
+
}
|
|
45
|
+
if (this.statePath) {
|
|
46
|
+
this.statePublisher = this.publisher;
|
|
47
|
+
const split = this.statePath.split(".");
|
|
48
|
+
for (const s of split) {
|
|
49
|
+
this.statePublisher = this.statePublisher[s] as typeof this.statePublisher;
|
|
50
|
+
}
|
|
51
|
+
this.statePublisher.onAssign(this.onAssign);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
disconnectedCallback(): void {
|
|
55
|
+
if (this.statePath) this.statePublisher?.offAssign(this.onAssign);
|
|
56
|
+
super.disconnectedCallback();
|
|
57
|
+
}
|
|
58
|
+
render() {
|
|
59
|
+
const templates = [];
|
|
60
|
+
let state = this.state;
|
|
61
|
+
if ((!Array.isArray(state) && Objects.isObject(state)) || state === undefined) {
|
|
62
|
+
state = "";
|
|
63
|
+
}
|
|
64
|
+
for (const t of this.templatePartsList) {
|
|
65
|
+
let path = t.getAttribute(this.templateValueAttribute) as string;
|
|
66
|
+
let stateToMatch = state;
|
|
67
|
+
|
|
68
|
+
if (this.inverted) {
|
|
69
|
+
stateToMatch = path;
|
|
70
|
+
path = state;
|
|
71
|
+
}
|
|
72
|
+
if (path == "") path = this.inverted ? ".*?" : "^$";
|
|
73
|
+
const regexp = new RegExp(path);
|
|
74
|
+
if (regexp.test(stateToMatch)) {
|
|
75
|
+
templates.push(t);
|
|
76
|
+
t.removeAttribute("mode");
|
|
77
|
+
} else {
|
|
78
|
+
const urlPattern = new UrlPattern(path) as UrlPatternExtended;
|
|
79
|
+
if (urlPattern.names.length > 0 && urlPattern.match(stateToMatch)) {
|
|
80
|
+
t.setAttribute("mode", "patternMatching");
|
|
81
|
+
templates.push(t);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return html`${repeat(
|
|
86
|
+
templates,
|
|
87
|
+
(template, index) => {
|
|
88
|
+
template;
|
|
89
|
+
return index + new Date().getTime();
|
|
90
|
+
},
|
|
91
|
+
(template) => {
|
|
92
|
+
if (template.title) document.title = template.title;
|
|
93
|
+
if (template.hasAttribute("dataProviderExpression")) {
|
|
94
|
+
const dataProviderExpression = template.getAttribute("dataProviderExpression") as string;
|
|
95
|
+
let dataProvider = "";
|
|
96
|
+
let stateToMatch = state;
|
|
97
|
+
let path: string = template.getAttribute(this.templateValueAttribute) as string;
|
|
98
|
+
if (this.inverted) {
|
|
99
|
+
stateToMatch = path;
|
|
100
|
+
path = state;
|
|
101
|
+
}
|
|
102
|
+
if (path == "") path = this.inverted ? "*" : "^$";
|
|
103
|
+
if (template.getAttribute("mode") == "patternMatching") {
|
|
104
|
+
const matcher = new UrlPattern(path);
|
|
105
|
+
const filler = new UrlPattern(dataProviderExpression);
|
|
106
|
+
dataProvider = filler.stringify(matcher.match(stateToMatch));
|
|
107
|
+
} else {
|
|
108
|
+
const regexp = new RegExp(path);
|
|
109
|
+
|
|
110
|
+
const match = (stateToMatch + "").match(regexp);
|
|
111
|
+
if (match) {
|
|
112
|
+
dataProvider = match.shift()?.replace(regexp, dataProviderExpression) as string;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return html`<div style="display:contents" dataProvider="${dataProvider}">${templateContent(template)}</div>`;
|
|
116
|
+
}
|
|
117
|
+
return templateContent(template);
|
|
118
|
+
}
|
|
119
|
+
)}`;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Submit
|
|
2
|
+
|
|
3
|
+
## The submit element is used to send data to a rest service
|
|
4
|
+
* The api is set up like a [fetcher](#core/components/functional/fetch/fetch.md/fetch).
|
|
5
|
+
* The *formDataProvider* attribute points to the adress where the data is held by a publisher.
|
|
6
|
+
* This attribute is also used by form elements such as *sonic-input*, or *sonic-select*, which fill this publisher with their *value* attribute according to their *name* attribute
|
|
7
|
+
* The *method* attribute allows you to choose the sending method: *put/delete/post*, *post* being the default method.
|
|
8
|
+
* If the *onClick* attribute is present, the data is sent when the content is clicked on
|
|
9
|
+
* If the *onEnterKey* attribute is present, data is sent when the enter key of an element contained in the *sonic-submit* with focus is pressed
|
|
10
|
+
* During sending, *sonic-submit* elements with the same *dataProvider* attribute have the *disabled="disabled "* property, which has the effect of disabling their content
|
|
11
|
+
* The *clearedDataOnSuccess* attribute can be used to clear the data from the corresponding dataProvider when the call to the api has provided a result.
|
|
12
|
+
|
|
13
|
+
## Form example
|
|
14
|
+
<sonic-code>
|
|
15
|
+
<template>
|
|
16
|
+
<sonic-scope
|
|
17
|
+
serviceURL="https://reqres.in" dataProvider="api/register"
|
|
18
|
+
formDataProvider="submit-example" submitResultDataProvider="submit-example-result"
|
|
19
|
+
method="post"
|
|
20
|
+
class="max-w-lg block"
|
|
21
|
+
>
|
|
22
|
+
<sonic-submit onEnterKey>
|
|
23
|
+
<div class="grid grid-cols-2 gap-4 mb-4 ">
|
|
24
|
+
<sonic-input required name="email" type="email" value="eve.holt@reqres.in"></sonic-input>
|
|
25
|
+
<sonic-input required type="password" name="password" value="pistol"></sonic-input>
|
|
26
|
+
</div>
|
|
27
|
+
</sonic-submit>
|
|
28
|
+
<sonic-submit onClick>
|
|
29
|
+
<sonic-button type="success" class="w-full">Submit</sonic-button>
|
|
30
|
+
</sonic-submit>
|
|
31
|
+
</sonic-scope>
|
|
32
|
+
</template>
|
|
33
|
+
</sonic-code>
|
|
34
|
+
|
|
35
|
+
## Result handling example
|
|
36
|
+
|
|
37
|
+
Result will show when something has been submit because the **dataprovider** used in this example is the same as the **submitResultDataProvider** used in the previous form.
|
|
38
|
+
<sonic-code>
|
|
39
|
+
<template>
|
|
40
|
+
<div dataProvider="submit-example-result">
|
|
41
|
+
<div>Id : <span data-bind ::inner-html="$id"></span></div>
|
|
42
|
+
<div>Token : <span data-bind ::inner-html="$token"></span></div>
|
|
43
|
+
<div data-bind ::inner-html="$error"></div>
|
|
44
|
+
</div>
|
|
45
|
+
</template>
|
|
46
|
+
</sonic-code>
|
|
47
|
+
|
|
48
|
+
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import "@supersoniks/concorde/core/components/ui/button/button";
|
|
2
|
+
import {
|
|
3
|
+
ConcordeWindow,
|
|
4
|
+
HTMLFormControl,
|
|
5
|
+
} from "@supersoniks/concorde/core/_types/types";
|
|
6
|
+
import { Loader } from "@supersoniks/concorde/core/components/ui/loader/loader";
|
|
7
|
+
import Subscriber from "@supersoniks/concorde/core/mixins/Subscriber";
|
|
8
|
+
import API, { ResultTypeInterface } from "@supersoniks/concorde/core/utils/api";
|
|
9
|
+
import Objects from "@supersoniks/concorde/core/utils/Objects";
|
|
10
|
+
import { PublisherManager } from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
11
|
+
import { Message } from "@supersoniks/concorde/core/_types/types";
|
|
12
|
+
import { HTML } from "@supersoniks/concorde/utils";
|
|
13
|
+
import { css, html, LitElement } from "lit";
|
|
14
|
+
import { customElement, property } from "lit/decorators.js";
|
|
15
|
+
|
|
16
|
+
type SubmitResult =
|
|
17
|
+
| ({ messages: Message[] } & ResultTypeInterface)
|
|
18
|
+
| null
|
|
19
|
+
| undefined;
|
|
20
|
+
const tagName = "sonic-submit";
|
|
21
|
+
|
|
22
|
+
declare const window: ConcordeWindow;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* ###L'élément submit permet d'envoyer des données en rest
|
|
26
|
+
* * Les données envoyées sont celles présentes dans le publisher dont l'adresse est renseignée via l'attribut *formDataProvider*.
|
|
27
|
+
* Cet attribut est également utilisé par les éléments de form comme *sonic-input*, ou *sonic-select*, qui remplissent ce publisher avec leur attribut *value* en fonction de leur attribut *name*
|
|
28
|
+
* * L'api est configuré à la manière d'un fetcher.
|
|
29
|
+
* * L'attribut *method* permet de choisir la méthode d'envoie : *put/delete/post*, *post* étant la méthode par défaut.
|
|
30
|
+
* * Si l'attribut *onClick* est présent, les données sont envoyées quand on click dans son contenu
|
|
31
|
+
* * Si l'attribut *onEnterKey* est présent, les données sont envoyées quand on appuie sur la touche entrée d'un élément contenu dans le *sonic-submit* ayant le focus
|
|
32
|
+
* * Pendant l'envoi, les éléments *sonic-submit* ayant le même attribut *dataProvider* ont la propriété *disabled="disabled"* ce qui a pour effet de désactiver leur contenu
|
|
33
|
+
* * L'attribut *clearedDataOnSuccess* peut être utilisé pour vider les données des dataProvider correspondants lorsque l'appel à l'api a fourni un résultat.
|
|
34
|
+
*/
|
|
35
|
+
@customElement(tagName)
|
|
36
|
+
export class Submit extends Subscriber(LitElement) {
|
|
37
|
+
static styles = css`
|
|
38
|
+
[data-disabled] {
|
|
39
|
+
opacity: 0.3;
|
|
40
|
+
pointer-events: none;
|
|
41
|
+
user-select: none;
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
@property({ type: String }) submitResultKey: string | null = null;
|
|
45
|
+
@property({ type: Boolean }) disabled = false;
|
|
46
|
+
@property({ type: String }) endPoint: string | null = null;
|
|
47
|
+
@property() name = "";
|
|
48
|
+
@property() value = "";
|
|
49
|
+
api: API | null = null;
|
|
50
|
+
|
|
51
|
+
connectedCallback() {
|
|
52
|
+
if (this.hasAttribute("onClick")) {
|
|
53
|
+
this.addEventListener("click", () => this.submit());
|
|
54
|
+
}
|
|
55
|
+
if (this.hasAttribute("onEnterKey")) {
|
|
56
|
+
this.addEventListener("keydown", (e: KeyboardEvent) => {
|
|
57
|
+
if (e.key === "Enter") this.submit();
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
super.connectedCallback();
|
|
61
|
+
this.api = new API(this.getApiConfiguration());
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
submitNativeForm() {
|
|
65
|
+
const form: HTMLFormElement = HTML.getClosestForm(this) as HTMLFormElement;
|
|
66
|
+
if (!form) return;
|
|
67
|
+
const formDataProvider = this.getAncestorAttributeValue("formDataProvider");
|
|
68
|
+
const formData = PublisherManager.get(formDataProvider).get();
|
|
69
|
+
for (const name in formData) {
|
|
70
|
+
if (name == "isFormValid") continue;
|
|
71
|
+
let control = form.querySelector(
|
|
72
|
+
'input[name="' +
|
|
73
|
+
name +
|
|
74
|
+
'"], select[name="' +
|
|
75
|
+
name +
|
|
76
|
+
'"], textarea[name="' +
|
|
77
|
+
name +
|
|
78
|
+
'"]'
|
|
79
|
+
) as HTMLFormControl;
|
|
80
|
+
|
|
81
|
+
if (!control) {
|
|
82
|
+
control = document.createElement("input");
|
|
83
|
+
control.type = "hidden";
|
|
84
|
+
control.name = name;
|
|
85
|
+
form.appendChild(control);
|
|
86
|
+
}
|
|
87
|
+
let value = formData[name];
|
|
88
|
+
if (Array.isArray(value)) value = value.join(",");
|
|
89
|
+
if (control.type === "checkbox" || control.type === "radio") {
|
|
90
|
+
if (value) (control as HTMLInputElement).checked = true;
|
|
91
|
+
} else {
|
|
92
|
+
control.value = value;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const submitButton = document.createElement("input") as HTMLInputElement;
|
|
96
|
+
submitButton.name = this.name;
|
|
97
|
+
submitButton.style.display = "none";
|
|
98
|
+
submitButton.value = this.value;
|
|
99
|
+
submitButton.type = "submit";
|
|
100
|
+
form.appendChild(submitButton);
|
|
101
|
+
if (submitButton) submitButton.click();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async submit() {
|
|
105
|
+
const formPublisher = PublisherManager.getInstance().get(
|
|
106
|
+
this.getAncestorAttributeValue("formDataProvider")
|
|
107
|
+
);
|
|
108
|
+
//
|
|
109
|
+
// Validation du formulaire
|
|
110
|
+
formPublisher.isFormValid = true;
|
|
111
|
+
formPublisher.invalidate();
|
|
112
|
+
if (!formPublisher.isFormValid.get()) return;
|
|
113
|
+
if (this.publisher) this.publisher.disabled = true;
|
|
114
|
+
formPublisher.isFormValid;
|
|
115
|
+
// support native html form
|
|
116
|
+
const native = this.hasAttribute("native");
|
|
117
|
+
if (native) {
|
|
118
|
+
this.submitNativeForm();
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
//
|
|
122
|
+
//Recup données
|
|
123
|
+
const method = this.getAttribute("method")?.toLocaleLowerCase() || "post";
|
|
124
|
+
|
|
125
|
+
const sendAsFormData = this.hasAttribute("sendAsFormData");
|
|
126
|
+
const formData = formPublisher.get();
|
|
127
|
+
delete formData.isFormValid;
|
|
128
|
+
const headesDataProvider = this.getAncestorAttributeValue(
|
|
129
|
+
"headersDataProvider"
|
|
130
|
+
);
|
|
131
|
+
const headerPublisher = headesDataProvider
|
|
132
|
+
? PublisherManager.getInstance().get(headesDataProvider)
|
|
133
|
+
: null;
|
|
134
|
+
let headerData = {};
|
|
135
|
+
if (headerPublisher) headerData = headerPublisher.get();
|
|
136
|
+
let result: SubmitResult = null;
|
|
137
|
+
const dataProvider = this.getAncestorAttributeValue("dataProvider");
|
|
138
|
+
const endPoint = this.endPoint || dataProvider;
|
|
139
|
+
Loader.show();
|
|
140
|
+
const sendData = async () => {
|
|
141
|
+
//
|
|
142
|
+
//envoi données
|
|
143
|
+
if (sendAsFormData) {
|
|
144
|
+
result = await this.api?.submitFormData(
|
|
145
|
+
endPoint,
|
|
146
|
+
formData,
|
|
147
|
+
method,
|
|
148
|
+
headerData
|
|
149
|
+
);
|
|
150
|
+
} else {
|
|
151
|
+
switch (method) {
|
|
152
|
+
case "put":
|
|
153
|
+
result = await this.api?.put(endPoint, formData, headerData);
|
|
154
|
+
break;
|
|
155
|
+
case "delete":
|
|
156
|
+
result = await this.api?.delete(endPoint, formData, headerData);
|
|
157
|
+
break;
|
|
158
|
+
case "get":
|
|
159
|
+
// add formData to endpoint
|
|
160
|
+
const params = new URLSearchParams();
|
|
161
|
+
if (formData) {
|
|
162
|
+
for (const key in formData) {
|
|
163
|
+
params.append(key, formData[key]);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
const paramString = "?" + params.toString();
|
|
167
|
+
result = await this.api?.get(endPoint + paramString, headerData);
|
|
168
|
+
break;
|
|
169
|
+
default:
|
|
170
|
+
result = await this.api?.post(endPoint, formData, headerData);
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
Loader.hide();
|
|
176
|
+
if (!result)
|
|
177
|
+
result = { messages: [{ content: "Network Error", status: "error" }] };
|
|
178
|
+
// Si result ne contient que la réponse HTTP, avec un status not ok, on ajoute un message
|
|
179
|
+
else if (
|
|
180
|
+
result._sonic_http_response_ &&
|
|
181
|
+
!result._sonic_http_response_.ok &&
|
|
182
|
+
Object.keys(result).length === 1
|
|
183
|
+
)
|
|
184
|
+
result.messages = [{ content: "Network Error", status: "error" }];
|
|
185
|
+
const clearedDataProvider = this.getAncestorAttributeValue(
|
|
186
|
+
"clearedDataOnSuccess"
|
|
187
|
+
);
|
|
188
|
+
if (clearedDataProvider) {
|
|
189
|
+
clearedDataProvider
|
|
190
|
+
.split(" ")
|
|
191
|
+
.forEach((dataProvider) =>
|
|
192
|
+
PublisherManager.get(dataProvider).set({})
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const username_key = this.hasAttribute("usernameKey")
|
|
197
|
+
? this.getAttribute("usernameKey")
|
|
198
|
+
: "username";
|
|
199
|
+
const password_key = this.hasAttribute("passwordKey")
|
|
200
|
+
? this.getAttribute("passwordKey")
|
|
201
|
+
: "password";
|
|
202
|
+
if (
|
|
203
|
+
this.api?.lastResult?.ok &&
|
|
204
|
+
formData[username_key] &&
|
|
205
|
+
formData[password_key]
|
|
206
|
+
) {
|
|
207
|
+
this.saveCredentials(formData[username_key], formData[password_key]);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (this.submitResultKey) {
|
|
211
|
+
result = Objects.traverse(
|
|
212
|
+
result,
|
|
213
|
+
this.submitResultKey.split("."),
|
|
214
|
+
true
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
const submitResultDataProvider = this.getAncestorAttributeValue(
|
|
218
|
+
"submitResultDataProvider"
|
|
219
|
+
);
|
|
220
|
+
if (submitResultDataProvider)
|
|
221
|
+
PublisherManager.get(submitResultDataProvider).set(result);
|
|
222
|
+
if (this.publisher) this.publisher.disabled = null;
|
|
223
|
+
};
|
|
224
|
+
const captchaPublisher = headerPublisher?.needsCaptchaValidation.get()
|
|
225
|
+
? headerPublisher
|
|
226
|
+
: formPublisher.needsCaptchaValidation.get()
|
|
227
|
+
? formPublisher
|
|
228
|
+
: null;
|
|
229
|
+
if (captchaPublisher) {
|
|
230
|
+
captchaPublisher.captchaMethod = method;
|
|
231
|
+
captchaPublisher.captchaAction =
|
|
232
|
+
dataProvider?.split("?")[0] ??
|
|
233
|
+
this.getAncestorAttributeValue("formDataProvider") ??
|
|
234
|
+
"submit";
|
|
235
|
+
captchaPublisher.captchaToken = "request_token";
|
|
236
|
+
const captchaAssign = (token?: string) => {
|
|
237
|
+
if (token != "request_token" && token != "") {
|
|
238
|
+
sendData();
|
|
239
|
+
// Après l'envoie des données, on supprime ce onAssign.
|
|
240
|
+
// Sinon les handler se cumuleraient après plusieurs submit consécutifs.
|
|
241
|
+
captchaPublisher.captchaToken.offAssign(captchaAssign);
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
captchaPublisher.captchaToken.onAssign(captchaAssign);
|
|
245
|
+
} else {
|
|
246
|
+
sendData();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
async saveCredentials(username: string, password: string) {
|
|
251
|
+
// Check if the browser supports password credentials (and the Credential Management API)
|
|
252
|
+
if ("PasswordCredential" in window) {
|
|
253
|
+
const credential = new window.PasswordCredential({
|
|
254
|
+
id: username,
|
|
255
|
+
// name: "Carina Anand", // In case of a login, the name comes from the server.
|
|
256
|
+
password: password,
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
await navigator.credentials.store(credential);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
protected render(): unknown {
|
|
263
|
+
return html`<div ?data-disabled=${this.disabled}><slot></slot></div>`;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Subscriber
|
|
2
|
+
|
|
3
|
+
La mixin Subscriber permet lier un composant à un publisher.
|
|
4
|
+
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).
|
|
5
|
+
|
|
6
|
+
Les propriétés du composant sont automatiquement remplies avec les propriétés du même nom dans les données du publisher.
|
|
7
|
+
|
|
8
|
+
Le composant est automatiquement mis à jour lorsque les données du publisher sont mises à jour.
|
|
9
|
+
|
|
10
|
+
## DataProvider
|
|
11
|
+
|
|
12
|
+
**Id** of the dataProvider that the component will **subscribe** to
|
|
13
|
+
|
|
14
|
+
<sonic-code>
|
|
15
|
+
<template>
|
|
16
|
+
<sonic-subscriber dataProvider="id_that_the_subsriber_will_subscribe_to" debug>
|
|
17
|
+
<sonic-button> custom dataProvider id</sonic-button>
|
|
18
|
+
</sonic-subscriber>
|
|
19
|
+
<sonic-subscriber debug>
|
|
20
|
+
<sonic-button> default id : pageHTML</sonic-button>
|
|
21
|
+
</sonic-subscriber>
|
|
22
|
+
</template>
|
|
23
|
+
</sonic-code>
|
|
24
|
+
|
|
25
|
+
## Props
|
|
26
|
+
|
|
27
|
+
Data object (json) that will be passed to the dataProvider
|
|
28
|
+
|
|
29
|
+
<sonic-code>
|
|
30
|
+
<template>
|
|
31
|
+
<sonic-subscriber props='{"data":"Hello world"}' debug>
|
|
32
|
+
<sonic-button> Hover to see the data</sonic-button>
|
|
33
|
+
</sonic-subscriber>
|
|
34
|
+
</template>
|
|
35
|
+
</sonic-code>
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## Debug
|
|
39
|
+
|
|
40
|
+
**Helper**, display the data held by the dataProvider in a floating div
|
|
41
|
+
|
|
42
|
+
<sonic-code>
|
|
43
|
+
<template>
|
|
44
|
+
<sonic-subscriber debug>
|
|
45
|
+
<sonic-button> see the dataProvider'data </sonic-button>
|
|
46
|
+
</sonic-subscriber>
|
|
47
|
+
</template>
|
|
48
|
+
</sonic-code>
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
## NoAutofill
|
|
52
|
+
|
|
53
|
+
<sonic-alert status="info">Docs coming soon</sonic-alert>
|
|
54
|
+
|
|
55
|
+
## PropertyMap
|
|
56
|
+
|
|
57
|
+
<sonic-alert status="info">Docs coming soon</sonic-alert>
|
|
58
|
+
|
|
59
|
+
Permet de mapper un nom de propriété de donnée source vers une propriété du subscriber à la volée
|
|
60
|
+
|
|
61
|
+
## BindPublisher
|
|
62
|
+
|
|
63
|
+
<sonic-alert status="info">Docs coming soon</sonic-alert>
|
|
64
|
+
|
|
65
|
+
On peut utiliser cette fonction pour lier un publisher spécifique au composant si besoin.
|
|
66
|
+
|
|
67
|
+
## instanceCounter
|
|
68
|
+
|
|
69
|
+
<sonic-alert status="info">Docs coming soon</sonic-alert>
|
|
70
|
+
|
|
71
|
+
## Publisher
|
|
72
|
+
|
|
73
|
+
<sonic-alert status="info">Docs coming soon</sonic-alert>
|
|
74
|
+
|
|
75
|
+
## Args
|
|
76
|
+
|
|
77
|
+
<sonic-alert status="info">Docs coming soon</sonic-alert>
|
|
78
|
+
|
|
79
|
+
## NoShadowDom
|
|
80
|
+
|
|
81
|
+
Par défaut on crée un shadow dom mais on peut demander à ne pas en avoir via cette propriété et un attribut associé.
|
|
82
|
+
Cela se fait à l'initialisation uniquement et n'est pas modifiable lors de la vie du composant.
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
## Other attributes gathered from subscriber.stories.ts
|
|
86
|
+
|
|
87
|
+
styles ??
|
|
88
|
+
title ??
|
|
89
|
+
_props ??
|
|
90
|
+
onAssign ??
|
|
91
|
+
defferedDebug ??
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {html, LitElement, PropertyValues} from "lit";
|
|
2
|
+
import {customElement} from "lit/decorators.js";
|
|
3
|
+
import Subscriber from "@supersoniks/concorde/core/mixins/Subscriber";
|
|
4
|
+
const tagName = "sonic-subscriber";
|
|
5
|
+
/**
|
|
6
|
+
* Voir la partie dédiée dans *MISCALLENOUS*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
@customElement(tagName)
|
|
10
|
+
export class SonicSubscriber extends Subscriber(LitElement) {
|
|
11
|
+
noAutofill = true;
|
|
12
|
+
connectedCallback(): void {
|
|
13
|
+
this.noShadowDom = "";
|
|
14
|
+
super.connectedCallback();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
updated(changedProperties: PropertyValues) {
|
|
18
|
+
super.updated(changedProperties);
|
|
19
|
+
|
|
20
|
+
// Display contents, notamment pour les layout dans tableaux
|
|
21
|
+
if (this.children.length == 0) this.style.display = "none";
|
|
22
|
+
else this.style.display = "contents";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
render() {
|
|
26
|
+
return html`<slot></slot> `;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Value
|
|
2
|
+
|
|
3
|
+
Simply shows a value from a data provider.
|
|
4
|
+
You can target sub data value using dot syntax.
|
|
5
|
+
The value reacts to changes.
|
|
6
|
+
|
|
7
|
+
* Below is a form that helps you to set a value for the field "preference" in the data target with id "value-example"
|
|
8
|
+
<sonic-code>
|
|
9
|
+
<template>
|
|
10
|
+
<div formDataProvider="value-example">
|
|
11
|
+
which one do you prefer ?
|
|
12
|
+
<sonic-radio name="preference" checked value="dogs"> Dogs</sonic-radio>
|
|
13
|
+
<sonic-radio name="preference" value="cats"> Cats</sonic-radio>
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
16
|
+
</sonic-code>
|
|
17
|
+
* Then you can see live value of the preference using this code :
|
|
18
|
+
<sonic-code>
|
|
19
|
+
<template>
|
|
20
|
+
I prefer <sonic-value dataProvider="value-example" key="preference"></sonic-value>
|
|
21
|
+
</template>
|
|
22
|
+
</sonic-code>
|
|
23
|
+
* If you have more complex data like this
|
|
24
|
+
<sonic-code>
|
|
25
|
+
<template>
|
|
26
|
+
<sonic-subscriber dataProvider="value-example-2" props='{"my":{"complex":[{"data":"👋 Hi There"}]}}'></sonic-subscriber>
|
|
27
|
+
</template>
|
|
28
|
+
</sonic-code>
|
|
29
|
+
* You can target it with the dot syntax
|
|
30
|
+
<sonic-code>
|
|
31
|
+
<template>
|
|
32
|
+
<sonic-value dataProvider="value-example-2" key="my.complex.0.data"></sonic-value>
|
|
33
|
+
</template>
|
|
34
|
+
</sonic-code>
|
|
35
|
+
|