@supersoniks/concorde 2.0.6 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-infos.json +1 -0
- package/index.html +44 -0
- package/notes de migration.md +21 -0
- package/package.json +23 -287
- package/scripts/prebuild.mjs +22 -0
- package/{components.js → src/components.ts} +5 -2
- package/src/concorde-loaded.ts +3 -0
- package/src/core/_types/types.ts +55 -0
- package/src/core/components/functional/date/date.md +290 -0
- package/src/core/components/functional/date/date.ts +206 -0
- package/src/core/components/functional/example/example.ts +11 -0
- package/src/core/components/functional/fetch/fetch.md +117 -0
- package/{core/components/functional/fetch/fetch.js → src/core/components/functional/fetch/fetch.ts} +33 -37
- package/src/core/components/functional/if/if.md +16 -0
- package/src/core/components/functional/if/if.test.ts +40 -0
- package/src/core/components/functional/if/if.ts +23 -0
- package/src/core/components/functional/list/list.md +194 -0
- package/src/core/components/functional/list/list.ts +236 -0
- package/src/core/components/functional/mix/mix.md +41 -0
- package/src/core/components/functional/mix/mix.ts +95 -0
- package/src/core/components/functional/queue/queue.md +87 -0
- package/src/core/components/functional/queue/queue.ts +279 -0
- package/src/core/components/functional/router/redirect.ts +44 -0
- package/src/core/components/functional/router/router.md +112 -0
- package/src/core/components/functional/router/router.ts +108 -0
- package/src/core/components/functional/sdui/SDUIDescriptorTransformer.ts +229 -0
- package/{core → src/core}/components/functional/sdui/default-library.json +13 -13
- package/src/core/components/functional/sdui/example.json +99 -0
- package/src/core/components/functional/sdui/sdui-utils.ts +62 -0
- package/src/core/components/functional/sdui/sdui.md +356 -0
- package/src/core/components/functional/sdui/sdui.ts +230 -0
- package/src/core/components/functional/sdui/types.ts +34 -0
- package/src/core/components/functional/sonic-scope/sonic-scope.ts +13 -0
- package/src/core/components/functional/states/states.md +87 -0
- package/src/core/components/functional/states/states.ts +121 -0
- package/src/core/components/functional/submit/submit.md +48 -0
- package/src/core/components/functional/submit/submit.ts +265 -0
- package/src/core/components/functional/subscriber/subscriber.md +91 -0
- package/src/core/components/functional/subscriber/subscriber.ts +28 -0
- package/src/core/components/functional/value/value.md +35 -0
- package/src/core/components/functional/value/value.ts +18 -0
- package/{core/components/ui/_css/scroll.js → src/core/components/ui/_css/scroll.ts} +3 -2
- package/{core/components/ui/_css/size.js → src/core/components/ui/_css/size.ts} +5 -2
- package/{core/components/ui/_css/type.js → src/core/components/ui/_css/type.ts} +5 -3
- package/src/core/components/ui/alert/alert.md +121 -0
- package/src/core/components/ui/alert/alert.ts +177 -0
- package/src/core/components/ui/badge/badge.md +102 -0
- package/{core/components/ui/badge/badge.js → src/core/components/ui/badge/badge.ts} +36 -51
- package/src/core/components/ui/button/button.md +184 -0
- package/{core/components/ui/button/button.js → src/core/components/ui/button/button.ts} +258 -302
- package/src/core/components/ui/captcha/captcha.md +12 -0
- package/src/core/components/ui/captcha/captcha.ts +88 -0
- package/src/core/components/ui/card/card-footer.ts +19 -0
- package/src/core/components/ui/card/card-header-descripton.ts +24 -0
- package/{core/components/ui/card/card-header.js → src/core/components/ui/card/card-header.ts} +28 -38
- package/src/core/components/ui/card/card-main.ts +24 -0
- package/src/core/components/ui/card/card.md +96 -0
- package/{core/components/ui/card/card.js → src/core/components/ui/card/card.ts} +23 -34
- package/src/core/components/ui/divider/divider.md +35 -0
- package/{core/components/ui/divider/divider.js → src/core/components/ui/divider/divider.ts} +35 -65
- package/src/core/components/ui/form/checkbox/checkbox.md +96 -0
- package/{core/components/ui/form/checkbox/checkbox.js → src/core/components/ui/form/checkbox/checkbox.ts} +79 -98
- package/{core/components/ui/form/css/form-control.js → src/core/components/ui/form/css/form-control.ts} +9 -5
- package/src/core/components/ui/form/fieldset/fieldset.md +129 -0
- package/src/core/components/ui/form/fieldset/fieldset.ts +96 -0
- package/src/core/components/ui/form/fieldset/legend-description.ts +23 -0
- package/src/core/components/ui/form/fieldset/legend.ts +90 -0
- package/src/core/components/ui/form/form-actions/form-actions.md +77 -0
- package/src/core/components/ui/form/form-actions/form-actions.ts +32 -0
- package/src/core/components/ui/form/form-layout/form-layout.md +43 -0
- package/src/core/components/ui/form/form-layout/form-layout.ts +71 -0
- package/src/core/components/ui/form/input/input.md +168 -0
- package/src/core/components/ui/form/input/input.ts +227 -0
- package/src/core/components/ui/form/input/password-helper.ts +68 -0
- package/src/core/components/ui/form/input/same-value-helper.ts +48 -0
- package/src/core/components/ui/form/input-autocomplete/input-autocomplete.md +130 -0
- package/src/core/components/ui/form/input-autocomplete/input-autocomplete.ts +285 -0
- package/src/core/components/ui/form/radio/radio.md +86 -0
- package/src/core/components/ui/form/radio/radio.ts +44 -0
- package/src/core/components/ui/form/select/select.md +99 -0
- package/src/core/components/ui/form/select/select.ts +310 -0
- package/src/core/components/ui/form/textarea/textarea.md +66 -0
- package/src/core/components/ui/form/textarea/textarea.ts +119 -0
- package/src/core/components/ui/group/group.md +75 -0
- package/src/core/components/ui/group/group.ts +101 -0
- package/src/core/components/ui/icon/icon.md +125 -0
- package/src/core/components/ui/icon/icon.stories.ts +100 -0
- package/src/core/components/ui/icon/icon.ts +106 -0
- package/src/core/components/ui/icon/icons.json +1 -0
- package/src/core/components/ui/icon/icons.ts +130 -0
- package/src/core/components/ui/icon/svgs/cancel.svg +3 -0
- package/src/core/components/ui/icon/svgs/check-circled-outline.svg +4 -0
- package/src/core/components/ui/icon/svgs/check.svg +3 -0
- package/src/core/components/ui/icon/svgs/emoji-puzzled.svg +1 -0
- package/src/core/components/ui/icon/svgs/info-empty.svg +5 -0
- package/src/core/components/ui/icon/svgs/loader.svg +1 -0
- package/src/core/components/ui/icon/svgs/minus-small.svg +3 -0
- package/src/core/components/ui/icon/svgs/more-horiz.svg +5 -0
- package/src/core/components/ui/icon/svgs/more-vert.svg +5 -0
- package/src/core/components/ui/icon/svgs/nav-arrow-down.svg +3 -0
- package/src/core/components/ui/icon/svgs/warning-circled-outline.svg +5 -0
- package/src/core/components/ui/image/image.md +107 -0
- package/src/core/components/ui/image/image.ts +117 -0
- package/src/core/components/ui/link/link.md +43 -0
- package/src/core/components/ui/link/link.ts +108 -0
- package/src/core/components/ui/loader/loader.md +37 -0
- package/src/core/components/ui/loader/loader.stories.ts +25 -0
- package/src/core/components/ui/loader/loader.ts +81 -0
- package/{core/components/ui/loader/styles/fixed.js → src/core/components/ui/loader/styles/fixed.ts} +2 -1
- package/{core/components/ui/loader/styles/inline.js → src/core/components/ui/loader/styles/inline.ts} +3 -2
- package/src/core/components/ui/menu/menu-item.ts +30 -0
- package/src/core/components/ui/menu/menu.md +288 -0
- package/src/core/components/ui/menu/menu.ts +292 -0
- package/src/core/components/ui/modal/modal-actions.ts +35 -0
- package/src/core/components/ui/modal/modal-close.ts +36 -0
- package/src/core/components/ui/modal/modal-content.ts +19 -0
- package/src/core/components/ui/modal/modal-subtitle.ts +23 -0
- package/src/core/components/ui/modal/modal-title.ts +22 -0
- package/src/core/components/ui/modal/modal.md +123 -0
- package/src/core/components/ui/modal/modal.stories.ts +140 -0
- package/src/core/components/ui/modal/modal.ts +386 -0
- package/src/core/components/ui/pop/pop.md +79 -0
- package/src/core/components/ui/pop/pop.ts +291 -0
- package/src/core/components/ui/progress/progress.md +65 -0
- package/{core/components/ui/progress/progress.js → src/core/components/ui/progress/progress.ts} +31 -50
- package/src/core/components/ui/table/table-caption.ts +21 -0
- package/src/core/components/ui/table/table-tbody.ts +32 -0
- package/src/core/components/ui/table/table-td.ts +47 -0
- package/src/core/components/ui/table/table-tfoot.ts +20 -0
- package/src/core/components/ui/table/table-th.ts +56 -0
- package/src/core/components/ui/table/table-thead.ts +18 -0
- package/src/core/components/ui/table/table-tr.ts +48 -0
- package/src/core/components/ui/table/table.md +467 -0
- package/{core/components/ui/table/table.js → src/core/components/ui/table/table.ts} +32 -53
- package/{core/components/ui/theme/theme-collection/core-variables.js → src/core/components/ui/theme/theme-collection/core-variables.ts} +3 -2
- package/{core/components/ui/theme/theme-collection/dark.js → src/core/components/ui/theme/theme-collection/dark.ts} +5 -3
- package/{core/components/ui/theme/theme-collection/light.js → src/core/components/ui/theme/theme-collection/light.ts} +3 -2
- package/src/core/components/ui/theme/theme.ts +118 -0
- package/src/core/components/ui/toast/message-subscriber.stories.ts +43 -0
- package/src/core/components/ui/toast/message-subscriber.ts +37 -0
- package/{core/components/ui/toast/toast-item.js → src/core/components/ui/toast/toast-item.ts} +86 -113
- package/src/core/components/ui/toast/toast.ts +237 -0
- package/src/core/components/ui/toast/types.ts +14 -0
- package/src/core/components/ui/tooltip/tooltip.md +37 -0
- package/{core/components/ui/tooltip/tooltip.js → src/core/components/ui/tooltip/tooltip.ts} +26 -47
- package/{core/components/ui/ui.js → src/core/components/ui/ui.ts} +2 -0
- package/src/core/core.ts +22 -0
- package/src/core/decorators/Subscriber.ts +187 -0
- package/src/core/directives/DataProvider.ts +113 -0
- package/src/core/directives/Wording.ts +220 -0
- package/src/core/mixins/Fetcher.ts +258 -0
- package/src/core/mixins/FormCheckable.ts +287 -0
- package/src/core/mixins/FormElement.ts +275 -0
- package/src/core/mixins/FormInput.ts +135 -0
- package/src/core/mixins/Subscriber.ts +352 -0
- package/src/core/mixins/TemplatesContainer.ts +70 -0
- package/{core/mixins/mixins.d.ts → src/core/mixins/mixins.ts} +1 -1
- package/src/core/utils/Arrays.ts +161 -0
- package/src/core/utils/DataBindObserver.ts +286 -0
- package/src/core/utils/Electron.ts +15 -0
- package/src/core/utils/Format.ts +58 -0
- package/src/core/utils/HTML.ts +126 -0
- package/src/core/utils/LocationHandler.ts +139 -0
- package/src/core/utils/Objects.ts +103 -0
- package/src/core/utils/PublisherProxy.ts +786 -0
- package/src/core/utils/Utils.ts +12 -0
- package/src/core/utils/api.ts +456 -0
- package/{core/utils/url-pattern.d.ts → src/core/utils/url-pattern.ts} +1 -0
- package/{decorators.js → src/decorators.ts} +6 -2
- package/{directives.js → src/directives.ts} +11 -6
- package/src/docs/_core-concept/overview.md +57 -0
- package/src/docs/_core-concept/subscriber.md +76 -0
- package/src/docs/_getting-started/concorde-outside.md +141 -0
- package/src/docs/_getting-started/create-a-component.md +137 -0
- package/src/docs/_getting-started/pubsub.md +150 -0
- package/src/docs/_getting-started/start.md +37 -0
- package/src/docs/_getting-started/theming.md +91 -0
- package/src/docs/code.ts +281 -0
- package/src/docs/docs.ts +6 -0
- package/src/docs/example/users.ts +64 -0
- package/src/docs/navigation/navigation.ts +101 -0
- package/src/docs/prism/index.ts +6 -0
- package/src/docs/prism/prism.css +158 -0
- package/src/docs/prism/prism.js +1022 -0
- package/src/docs/search/docs-search.json +3767 -0
- package/src/docs/search/markdown-renderer.ts +40 -0
- package/src/docs/search/page.ts +40 -0
- package/src/docs/search/search.ts +184 -0
- package/src/docs.ts +2 -0
- package/src/index.ts +7 -0
- package/{mixins.js → src/mixins.ts} +10 -6
- package/src/tag-list.json +1 -0
- package/src/test-utils/TestUtils.ts +13 -0
- package/src/tsconfig.json +113 -0
- package/{utils.js → src/utils.ts} +15 -11
- package/test-utils/TestUtils.ts +13 -0
- package/vite/config.js +136 -0
- package/vite.config.mts +87 -0
- package/README.md +0 -27
- package/cli.js +0 -74
- package/components.d.ts +0 -4
- package/concorde-core.bundle.js +0 -3427
- package/concorde-core.es.js +0 -14199
- package/core/_types/types.d.ts +0 -28
- package/core/_types/types.js +0 -2
- package/core/components/functional/date/date.d.ts +0 -45
- package/core/components/functional/date/date.js +0 -243
- package/core/components/functional/example/example.d.ts +0 -7
- package/core/components/functional/example/example.js +0 -26
- package/core/components/functional/fetch/fetch.d.ts +0 -93
- package/core/components/functional/functional.js +0 -15
- package/core/components/functional/if/if.d.ts +0 -12
- package/core/components/functional/if/if.js +0 -38
- package/core/components/functional/if/if.test.d.ts +0 -1
- package/core/components/functional/if/if.test.js +0 -35
- package/core/components/functional/list/list.d.ts +0 -117
- package/core/components/functional/list/list.js +0 -214
- package/core/components/functional/mix/mix.d.ts +0 -22
- package/core/components/functional/mix/mix.js +0 -102
- package/core/components/functional/queue/queue.d.ts +0 -67
- package/core/components/functional/queue/queue.js +0 -310
- package/core/components/functional/router/redirect.d.ts +0 -18
- package/core/components/functional/router/redirect.js +0 -53
- package/core/components/functional/router/router.d.ts +0 -27
- package/core/components/functional/router/router.js +0 -119
- package/core/components/functional/sdui/SDUIDescriptorTransformer.d.ts +0 -58
- package/core/components/functional/sdui/SDUIDescriptorTransformer.js +0 -215
- package/core/components/functional/sdui/sdui-utils.d.ts +0 -5
- package/core/components/functional/sdui/sdui-utils.js +0 -63
- package/core/components/functional/sdui/sdui.d.ts +0 -136
- package/core/components/functional/sdui/sdui.js +0 -254
- package/core/components/functional/sdui/types.d.ts +0 -37
- package/core/components/functional/sdui/types.js +0 -1
- package/core/components/functional/sonic-scope/sonic-scope.d.ts +0 -5
- package/core/components/functional/sonic-scope/sonic-scope.js +0 -21
- package/core/components/functional/states/states.d.ts +0 -29
- package/core/components/functional/states/states.js +0 -134
- package/core/components/functional/submit/submit.d.ts +0 -30
- package/core/components/functional/submit/submit.js +0 -236
- package/core/components/functional/subscriber/subscriber.d.ts +0 -12
- package/core/components/functional/subscriber/subscriber.js +0 -38
- package/core/components/functional/value/value.d.ts +0 -7
- package/core/components/functional/value/value.js +0 -27
- package/core/components/ui/_css/scroll.d.ts +0 -1
- package/core/components/ui/_css/size.d.ts +0 -2
- package/core/components/ui/_css/type.d.ts +0 -2
- package/core/components/ui/alert/alert.d.ts +0 -34
- package/core/components/ui/alert/alert.js +0 -202
- package/core/components/ui/badge/badge.d.ts +0 -26
- package/core/components/ui/button/button.d.ts +0 -171
- package/core/components/ui/captcha/captcha.d.ts +0 -30
- package/core/components/ui/captcha/captcha.js +0 -93
- package/core/components/ui/card/card-footer.d.ts +0 -4
- package/core/components/ui/card/card-footer.js +0 -24
- package/core/components/ui/card/card-header-descripton.d.ts +0 -5
- package/core/components/ui/card/card-header-descripton.js +0 -32
- package/core/components/ui/card/card-header.d.ts +0 -8
- package/core/components/ui/card/card-main.d.ts +0 -4
- package/core/components/ui/card/card-main.js +0 -28
- package/core/components/ui/card/card.d.ts +0 -12
- package/core/components/ui/divider/divider.d.ts +0 -15
- package/core/components/ui/form/checkbox/checkbox.d.ts +0 -181
- package/core/components/ui/form/css/form-control.d.ts +0 -4
- package/core/components/ui/form/fieldset/fieldset.d.ts +0 -23
- package/core/components/ui/form/fieldset/fieldset.js +0 -118
- package/core/components/ui/form/fieldset/legend-description.d.ts +0 -5
- package/core/components/ui/form/fieldset/legend-description.js +0 -30
- package/core/components/ui/form/fieldset/legend.d.ts +0 -16
- package/core/components/ui/form/fieldset/legend.js +0 -112
- package/core/components/ui/form/form-actions/form-actions.d.ts +0 -7
- package/core/components/ui/form/form-actions/form-actions.js +0 -46
- package/core/components/ui/form/form-layout/form-layout.d.ts +0 -12
- package/core/components/ui/form/form-layout/form-layout.js +0 -83
- package/core/components/ui/form/input/input.d.ts +0 -106
- package/core/components/ui/form/input/input.js +0 -268
- package/core/components/ui/form/input/password-helper.d.ts +0 -25
- package/core/components/ui/form/input/password-helper.js +0 -119
- package/core/components/ui/form/input/same-value-helper.d.ts +0 -16
- package/core/components/ui/form/input/same-value-helper.js +0 -77
- package/core/components/ui/form/input-autocomplete/input-autocomplete.d.ts +0 -136
- package/core/components/ui/form/input-autocomplete/input-autocomplete.js +0 -296
- package/core/components/ui/form/radio/radio.d.ts +0 -12
- package/core/components/ui/form/radio/radio.js +0 -50
- package/core/components/ui/form/select/select.d.ts +0 -58
- package/core/components/ui/form/select/select.js +0 -298
- package/core/components/ui/form/textarea/textarea.d.ts +0 -84
- package/core/components/ui/form/textarea/textarea.js +0 -150
- package/core/components/ui/group/group.d.ts +0 -16
- package/core/components/ui/group/group.js +0 -118
- package/core/components/ui/icon/icon.d.ts +0 -26
- package/core/components/ui/icon/icon.js +0 -113
- package/core/components/ui/icon/icons.d.ts +0 -10
- package/core/components/ui/icon/icons.js +0 -126
- package/core/components/ui/icon/icons.json +0 -1
- package/core/components/ui/image/image.d.ts +0 -15
- package/core/components/ui/image/image.js +0 -153
- package/core/components/ui/link/link.d.ts +0 -29
- package/core/components/ui/link/link.js +0 -124
- package/core/components/ui/loader/loader.d.ts +0 -23
- package/core/components/ui/loader/loader.js +0 -97
- package/core/components/ui/loader/styles/fixed.d.ts +0 -1
- package/core/components/ui/loader/styles/inline.d.ts +0 -1
- package/core/components/ui/menu/menu-item.d.ts +0 -5
- package/core/components/ui/menu/menu-item.js +0 -34
- package/core/components/ui/menu/menu.d.ts +0 -41
- package/core/components/ui/menu/menu.js +0 -313
- package/core/components/ui/modal/modal-actions.d.ts +0 -7
- package/core/components/ui/modal/modal-actions.js +0 -42
- package/core/components/ui/modal/modal-close.d.ts +0 -7
- package/core/components/ui/modal/modal-close.js +0 -43
- package/core/components/ui/modal/modal-content.d.ts +0 -5
- package/core/components/ui/modal/modal-content.js +0 -26
- package/core/components/ui/modal/modal-subtitle.d.ts +0 -5
- package/core/components/ui/modal/modal-subtitle.js +0 -30
- package/core/components/ui/modal/modal-title.d.ts +0 -5
- package/core/components/ui/modal/modal-title.js +0 -29
- package/core/components/ui/modal/modal.d.ts +0 -58
- package/core/components/ui/modal/modal.js +0 -401
- package/core/components/ui/pop/pop.d.ts +0 -37
- package/core/components/ui/pop/pop.js +0 -299
- package/core/components/ui/progress/progress.d.ts +0 -10
- package/core/components/ui/table/table-caption.d.ts +0 -5
- package/core/components/ui/table/table-caption.js +0 -28
- package/core/components/ui/table/table-tbody.d.ts +0 -5
- package/core/components/ui/table/table-tbody.js +0 -39
- package/core/components/ui/table/table-td.d.ts +0 -12
- package/core/components/ui/table/table-td.js +0 -68
- package/core/components/ui/table/table-tfoot.d.ts +0 -5
- package/core/components/ui/table/table-tfoot.js +0 -27
- package/core/components/ui/table/table-th.d.ts +0 -11
- package/core/components/ui/table/table-th.js +0 -73
- package/core/components/ui/table/table-thead.d.ts +0 -5
- package/core/components/ui/table/table-thead.js +0 -25
- package/core/components/ui/table/table-tr.d.ts +0 -13
- package/core/components/ui/table/table-tr.js +0 -66
- package/core/components/ui/table/table.d.ts +0 -17
- package/core/components/ui/theme/theme-collection/core-variables.d.ts +0 -1
- package/core/components/ui/theme/theme-collection/dark.d.ts +0 -1
- package/core/components/ui/theme/theme-collection/light.d.ts +0 -1
- package/core/components/ui/theme/theme.d.ts +0 -19
- package/core/components/ui/theme/theme.js +0 -124
- package/core/components/ui/toast/message-subscriber.d.ts +0 -18
- package/core/components/ui/toast/message-subscriber.js +0 -40
- package/core/components/ui/toast/toast-item.d.ts +0 -19
- package/core/components/ui/toast/toast.d.ts +0 -25
- package/core/components/ui/toast/toast.js +0 -226
- package/core/components/ui/toast/types.d.ts +0 -11
- package/core/components/ui/toast/types.js +0 -1
- package/core/components/ui/tooltip/tooltip.d.ts +0 -10
- package/core/components/ui/ui.d.ts +0 -32
- package/core/core.d.ts +0 -4
- package/core/core.js +0 -19
- package/core/decorators/Subscriber.d.ts +0 -4
- package/core/decorators/Subscriber.js +0 -166
- package/core/directives/DataProvider.d.ts +0 -23
- package/core/directives/DataProvider.js +0 -102
- package/core/directives/Wording.d.ts +0 -42
- package/core/directives/Wording.js +0 -202
- package/core/mixins/Fetcher.d.ts +0 -90
- package/core/mixins/Fetcher.js +0 -242
- package/core/mixins/FormCheckable.d.ts +0 -88
- package/core/mixins/FormCheckable.js +0 -306
- package/core/mixins/FormElement.d.ts +0 -32
- package/core/mixins/FormElement.js +0 -272
- package/core/mixins/FormInput.d.ts +0 -70
- package/core/mixins/FormInput.js +0 -81
- package/core/mixins/Subscriber.d.ts +0 -36
- package/core/mixins/Subscriber.js +0 -333
- package/core/mixins/TemplatesContainer.d.ts +0 -13
- package/core/mixins/TemplatesContainer.js +0 -69
- package/core/mixins/mixins.js +0 -6
- package/core/utils/Arrays.d.ts +0 -97
- package/core/utils/Arrays.js +0 -140
- package/core/utils/DataBindObserver.d.ts +0 -83
- package/core/utils/DataBindObserver.js +0 -264
- package/core/utils/Electron.d.ts +0 -7
- package/core/utils/Electron.js +0 -11
- package/core/utils/Format.d.ts +0 -12
- package/core/utils/Format.js +0 -38
- package/core/utils/HTML.d.ts +0 -42
- package/core/utils/HTML.js +0 -119
- package/core/utils/LocationHandler.d.ts +0 -46
- package/core/utils/LocationHandler.js +0 -133
- package/core/utils/Objects.d.ts +0 -28
- package/core/utils/Objects.js +0 -102
- package/core/utils/PublisherProxy.d.ts +0 -176
- package/core/utils/PublisherProxy.js +0 -709
- package/core/utils/Utils.d.ts +0 -4
- package/core/utils/Utils.js +0 -12
- package/core/utils/api.d.ts +0 -139
- package/core/utils/api.js +0 -391
- package/core/utils/url-pattern.js +0 -2
- package/decorators.d.ts +0 -3
- package/directives.d.ts +0 -40
- package/img/concorde-logo.svg +0 -1
- package/img/concorde.png +0 -0
- package/img/concorde_def.png +0 -0
- package/mixins.d.ts +0 -181
- package/svg/regular/plane.svg +0 -1
- package/svg/solid/plane.svg +0 -1
- package/test-utils/TestUtils.d.ts +0 -4
- package/test-utils/TestUtils.js +0 -12
- package/utils.d.ts +0 -20
- /package/{core/components/functional/functional.d.ts → src/core/components/functional/functional.ts} +0 -0
- /package/{core → src/core}/components/ui/theme/css/tailwind.css +0 -0
- /package/{core → src/core}/components/ui/theme/css/tailwind.d.ts +0 -0
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import {property} from "lit/decorators.js";
|
|
2
|
+
import {FormElementInterface} from "@supersoniks/concorde/core/mixins/FormElement";
|
|
3
|
+
import {PublisherManager} from "@supersoniks/concorde/utils";
|
|
4
|
+
import {MixinArgsType} from "../_types/types";
|
|
5
|
+
type Constructor<T> = new (...args: MixinArgsType[]) => T;
|
|
6
|
+
const Form = <T extends Constructor<FormElementInterface>>(superClass: T) => {
|
|
7
|
+
/**
|
|
8
|
+
* FormCheckable ajoute un comportement de sélection (checked) a tout FormElement qui utilise cette mixin.
|
|
9
|
+
* Il est notamment utilisé par sonic-checkbox, sonic-radio et sonic-button
|
|
10
|
+
* * Par défaut le fonctionnement est celui d'une checkbox classique.
|
|
11
|
+
* * Dans ce cas, a la sélection, formPublisher[this.name] = [this.value, ...autres valeurs d'élémen,ts sélectionnés ayant le même nom];
|
|
12
|
+
* * En activant le mode radio à l'aide du flag dédié, un seul FormElement ayant la même propriété name peut être sélectionné à la fois.
|
|
13
|
+
* * Dans ce cas, a la sélection, formPublisher[this.name] = this.value;
|
|
14
|
+
*/
|
|
15
|
+
class FormCheckable extends superClass {
|
|
16
|
+
/**
|
|
17
|
+
* Voir la mixin FormElement.
|
|
18
|
+
*/
|
|
19
|
+
_value: string | null = "";
|
|
20
|
+
@property() get value(): string | null {
|
|
21
|
+
return this._value;
|
|
22
|
+
}
|
|
23
|
+
set value(newValue: string | null) {
|
|
24
|
+
if (this.value == newValue) return;
|
|
25
|
+
if (this.hasAttribute("value") && !this.forceAutoFill) newValue = this.getAttribute("value");
|
|
26
|
+
|
|
27
|
+
if (this._value == newValue) return;
|
|
28
|
+
if (newValue == null) return;
|
|
29
|
+
|
|
30
|
+
this._value = newValue;
|
|
31
|
+
if (!this.value) return;
|
|
32
|
+
|
|
33
|
+
// On check l'élément si il est cheched dans le formPublisher
|
|
34
|
+
const formPublisher = this.getFormPublisher();
|
|
35
|
+
if (formPublisher && this.name) {
|
|
36
|
+
let currentValue = formPublisher[this.name].get();
|
|
37
|
+
if (this.radio || this.unique) {
|
|
38
|
+
this.checked = currentValue == newValue ? true : null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!Array.isArray(currentValue)) {
|
|
42
|
+
currentValue = [];
|
|
43
|
+
}
|
|
44
|
+
if (currentValue.indexOf(newValue) != -1) this.checked = true;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//On mets à jour la valeur dans la donnée si l'élément est checked
|
|
48
|
+
if (this.checked == true) this.updateDataValue();
|
|
49
|
+
|
|
50
|
+
this.requestUpdate();
|
|
51
|
+
}
|
|
52
|
+
@property() forceAutoFill = false;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* comme radio,mais peut être désélectionné après sélection
|
|
56
|
+
*/
|
|
57
|
+
@property({type: Boolean}) unique: true | null = null;
|
|
58
|
+
/**
|
|
59
|
+
Active le mode radio
|
|
60
|
+
*/
|
|
61
|
+
@property({type: Boolean}) radio: true | null = null;
|
|
62
|
+
|
|
63
|
+
@property({type: Boolean}) unCheckOnDisconnect = false;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* propriété checked avec des caractéristiques similaire à un input html classique.
|
|
67
|
+
*/
|
|
68
|
+
_checked: true | null | "indeterminate" = null;
|
|
69
|
+
@property() get checked(): true | null | "indeterminate" {
|
|
70
|
+
return this._checked;
|
|
71
|
+
}
|
|
72
|
+
public set checked(checked: true | null | "indeterminate") {
|
|
73
|
+
this.setCheckedValue(checked);
|
|
74
|
+
if (this.checksAll()) {
|
|
75
|
+
const checkAllPublisher = this.getCheckAllPublisher();
|
|
76
|
+
if (checkAllPublisher) {
|
|
77
|
+
if (this.checked === true) checkAllPublisher.checkMode = "allChecked";
|
|
78
|
+
else if (this.checked === null) {
|
|
79
|
+
checkAllPublisher.checkMode = "noneChecked";
|
|
80
|
+
const formPublisher = this.getFormPublisher();
|
|
81
|
+
if (formPublisher) {
|
|
82
|
+
formPublisher[this.name] = [];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
this.requestUpdate();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
validateFormElement() {
|
|
91
|
+
const input: HTMLInputElement = this.shadowRoot?.querySelector("input") as HTMLInputElement;
|
|
92
|
+
if (!input || input.checkValidity()) return;
|
|
93
|
+
const formPublisher = this.getFormPublisher();
|
|
94
|
+
if (formPublisher) {
|
|
95
|
+
const value = formPublisher[this.name].get();
|
|
96
|
+
if ((this.unique || this.radio) && value !== null && value.toString().length > 0) return;
|
|
97
|
+
formPublisher.isFormValid = false;
|
|
98
|
+
input.reportValidity();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
checksAll() {
|
|
103
|
+
return this.hasAttribute("checksAll");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
setCheckedValue(checked: true | null | "indeterminate") {
|
|
107
|
+
if (this._checked == checked) return;
|
|
108
|
+
this._checked = checked;
|
|
109
|
+
this.updateDataValue();
|
|
110
|
+
this.requestUpdate();
|
|
111
|
+
setTimeout(() => this.updateAllChecked(), 1);
|
|
112
|
+
|
|
113
|
+
// Désactivation du checked sur le publisher
|
|
114
|
+
// Pas sur de l'utilité mais provoque un bug
|
|
115
|
+
// if (this.publisher && !this.radio && !this.unique) {
|
|
116
|
+
// this.publisher.checked = this._checked;
|
|
117
|
+
// }
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
handleChange() {
|
|
121
|
+
const newCheckedValue = this.checked === true ? (!this.radio ? null : true) : true;
|
|
122
|
+
this.checked = newCheckedValue;
|
|
123
|
+
|
|
124
|
+
const event = new Event("change");
|
|
125
|
+
this.dispatchEvent(event);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Voir la mixin FormElement
|
|
129
|
+
* Le comportement est ici modifié fonction de son mode (checkbox, radio, unique)
|
|
130
|
+
*/
|
|
131
|
+
getValueForFormPublisher() {
|
|
132
|
+
const formPublisher = this.getFormPublisher();
|
|
133
|
+
if (!formPublisher) return null;
|
|
134
|
+
let currentValue = formPublisher[this.name].get();
|
|
135
|
+
|
|
136
|
+
if (this.radio) {
|
|
137
|
+
return this.checked === true && this.value != null ? this.value : currentValue;
|
|
138
|
+
}
|
|
139
|
+
if (this.unique) {
|
|
140
|
+
return this.checked === true && this.value != null ? this.value : null;
|
|
141
|
+
}
|
|
142
|
+
if (!Array.isArray(currentValue)) {
|
|
143
|
+
currentValue = [];
|
|
144
|
+
}
|
|
145
|
+
currentValue = currentValue.slice(0);
|
|
146
|
+
const idx = currentValue.indexOf(this.value);
|
|
147
|
+
if (this.checked === true && idx === -1 && !this.checksAll()) currentValue.push(this.value);
|
|
148
|
+
if (this.checked === null && idx !== -1) {
|
|
149
|
+
currentValue.splice(idx, 1);
|
|
150
|
+
}
|
|
151
|
+
return currentValue;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Voir la mixin FormElement
|
|
155
|
+
* Le comportement est modifié de la manière suivante :
|
|
156
|
+
* L'état du composant (checked) est mis à jour en fonction de la valeur fournie par le publisher associé au composant / en fonction de sont mode (radio, unique)
|
|
157
|
+
*/
|
|
158
|
+
setFormValueFromPublisher(value: string | Array<string | null> | null) {
|
|
159
|
+
if (this.unique || this.radio) {
|
|
160
|
+
this.checked = this.value == value ? true : null;
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (!Array.isArray(value)) value = [];
|
|
165
|
+
if (this.checksAll()) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
this.checked = value.indexOf(this.value) !== -1 ? true : null;
|
|
169
|
+
}
|
|
170
|
+
getCheckAllPublisher() {
|
|
171
|
+
if (!this.formDataProvider) this.formDataProvider = this.getAncestorAttributeValue("formDataProvider");
|
|
172
|
+
const formDataProvider = this.formDataProvider;
|
|
173
|
+
const name = this.getAttribute("name");
|
|
174
|
+
if (!formDataProvider || !name) {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
return PublisherManager.get(formDataProvider + "/" + name + "/_available_values_");
|
|
178
|
+
}
|
|
179
|
+
updateAllChecked = () => {
|
|
180
|
+
const name = this.getAttribute("name");
|
|
181
|
+
const checkAllPublisher = this.getCheckAllPublisher();
|
|
182
|
+
const formPublisher = this.getFormPublisher();
|
|
183
|
+
if (!checkAllPublisher?.hasCheckAll.get()) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (!this.checksAll() && checkAllPublisher && formPublisher && name) {
|
|
188
|
+
if (!formPublisher[this.name].get().length) {
|
|
189
|
+
checkAllPublisher.checkMode = "noneChecked";
|
|
190
|
+
return;
|
|
191
|
+
} else if (this.checked === null) {
|
|
192
|
+
checkAllPublisher.checkMode = "someUnchecked";
|
|
193
|
+
} else if (checkAllPublisher.checkMode.get() == "noneChecked" || checkAllPublisher.checkMode.get() == null) {
|
|
194
|
+
checkAllPublisher.checkMode = "someUnchecked";
|
|
195
|
+
}
|
|
196
|
+
const currentValues = formPublisher[name].get();
|
|
197
|
+
const allValues = checkAllPublisher.values.get();
|
|
198
|
+
|
|
199
|
+
if (allValues && allValues.length) {
|
|
200
|
+
let checkedCount = allValues.length;
|
|
201
|
+
for (const p of allValues) {
|
|
202
|
+
if (currentValues.indexOf(p) == -1) {
|
|
203
|
+
checkedCount -= 1;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (checkedCount == allValues.length) {
|
|
207
|
+
checkAllPublisher.checkMode = "allChecked";
|
|
208
|
+
}
|
|
209
|
+
if (checkedCount == 0) {
|
|
210
|
+
checkAllPublisher.checkMode = "noneChecked";
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (allValues.indexOf(this.value) == -1) {
|
|
214
|
+
this.checked = null;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
onChecksAllRequest = (value: string) => {
|
|
219
|
+
this.removeAttribute("allChecked");
|
|
220
|
+
this.removeAttribute("indeterminate");
|
|
221
|
+
if (value == "allChecked") {
|
|
222
|
+
this.checked = true;
|
|
223
|
+
this.setAttribute("allChecked", "");
|
|
224
|
+
}
|
|
225
|
+
if (value == "noneChecked") {
|
|
226
|
+
this.checked = null;
|
|
227
|
+
}
|
|
228
|
+
if (value == "someUnchecked") {
|
|
229
|
+
if (this.checksAll()) this.checked = "indeterminate";
|
|
230
|
+
this.setAttribute("indeterminate", "");
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
disconnectedCallback(): void {
|
|
234
|
+
super.disconnectedCallback();
|
|
235
|
+
|
|
236
|
+
const checkAllPublisher = this.getCheckAllPublisher();
|
|
237
|
+
if (checkAllPublisher) {
|
|
238
|
+
checkAllPublisher.checkMode.offAssign(this.onChecksAllRequest);
|
|
239
|
+
if (!this.checksAll()) {
|
|
240
|
+
const values = checkAllPublisher.values.get().slice(0);
|
|
241
|
+
const idx = values.indexOf(this.value);
|
|
242
|
+
if (idx != -1) {
|
|
243
|
+
values.splice(idx, 1);
|
|
244
|
+
checkAllPublisher.values = values;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
setTimeout(() => this.updateAllChecked(), 1);
|
|
249
|
+
}
|
|
250
|
+
connectedCallback(): void {
|
|
251
|
+
super.connectedCallback();
|
|
252
|
+
const formPublisher = this.getFormPublisher();
|
|
253
|
+
if (formPublisher && this.name) {
|
|
254
|
+
const publisherValueForName = formPublisher[this.name].get();
|
|
255
|
+
if (
|
|
256
|
+
publisherValueForName &&
|
|
257
|
+
Array.isArray(publisherValueForName) &&
|
|
258
|
+
publisherValueForName.indexOf(this.value) !== -1
|
|
259
|
+
) {
|
|
260
|
+
this.checked = true;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
const checkAllPublisher = this.getCheckAllPublisher();
|
|
264
|
+
if (checkAllPublisher) {
|
|
265
|
+
checkAllPublisher.checkMode.onAssign(this.onChecksAllRequest);
|
|
266
|
+
if (this.checksAll()) {
|
|
267
|
+
checkAllPublisher.hasCheckAll = true;
|
|
268
|
+
}
|
|
269
|
+
if (!checkAllPublisher.values.get()) {
|
|
270
|
+
checkAllPublisher.values = [];
|
|
271
|
+
}
|
|
272
|
+
if (!this.checksAll()) {
|
|
273
|
+
checkAllPublisher.values = [...checkAllPublisher.values.get(), this.value];
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (!this.hasAttribute("checked")) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
if (!this.publisher || this.publisher.get().checked !== false) {
|
|
281
|
+
setTimeout(() => (this.checked = true), 1);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return FormCheckable;
|
|
286
|
+
};
|
|
287
|
+
export default Form;
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import {PublisherManager} from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
2
|
+
import {property} from "lit/decorators.js";
|
|
3
|
+
import {SubscriberInterface} from "@supersoniks/concorde/core/mixins/Subscriber";
|
|
4
|
+
import Objects from "@supersoniks/concorde/core/utils/Objects";
|
|
5
|
+
import {PublisherInterface, HTMLFormControl, CoreJSType} from "../_types/types";
|
|
6
|
+
import {MixinArgsType} from "../_types/types";
|
|
7
|
+
type Constructor<T> = new (...args: MixinArgsType[]) => T;
|
|
8
|
+
type FormElementValue = string | string[] | object | null | undefined;
|
|
9
|
+
export interface FormElementInterface extends SubscriberInterface {
|
|
10
|
+
getFormPublisher(): PublisherInterface;
|
|
11
|
+
updateDataValue(): void;
|
|
12
|
+
handleChange(e?: Event): void;
|
|
13
|
+
handleBlur(e?: Event): void;
|
|
14
|
+
getValueForFormPublisher(): FormElementValue;
|
|
15
|
+
setValueFromPublisher(value: FormElementValue): void;
|
|
16
|
+
validateFormElement(): void;
|
|
17
|
+
focus?: () => void;
|
|
18
|
+
forceAutoFill: boolean;
|
|
19
|
+
shadowRoot?: ShadowRoot;
|
|
20
|
+
error: boolean;
|
|
21
|
+
autofocus: boolean;
|
|
22
|
+
required: boolean;
|
|
23
|
+
disabled: true | null;
|
|
24
|
+
formDataProvider: string;
|
|
25
|
+
ariaLabelledby?: string;
|
|
26
|
+
ariaLabel?: string;
|
|
27
|
+
_value: FormElementValue;
|
|
28
|
+
get value(): FormElementValue;
|
|
29
|
+
set value(value: FormElementValue);
|
|
30
|
+
_name: string;
|
|
31
|
+
get name(): string;
|
|
32
|
+
set name(value: string);
|
|
33
|
+
}
|
|
34
|
+
const keyboardLoops = new Map<string, Array<FormElementInterface>>();
|
|
35
|
+
const Form = <T extends Constructor<SubscriberInterface>>(superClass: T) => {
|
|
36
|
+
/**
|
|
37
|
+
* ## FormElement est la mixin utilisée par les éléments de formulaire de concorde ainsi que par le composant sonic-button.
|
|
38
|
+
* * La propriété value est remplie automatiquement a l'aide de l'attribut name renseigné, ceci en prenant la valeur de la propriété du même nom dans les données du dataprovider associé.
|
|
39
|
+
* * Par défault lorsque l'on édite l'input, la valeur est également mise à jour via le même dataprovider
|
|
40
|
+
* * On peut cependant décider de mettre à jour la donnée à une autre adresse en renseignent l'attribut *formDataProvider*.
|
|
41
|
+
* * Par conséquent, on peut par exemple le lier à un composant *queue* (via sa propriété *dataFilterProvider*) de manière à appeller en auto une api avec des filtres.
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
class FormElement extends superClass implements FormElementInterface {
|
|
45
|
+
@property({type: Boolean, reflect: true}) touched = false;
|
|
46
|
+
@property({type: Boolean}) error = false;
|
|
47
|
+
@property({type: Boolean}) autofocus = false;
|
|
48
|
+
@property({type: Boolean}) required = false;
|
|
49
|
+
@property({type: Boolean}) forceAutoFill = false;
|
|
50
|
+
@property({type: Boolean}) disabled: true | null = null;
|
|
51
|
+
|
|
52
|
+
/* Attribut data-aria-label pour passer aria-label */
|
|
53
|
+
@property({type: String, attribute: "data-aria-label"}) ariaLabel?: string;
|
|
54
|
+
@property({type: String, attribute: "data-aria-labelledby"})
|
|
55
|
+
ariaLabelledby?: string;
|
|
56
|
+
|
|
57
|
+
onValueAssign?: (v: string) => void;
|
|
58
|
+
onFormValueAssign?: (v: string) => void;
|
|
59
|
+
onFormDataInValidate?: (v: string) => void;
|
|
60
|
+
constructor(...args: MixinArgsType[]) {
|
|
61
|
+
super();
|
|
62
|
+
args;
|
|
63
|
+
this.onValueAssign = (value) => {
|
|
64
|
+
this.setValueFromPublisher(value);
|
|
65
|
+
};
|
|
66
|
+
this.onFormValueAssign = async (value) => {
|
|
67
|
+
this.setFormValueFromPublisher(value);
|
|
68
|
+
};
|
|
69
|
+
this.onFormDataInValidate = () => {
|
|
70
|
+
const formPublisher = this.getFormPublisher();
|
|
71
|
+
if (!(formPublisher && formPublisher.isFormValid.get())) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
this.validateFormElement();
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
formDataProvider = "";
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Le nom du champ avec des caractéristiques similaire à un input html classique.
|
|
81
|
+
*/
|
|
82
|
+
_name = "";
|
|
83
|
+
@property() get name(): string {
|
|
84
|
+
return this._name;
|
|
85
|
+
}
|
|
86
|
+
set name(value: string) {
|
|
87
|
+
if (this.hasAttribute("name") && !this.forceAutoFill) value = this.getAttribute("name");
|
|
88
|
+
this._name = value;
|
|
89
|
+
this.requestUpdate();
|
|
90
|
+
}
|
|
91
|
+
validateFormElement() {
|
|
92
|
+
//Implémentation dans une sous classe
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
updateDataValue() {
|
|
96
|
+
const name = this.getAttribute("name");
|
|
97
|
+
if (name) {
|
|
98
|
+
const formPublisher = this.getFormPublisher();
|
|
99
|
+
if (formPublisher) {
|
|
100
|
+
formPublisher[name] = this.getValueForFormPublisher();
|
|
101
|
+
this.setFormValueFromPublisher(formPublisher[name].get());
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
getFormPublisher() {
|
|
106
|
+
if (!this.formDataProvider) this.formDataProvider = this.getAncestorAttributeValue("formDataProvider");
|
|
107
|
+
if (this.formDataProvider) {
|
|
108
|
+
return PublisherManager.get(this.formDataProvider);
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
//else return this.publisher;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Mise en forme de la valeur fournie au formPublisher associé au composant
|
|
115
|
+
* Destinée à être surchargée si besoin (cf Form-checkable)
|
|
116
|
+
*/
|
|
117
|
+
getValueForFormPublisher() {
|
|
118
|
+
return this.value;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Mise à jour de la valeur interne du composant en fonction de la valeur venant du publisher associé au composant
|
|
122
|
+
* Destinée à être surchargée si besoin (cf Form-checkable)
|
|
123
|
+
*/
|
|
124
|
+
setValueFromPublisher(value: FormElementValue) {
|
|
125
|
+
this.value = value;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Mise à jour de la valeur interne du composant en fonction de la valeur venant du formPublisher associé au composant
|
|
130
|
+
* Destinée à être surchargée si besoin (cf Form-checkable)
|
|
131
|
+
*/
|
|
132
|
+
setFormValueFromPublisher(value: FormElementValue) {
|
|
133
|
+
this.value = value;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* La valeur du champ avec des caractéristiques similaire à un input html classique :
|
|
137
|
+
*/
|
|
138
|
+
_value: FormElementValue = "";
|
|
139
|
+
@property() get value() {
|
|
140
|
+
return this._value;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
set value(value) {
|
|
144
|
+
if (value == null) value = "";
|
|
145
|
+
if (
|
|
146
|
+
Objects.isObject(value) &&
|
|
147
|
+
Object.prototype.hasOwnProperty.call(value, "__value") &&
|
|
148
|
+
(value as {_value?: CoreJSType})._value == undefined
|
|
149
|
+
)
|
|
150
|
+
value = "";
|
|
151
|
+
if (this._value == value) return;
|
|
152
|
+
this._value = value;
|
|
153
|
+
this.updateDataValue();
|
|
154
|
+
this.requestUpdate();
|
|
155
|
+
}
|
|
156
|
+
initPublisher() {
|
|
157
|
+
let formPublisher = this.getFormPublisher();
|
|
158
|
+
const value =
|
|
159
|
+
this.hasAncestorAttribute("initFromPublisher") && this._name && formPublisher[this._name].get()
|
|
160
|
+
? formPublisher[this._name].get()
|
|
161
|
+
: this.getAttribute("value");
|
|
162
|
+
if (this._name && this.publisher) this.publisher[this._name].offAssign(this.onValueAssign);
|
|
163
|
+
if (this._name && formPublisher) formPublisher[this._name].offAssign(this.onFormValueAssign);
|
|
164
|
+
super.initPublisher();
|
|
165
|
+
if (!this.name) this._name = this.getAttribute("name");
|
|
166
|
+
if (!this.value) this._value = this.getAttribute("value");
|
|
167
|
+
if (this.publisher && this._name) {
|
|
168
|
+
this.publisher[this._name].onAssign(this.onValueAssign);
|
|
169
|
+
}
|
|
170
|
+
formPublisher = this.getFormPublisher();
|
|
171
|
+
if (this._name && formPublisher) {
|
|
172
|
+
formPublisher[this._name].onAssign(this.onFormValueAssign);
|
|
173
|
+
formPublisher.onInvalidate(this.onFormDataInValidate);
|
|
174
|
+
}
|
|
175
|
+
this.updateDataValue();
|
|
176
|
+
if (value) this.value = value;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
handleBlur() {
|
|
180
|
+
this.touched = true;
|
|
181
|
+
// this.validateFormElement();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
handleChange(e: Event) {
|
|
185
|
+
this.value = (e.target as HTMLFormControl).value;
|
|
186
|
+
const event = new Event("change");
|
|
187
|
+
this.dispatchEvent(event);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Ajoute un comportement de navigation au clavier pour les éléments de formulaire
|
|
191
|
+
* data-keyboard-nav peut contenir plusieurs valeurs qui identifient les boucles de navigation auquelles est attaché cet élément.
|
|
192
|
+
* Les valeurs sont séparées par des espaces.
|
|
193
|
+
* En appuyant sur la touche "Down", le composant va se déplacer dans la boucle de navigation correspondante en suivant le flux.
|
|
194
|
+
* En appuyant sur la touche "Up", le déplacement inverse est effectué.
|
|
195
|
+
*/
|
|
196
|
+
addKeyboardNavigation() {
|
|
197
|
+
const keyboardLoopIds: string = this.getAncestorAttributeValue("data-keyboard-nav");
|
|
198
|
+
if (!keyboardLoopIds) return;
|
|
199
|
+
|
|
200
|
+
const split = keyboardLoopIds.split(" ");
|
|
201
|
+
const keyboardLoopId = split[0];
|
|
202
|
+
if (!keyboardLoopId) return;
|
|
203
|
+
for (const keyboardLoopId2 of split) {
|
|
204
|
+
if (!keyboardLoops.has(keyboardLoopId2)) {
|
|
205
|
+
keyboardLoops.set(keyboardLoopId2, []);
|
|
206
|
+
}
|
|
207
|
+
const keyboardLoop = keyboardLoops.get(keyboardLoopId2);
|
|
208
|
+
if (keyboardLoop?.indexOf(this) == -1) {
|
|
209
|
+
keyboardLoop.push(this);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
const keyboardLoop = keyboardLoops.get(keyboardLoopId);
|
|
213
|
+
|
|
214
|
+
this.addEventListener("keydown", (e) => {
|
|
215
|
+
const keyboardEvent = e as KeyboardEvent;
|
|
216
|
+
if (!["ArrowDown", "ArrowUp"].includes(keyboardEvent.key)) return;
|
|
217
|
+
const selector = "input:not([disabled]), button:not([disabled]), select:not([disabled]), textarea:not([disabled])";
|
|
218
|
+
const loop = keyboardLoop?.filter((el) => {
|
|
219
|
+
const child = el.shadowRoot?.querySelector(selector);
|
|
220
|
+
if (!child) return false;
|
|
221
|
+
const cpStyle = window.getComputedStyle(child);
|
|
222
|
+
return (
|
|
223
|
+
cpStyle.display !== "none" &&
|
|
224
|
+
cpStyle.display !== "" &&
|
|
225
|
+
cpStyle.pointerEvents != "none" &&
|
|
226
|
+
cpStyle.visibility !== "hidden" &&
|
|
227
|
+
child.getBoundingClientRect().width > 0
|
|
228
|
+
);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
let next: SubscriberInterface | null = null;
|
|
232
|
+
if (keyboardEvent.key == "ArrowDown" && loop) {
|
|
233
|
+
const index = loop.indexOf(this);
|
|
234
|
+
if (index == loop.length - 1) {
|
|
235
|
+
next = loop[0];
|
|
236
|
+
} else {
|
|
237
|
+
next = loop[index + 1];
|
|
238
|
+
}
|
|
239
|
+
} else if (keyboardEvent.key == "ArrowUp" && loop) {
|
|
240
|
+
const index = loop.indexOf(this);
|
|
241
|
+
if (index == 0) {
|
|
242
|
+
next = loop[loop.length - 1];
|
|
243
|
+
} else {
|
|
244
|
+
next = loop[index - 1];
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
const elt = next?.shadowRoot?.querySelector(selector) as FormElementInterface | null;
|
|
248
|
+
|
|
249
|
+
if (elt && elt.focus) {
|
|
250
|
+
elt.focus();
|
|
251
|
+
e.preventDefault();
|
|
252
|
+
e.stopPropagation();
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
connectedCallback(): void {
|
|
258
|
+
this.formDataProvider = this.getAncestorAttributeValue("formDataProvider") as string;
|
|
259
|
+
super.connectedCallback();
|
|
260
|
+
this.addKeyboardNavigation();
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
disconnectedCallback() {
|
|
264
|
+
super.disconnectedCallback();
|
|
265
|
+
if (this._name && this.publisher) this.publisher[this._name].offAssign(this.onValueAssign);
|
|
266
|
+
const formPublisher = this.getFormPublisher();
|
|
267
|
+
if (this._name && formPublisher) {
|
|
268
|
+
formPublisher[this._name].offAssign(this.onFormValueAssign);
|
|
269
|
+
formPublisher.offInvalidate(this.onFormDataInValidate);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return FormElement as Constructor<FormElementInterface> & T;
|
|
274
|
+
};
|
|
275
|
+
export default Form;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import {property} from "lit/decorators.js";
|
|
2
|
+
import {FormElementInterface} from "@supersoniks/concorde/core/mixins/FormElement";
|
|
3
|
+
import {MixinArgsType} from "../_types/types";
|
|
4
|
+
|
|
5
|
+
type Constructor<T> = new (...args: MixinArgsType[]) => T;
|
|
6
|
+
type Type =
|
|
7
|
+
| "button"
|
|
8
|
+
| "checkbox"
|
|
9
|
+
| "color"
|
|
10
|
+
| "date"
|
|
11
|
+
| "datetime-local"
|
|
12
|
+
| "email"
|
|
13
|
+
| "file"
|
|
14
|
+
| "hidden"
|
|
15
|
+
| "image"
|
|
16
|
+
| "month"
|
|
17
|
+
| "number"
|
|
18
|
+
| "password"
|
|
19
|
+
| "radio"
|
|
20
|
+
| "range"
|
|
21
|
+
| "reset"
|
|
22
|
+
| "search"
|
|
23
|
+
| "submit"
|
|
24
|
+
| "tel"
|
|
25
|
+
| "text"
|
|
26
|
+
| "time"
|
|
27
|
+
| "url"
|
|
28
|
+
| "week";
|
|
29
|
+
const Form = <T extends Constructor<FormElementInterface>>(superClass: T) => {
|
|
30
|
+
class FormInput extends superClass {
|
|
31
|
+
constructor(...args: MixinArgsType[]) {
|
|
32
|
+
super();
|
|
33
|
+
args;
|
|
34
|
+
}
|
|
35
|
+
validateFormElement() {
|
|
36
|
+
const input: HTMLInputElement = this.shadowRoot?.querySelector("input") as HTMLInputElement;
|
|
37
|
+
if (!input || input.checkValidity()) return;
|
|
38
|
+
const formPublisher = this.getFormPublisher();
|
|
39
|
+
if (formPublisher) formPublisher.isFormValid = false;
|
|
40
|
+
input.reportValidity();
|
|
41
|
+
}
|
|
42
|
+
@property() forceAutoFill = false;
|
|
43
|
+
/**
|
|
44
|
+
* Le type De l'input, comme en html cependant tous les types ne sont pas actuellements compatibles en raison du style en vigueur
|
|
45
|
+
* On peut essayer text, date, color, email par exemple, mais pas radio/checkbox/range a priori
|
|
46
|
+
*/
|
|
47
|
+
_type: Type = "text";
|
|
48
|
+
@property({type: String}) set type(value) {
|
|
49
|
+
if (this.hasAttribute("type") && !this.forceAutoFill) value = this.getAttribute("type") as Type;
|
|
50
|
+
this._type = value;
|
|
51
|
+
this.requestUpdate();
|
|
52
|
+
}
|
|
53
|
+
get type() {
|
|
54
|
+
return this._type;
|
|
55
|
+
}
|
|
56
|
+
_description?: string;
|
|
57
|
+
@property() get description(): string | undefined {
|
|
58
|
+
return this._description;
|
|
59
|
+
}
|
|
60
|
+
set description(value) {
|
|
61
|
+
if (this.hasAttribute("description") && !this.forceAutoFill) value = this.getAttribute("description") as string;
|
|
62
|
+
this._description = value;
|
|
63
|
+
this.requestUpdate();
|
|
64
|
+
}
|
|
65
|
+
_label?: string;
|
|
66
|
+
@property() get label(): string | undefined {
|
|
67
|
+
return this._label;
|
|
68
|
+
}
|
|
69
|
+
set label(value) {
|
|
70
|
+
if (this.hasAttribute("label") && !this.forceAutoFill) value = this.getAttribute("label") as string;
|
|
71
|
+
this._label = value;
|
|
72
|
+
this.requestUpdate();
|
|
73
|
+
}
|
|
74
|
+
@property({type: String, reflect: true}) status: "default" | "success" | "error" | "warning" | "info" = "default";
|
|
75
|
+
@property({type: Number}) tabindex?: number;
|
|
76
|
+
@property({type: String}) autocomplete?:
|
|
77
|
+
| "off"
|
|
78
|
+
| "on"
|
|
79
|
+
| "name"
|
|
80
|
+
| "honorific-prefix"
|
|
81
|
+
| "given-name"
|
|
82
|
+
| "additional-name"
|
|
83
|
+
| "family-name"
|
|
84
|
+
| "honorific-suffix"
|
|
85
|
+
| "nickname"
|
|
86
|
+
| "email"
|
|
87
|
+
| "username"
|
|
88
|
+
| "new-password"
|
|
89
|
+
| "current-password"
|
|
90
|
+
| "one-time-code"
|
|
91
|
+
| "organization-title"
|
|
92
|
+
| "organization"
|
|
93
|
+
| "street-address"
|
|
94
|
+
| "address-line1"
|
|
95
|
+
| "address-line2"
|
|
96
|
+
| "address-line3"
|
|
97
|
+
| "address-level4"
|
|
98
|
+
| "address-level3"
|
|
99
|
+
| "address-level2"
|
|
100
|
+
| "address-level1"
|
|
101
|
+
| "country"
|
|
102
|
+
| "country-name"
|
|
103
|
+
| "postal-code"
|
|
104
|
+
| "cc-name"
|
|
105
|
+
| "cc-given-name"
|
|
106
|
+
| "cc-additional-name"
|
|
107
|
+
| "cc-family-name"
|
|
108
|
+
| "cc-number"
|
|
109
|
+
| "cc-exp"
|
|
110
|
+
| "cc-exp-month"
|
|
111
|
+
| "cc-exp-year"
|
|
112
|
+
| "cc-csc"
|
|
113
|
+
| "cc-type"
|
|
114
|
+
| "transaction-currency"
|
|
115
|
+
| "transaction-amount"
|
|
116
|
+
| "language"
|
|
117
|
+
| "bday"
|
|
118
|
+
| "bday-day"
|
|
119
|
+
| "bday-month"
|
|
120
|
+
| "bday-year"
|
|
121
|
+
| "sex"
|
|
122
|
+
| "tel"
|
|
123
|
+
| "tel-country-code"
|
|
124
|
+
| "tel-national"
|
|
125
|
+
| "tel-area-code"
|
|
126
|
+
| "tel-local"
|
|
127
|
+
| "tel-extension"
|
|
128
|
+
| "impp"
|
|
129
|
+
| "url"
|
|
130
|
+
| "photo";
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return FormInput;
|
|
134
|
+
};
|
|
135
|
+
export default Form;
|