@synergy-design-system/mcp 2.14.1 → 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/CHANGELOG.md +28 -0
- package/README.md +826 -303
- package/dist/bin/start.js +57 -6
- package/dist/middleware/compose.d.ts +15 -0
- package/dist/middleware/compose.js +10 -0
- package/dist/middleware/compression.d.ts +19 -0
- package/dist/middleware/compression.js +35 -0
- package/dist/middleware/error-handler.d.ts +13 -0
- package/dist/middleware/error-handler.js +42 -0
- package/dist/middleware/index.d.ts +9 -0
- package/dist/middleware/index.js +8 -0
- package/dist/middleware/logging.d.ts +14 -0
- package/dist/middleware/logging.js +64 -0
- package/dist/middleware/types.d.ts +20 -0
- package/dist/middleware/types.js +4 -0
- package/dist/resources/asset-list.d.ts +7 -0
- package/dist/resources/asset-list.js +34 -0
- package/dist/resources/component-cluster-list.d.ts +7 -0
- package/dist/resources/component-cluster-list.js +30 -0
- package/dist/resources/component-list.d.ts +7 -0
- package/dist/resources/component-list.js +31 -0
- package/dist/resources/index.d.ts +5 -0
- package/dist/resources/index.js +5 -0
- package/dist/resources/styles-list.d.ts +7 -0
- package/dist/resources/styles-list.js +31 -0
- package/dist/resources/templates-list.d.ts +7 -0
- package/dist/resources/templates-list.js +28 -0
- package/dist/server.js +5 -1
- package/dist/tools/asset-info.js +41 -85
- package/dist/tools/asset-list.js +22 -31
- package/dist/tools/component-cluster-list.d.ts +6 -0
- package/dist/tools/component-cluster-list.js +30 -0
- package/dist/tools/component-info.js +38 -21
- package/dist/tools/component-list.js +35 -30
- package/dist/tools/davinci-migration-info.d.ts +2 -0
- package/dist/tools/davinci-migration-info.js +21 -0
- package/dist/tools/davinci-migration-list.d.ts +2 -0
- package/dist/tools/davinci-migration-list.js +20 -0
- package/dist/tools/index.d.ts +6 -5
- package/dist/tools/index.js +6 -5
- package/dist/tools/migration-info.js +12 -37
- package/dist/tools/migration-list.js +7 -13
- package/dist/tools/setup.d.ts +6 -0
- package/dist/tools/setup.js +31 -0
- package/dist/tools/styles-info.d.ts +1 -2
- package/dist/tools/styles-info.js +24 -20
- package/dist/tools/styles-list.js +19 -33
- package/dist/tools/template-info.js +19 -20
- package/dist/tools/template-list.d.ts +1 -1
- package/dist/tools/template-list.js +17 -32
- package/dist/tools/{tokens.d.ts → token-info.d.ts} +2 -2
- package/dist/tools/token-info.js +31 -0
- package/dist/tools/tokens-list.d.ts +6 -0
- package/dist/tools/tokens-list.js +52 -0
- package/dist/transports/http.d.ts +14 -0
- package/dist/transports/http.js +157 -0
- package/dist/transports/index.d.ts +23 -0
- package/dist/transports/index.js +23 -0
- package/dist/transports/stdio.d.ts +10 -0
- package/dist/transports/stdio.js +21 -0
- package/dist/types/tool-response.d.ts +13 -0
- package/dist/types/tool-response.js +7 -0
- package/dist/utilities/cli.d.ts +27 -0
- package/dist/utilities/cli.js +170 -0
- package/dist/utilities/compression.d.ts +7 -0
- package/dist/utilities/compression.js +45 -0
- package/dist/utilities/config.d.ts +122 -80
- package/dist/utilities/config.js +212 -81
- package/dist/utilities/davinci.d.ts +12 -0
- package/dist/utilities/davinci.js +55 -0
- package/dist/utilities/index.d.ts +10 -10
- package/dist/utilities/index.js +10 -10
- package/dist/utilities/local-file-logger.d.ts +2 -0
- package/dist/utilities/local-file-logger.js +22 -0
- package/dist/utilities/logger.d.ts +12 -0
- package/dist/utilities/logger.js +30 -0
- package/dist/utilities/logging-context.d.ts +8 -0
- package/dist/utilities/logging-context.js +7 -0
- package/dist/utilities/logging-service.d.ts +2 -0
- package/dist/utilities/logging-service.js +24 -0
- package/dist/utilities/logging-types.d.ts +19 -0
- package/dist/utilities/metadata.d.ts +10 -17
- package/dist/utilities/metadata.js +34 -51
- package/dist/utilities/migration.d.ts +2 -1
- package/dist/utilities/migration.js +33 -30
- package/dist/utilities/rules.d.ts +8 -0
- package/dist/utilities/rules.js +37 -0
- package/dist/utilities/server.d.ts +7 -0
- package/dist/utilities/server.js +12 -0
- package/dist/utilities/token-counter.d.ts +14 -0
- package/dist/utilities/token-counter.js +53 -0
- package/package.json +18 -28
- package/rules/asset-info.md +10 -0
- package/rules/asset-list.md +10 -0
- package/rules/component-cluster-list.md +5 -0
- package/{metadata/static/angular/index.md → rules/component-info-angular.md} +2 -1
- package/{metadata/static/react/index.md → rules/component-info-react.md} +2 -1
- package/{metadata/static/vue/index.md → rules/component-info-vue.md} +4 -1
- package/{metadata/static/component-list/index.md → rules/component-list.md} +5 -7
- package/rules/styles-info.md +9 -0
- package/{metadata/static/styles/index.md → rules/styles-list.md} +0 -2
- package/{metadata/static/templates/index.md → rules/template-info.md} +0 -1
- package/rules/template-list.md +7 -0
- package/dist/bin/create-checksum.d.ts +0 -2
- package/dist/bin/create-checksum.js +0 -24
- package/dist/build/assets.d.ts +0 -4
- package/dist/build/assets.js +0 -57
- package/dist/build/build.js +0 -35
- package/dist/build/components.d.ts +0 -4
- package/dist/build/components.js +0 -133
- package/dist/build/fonts.d.ts +0 -4
- package/dist/build/fonts.js +0 -49
- package/dist/build/frameworks.d.ts +0 -4
- package/dist/build/frameworks.js +0 -61
- package/dist/build/static.d.ts +0 -4
- package/dist/build/static.js +0 -65
- package/dist/build/styles.d.ts +0 -4
- package/dist/build/styles.js +0 -58
- package/dist/build/tokens.d.ts +0 -4
- package/dist/build/tokens.js +0 -59
- package/dist/tools/davinci-migration.d.ts +0 -3
- package/dist/tools/davinci-migration.js +0 -66
- package/dist/tools/font-info.d.ts +0 -6
- package/dist/tools/font-info.js +0 -35
- package/dist/tools/framework-info.d.ts +0 -7
- package/dist/tools/framework-info.js +0 -58
- package/dist/tools/tokens.js +0 -24
- package/dist/tools/version.d.ts +0 -7
- package/dist/tools/version.js +0 -53
- package/dist/utilities/assets.d.ts +0 -2
- package/dist/utilities/assets.js +0 -3
- package/dist/utilities/checksum.d.ts +0 -36
- package/dist/utilities/checksum.js +0 -94
- package/dist/utilities/components.d.ts +0 -25
- package/dist/utilities/components.js +0 -86
- package/dist/utilities/file.d.ts +0 -12
- package/dist/utilities/file.js +0 -31
- package/dist/utilities/fonts.d.ts +0 -2
- package/dist/utilities/fonts.js +0 -3
- package/dist/utilities/stdio.d.ts +0 -14
- package/dist/utilities/stdio.js +0 -60
- package/dist/utilities/storybook/build-docs.d.ts +0 -2
- package/dist/utilities/storybook/build-docs.js +0 -43
- package/dist/utilities/storybook/configs.d.ts +0 -13
- package/dist/utilities/storybook/configs.js +0 -85
- package/dist/utilities/storybook/docs-scraper.d.ts +0 -26
- package/dist/utilities/storybook/docs-scraper.js +0 -96
- package/dist/utilities/storybook/index.d.ts +0 -5
- package/dist/utilities/storybook/index.js +0 -4
- package/dist/utilities/storybook/scraper.d.ts +0 -14
- package/dist/utilities/storybook/scraper.js +0 -243
- package/dist/utilities/storybook/storybook-manager.d.ts +0 -29
- package/dist/utilities/storybook/storybook-manager.js +0 -138
- package/dist/utilities/storybook/types.d.ts +0 -22
- package/dist/utilities/storybook/types.js +0 -1
- package/dist/utilities/styles.d.ts +0 -6
- package/dist/utilities/styles.js +0 -24
- package/dist/utilities/templates.d.ts +0 -12
- package/dist/utilities/templates.js +0 -28
- package/dist/utilities/tokens.d.ts +0 -1
- package/dist/utilities/tokens.js +0 -21
- package/dist/utilities/version.d.ts +0 -28
- package/dist/utilities/version.js +0 -21
- package/metadata/checksum.txt +0 -1
- package/metadata/davinci-migration/migration-guide.md +0 -1859
- package/metadata/packages/angular/LIMITATIONS.md +0 -32
- package/metadata/packages/angular/README.md +0 -393
- package/metadata/packages/assets/BREAKING_CHANGES.md +0 -305
- package/metadata/packages/assets/CHANGELOG.md +0 -364
- package/metadata/packages/assets/README.md +0 -103
- package/metadata/packages/components/components/syn-accordion/component.angular.ts +0 -80
- package/metadata/packages/components/components/syn-accordion/component.react.ts +0 -30
- package/metadata/packages/components/components/syn-accordion/component.styles.ts +0 -15
- package/metadata/packages/components/components/syn-accordion/component.ts +0 -111
- package/metadata/packages/components/components/syn-accordion/component.vue +0 -64
- package/metadata/packages/components/components/syn-alert/component.angular.ts +0 -169
- package/metadata/packages/components/components/syn-alert/component.react.ts +0 -60
- package/metadata/packages/components/components/syn-alert/component.styles.ts +0 -203
- package/metadata/packages/components/components/syn-alert/component.ts +0 -322
- package/metadata/packages/components/components/syn-alert/component.vue +0 -135
- package/metadata/packages/components/components/syn-badge/component.angular.ts +0 -53
- package/metadata/packages/components/components/syn-badge/component.custom.styles.ts +0 -62
- package/metadata/packages/components/components/syn-badge/component.react.ts +0 -29
- package/metadata/packages/components/components/syn-badge/component.styles.ts +0 -52
- package/metadata/packages/components/components/syn-badge/component.ts +0 -58
- package/metadata/packages/components/components/syn-badge/component.vue +0 -53
- package/metadata/packages/components/components/syn-breadcrumb/component.angular.ts +0 -58
- package/metadata/packages/components/components/syn-breadcrumb/component.custom.styles.ts +0 -5
- package/metadata/packages/components/components/syn-breadcrumb/component.react.ts +0 -32
- package/metadata/packages/components/components/syn-breadcrumb/component.styles.ts +0 -11
- package/metadata/packages/components/components/syn-breadcrumb/component.ts +0 -103
- package/metadata/packages/components/components/syn-breadcrumb/component.vue +0 -58
- package/metadata/packages/components/components/syn-breadcrumb-item/component.angular.ts +0 -88
- package/metadata/packages/components/components/syn-breadcrumb-item/component.custom.styles.ts +0 -78
- package/metadata/packages/components/components/syn-breadcrumb-item/component.react.ts +0 -37
- package/metadata/packages/components/components/syn-breadcrumb-item/component.styles.ts +0 -88
- package/metadata/packages/components/components/syn-breadcrumb-item/component.ts +0 -132
- package/metadata/packages/components/components/syn-breadcrumb-item/component.vue +0 -76
- package/metadata/packages/components/components/syn-button/component.angular.ts +0 -318
- package/metadata/packages/components/components/syn-button/component.custom.styles.ts +0 -245
- package/metadata/packages/components/components/syn-button/component.react.ts +0 -56
- package/metadata/packages/components/components/syn-button/component.styles.ts +0 -361
- package/metadata/packages/components/components/syn-button/component.ts +0 -315
- package/metadata/packages/components/components/syn-button/component.vue +0 -204
- package/metadata/packages/components/components/syn-button-group/component.angular.ts +0 -79
- package/metadata/packages/components/components/syn-button-group/component.custom.styles.ts +0 -5
- package/metadata/packages/components/components/syn-button-group/component.react.ts +0 -29
- package/metadata/packages/components/components/syn-button-group/component.styles.ts +0 -14
- package/metadata/packages/components/components/syn-button-group/component.ts +0 -171
- package/metadata/packages/components/components/syn-button-group/component.vue +0 -67
- package/metadata/packages/components/components/syn-card/component.angular.ts +0 -83
- package/metadata/packages/components/components/syn-card/component.custom.styles.ts +0 -60
- package/metadata/packages/components/components/syn-card/component.react.ts +0 -41
- package/metadata/packages/components/components/syn-card/component.styles.ts +0 -70
- package/metadata/packages/components/components/syn-card/component.ts +0 -65
- package/metadata/packages/components/components/syn-card/component.vue +0 -73
- package/metadata/packages/components/components/syn-checkbox/component.angular.ts +0 -273
- package/metadata/packages/components/components/syn-checkbox/component.react.ts +0 -64
- package/metadata/packages/components/components/syn-checkbox/component.styles.ts +0 -183
- package/metadata/packages/components/components/syn-checkbox/component.ts +0 -287
- package/metadata/packages/components/components/syn-checkbox/component.vue +0 -191
- package/metadata/packages/components/components/syn-combobox/component.angular.ts +0 -516
- package/metadata/packages/components/components/syn-combobox/component.react.ts +0 -118
- package/metadata/packages/components/components/syn-combobox/component.styles.ts +0 -393
- package/metadata/packages/components/components/syn-combobox/component.ts +0 -1684
- package/metadata/packages/components/components/syn-combobox/component.vue +0 -350
- package/metadata/packages/components/components/syn-details/component.angular.ts +0 -186
- package/metadata/packages/components/components/syn-details/component.react.ts +0 -65
- package/metadata/packages/components/components/syn-details/component.styles.ts +0 -181
- package/metadata/packages/components/components/syn-details/component.ts +0 -261
- package/metadata/packages/components/components/syn-details/component.vue +0 -136
- package/metadata/packages/components/components/syn-dialog/component.angular.ts +0 -201
- package/metadata/packages/components/components/syn-dialog/component.react.ts +0 -91
- package/metadata/packages/components/components/syn-dialog/component.styles.ts +0 -130
- package/metadata/packages/components/components/syn-dialog/component.ts +0 -367
- package/metadata/packages/components/components/syn-dialog/component.vue +0 -169
- package/metadata/packages/components/components/syn-divider/component.angular.ts +0 -55
- package/metadata/packages/components/components/syn-divider/component.react.ts +0 -29
- package/metadata/packages/components/components/syn-divider/component.styles.ts +0 -22
- package/metadata/packages/components/components/syn-divider/component.ts +0 -34
- package/metadata/packages/components/components/syn-divider/component.vue +0 -51
- package/metadata/packages/components/components/syn-drawer/component.angular.ts +0 -234
- package/metadata/packages/components/components/syn-drawer/component.custom.styles.ts +0 -78
- package/metadata/packages/components/components/syn-drawer/component.react.ts +0 -98
- package/metadata/packages/components/components/syn-drawer/component.styles.ts +0 -158
- package/metadata/packages/components/components/syn-drawer/component.ts +0 -489
- package/metadata/packages/components/components/syn-drawer/component.vue +0 -188
- package/metadata/packages/components/components/syn-dropdown/component.angular.ts +0 -208
- package/metadata/packages/components/components/syn-dropdown/component.react.ts +0 -59
- package/metadata/packages/components/components/syn-dropdown/component.styles.ts +0 -51
- package/metadata/packages/components/components/syn-dropdown/component.ts +0 -469
- package/metadata/packages/components/components/syn-dropdown/component.vue +0 -152
- package/metadata/packages/components/components/syn-file/component.angular.ts +0 -372
- package/metadata/packages/components/components/syn-file/component.react.ts +0 -85
- package/metadata/packages/components/components/syn-file/component.styles.ts +0 -197
- package/metadata/packages/components/components/syn-file/component.ts +0 -645
- package/metadata/packages/components/components/syn-file/component.vue +0 -256
- package/metadata/packages/components/components/syn-header/component.angular.ts +0 -149
- package/metadata/packages/components/components/syn-header/component.react.ts +0 -68
- package/metadata/packages/components/components/syn-header/component.styles.ts +0 -143
- package/metadata/packages/components/components/syn-header/component.ts +0 -310
- package/metadata/packages/components/components/syn-header/component.vue +0 -126
- package/metadata/packages/components/components/syn-icon/component.angular.ts +0 -115
- package/metadata/packages/components/components/syn-icon/component.custom.styles.ts +0 -5
- package/metadata/packages/components/components/syn-icon/component.react.ts +0 -41
- package/metadata/packages/components/components/syn-icon/component.styles.ts +0 -18
- package/metadata/packages/components/components/syn-icon/component.ts +0 -227
- package/metadata/packages/components/components/syn-icon/component.vue +0 -100
- package/metadata/packages/components/components/syn-icon-button/component.angular.ts +0 -185
- package/metadata/packages/components/components/syn-icon-button/component.custom.styles.ts +0 -79
- package/metadata/packages/components/components/syn-icon-button/component.react.ts +0 -42
- package/metadata/packages/components/components/syn-icon-button/component.styles.ts +0 -52
- package/metadata/packages/components/components/syn-icon-button/component.ts +0 -147
- package/metadata/packages/components/components/syn-icon-button/component.vue +0 -132
- package/metadata/packages/components/components/syn-input/component.angular.ts +0 -608
- package/metadata/packages/components/components/syn-input/component.custom.styles.ts +0 -278
- package/metadata/packages/components/components/syn-input/component.react.ts +0 -91
- package/metadata/packages/components/components/syn-input/component.styles.ts +0 -280
- package/metadata/packages/components/components/syn-input/component.ts +0 -941
- package/metadata/packages/components/components/syn-input/component.vue +0 -370
- package/metadata/packages/components/components/syn-menu/component.angular.ts +0 -52
- package/metadata/packages/components/components/syn-menu/component.react.ts +0 -36
- package/metadata/packages/components/components/syn-menu/component.styles.ts +0 -37
- package/metadata/packages/components/components/syn-menu/component.ts +0 -191
- package/metadata/packages/components/components/syn-menu/component.vue +0 -48
- package/metadata/packages/components/components/syn-menu-item/component.angular.ts +0 -121
- package/metadata/packages/components/components/syn-menu-item/component.react.ts +0 -45
- package/metadata/packages/components/components/syn-menu-item/component.styles.ts +0 -285
- package/metadata/packages/components/components/syn-menu-item/component.ts +0 -201
- package/metadata/packages/components/components/syn-menu-item/component.vue +0 -91
- package/metadata/packages/components/components/syn-menu-label/component.angular.ts +0 -48
- package/metadata/packages/components/components/syn-menu-label/component.react.ts +0 -35
- package/metadata/packages/components/components/syn-menu-label/component.styles.ts +0 -31
- package/metadata/packages/components/components/syn-menu-label/component.ts +0 -46
- package/metadata/packages/components/components/syn-menu-label/component.vue +0 -41
- package/metadata/packages/components/components/syn-nav-item/component.angular.ts +0 -242
- package/metadata/packages/components/components/syn-nav-item/component.react.ts +0 -82
- package/metadata/packages/components/components/syn-nav-item/component.styles.ts +0 -333
- package/metadata/packages/components/components/syn-nav-item/component.ts +0 -491
- package/metadata/packages/components/components/syn-nav-item/component.vue +0 -182
- package/metadata/packages/components/components/syn-optgroup/component.angular.ts +0 -79
- package/metadata/packages/components/components/syn-optgroup/component.react.ts +0 -41
- package/metadata/packages/components/components/syn-optgroup/component.styles.ts +0 -61
- package/metadata/packages/components/components/syn-optgroup/component.ts +0 -176
- package/metadata/packages/components/components/syn-optgroup/component.vue +0 -71
- package/metadata/packages/components/components/syn-option/component.angular.ts +0 -79
- package/metadata/packages/components/components/syn-option/component.react.ts +0 -37
- package/metadata/packages/components/components/syn-option/component.styles.ts +0 -165
- package/metadata/packages/components/components/syn-option/component.ts +0 -191
- package/metadata/packages/components/components/syn-option/component.vue +0 -71
- package/metadata/packages/components/components/syn-popup/component.angular.ts +0 -372
- package/metadata/packages/components/components/syn-popup/component.react.ts +0 -55
- package/metadata/packages/components/components/syn-popup/component.styles.ts +0 -70
- package/metadata/packages/components/components/syn-popup/component.ts +0 -582
- package/metadata/packages/components/components/syn-popup/component.vue +0 -233
- package/metadata/packages/components/components/syn-prio-nav/component.angular.ts +0 -67
- package/metadata/packages/components/components/syn-prio-nav/component.react.ts +0 -54
- package/metadata/packages/components/components/syn-prio-nav/component.styles.ts +0 -48
- package/metadata/packages/components/components/syn-prio-nav/component.ts +0 -288
- package/metadata/packages/components/components/syn-prio-nav/component.vue +0 -60
- package/metadata/packages/components/components/syn-progress-bar/component.angular.ts +0 -85
- package/metadata/packages/components/components/syn-progress-bar/component.custom.styles.ts +0 -24
- package/metadata/packages/components/components/syn-progress-bar/component.react.ts +0 -37
- package/metadata/packages/components/components/syn-progress-bar/component.styles.ts +0 -87
- package/metadata/packages/components/components/syn-progress-bar/component.ts +0 -67
- package/metadata/packages/components/components/syn-progress-bar/component.vue +0 -71
- package/metadata/packages/components/components/syn-progress-ring/component.angular.ts +0 -72
- package/metadata/packages/components/components/syn-progress-ring/component.custom.styles.ts +0 -19
- package/metadata/packages/components/components/syn-progress-ring/component.react.ts +0 -37
- package/metadata/packages/components/components/syn-progress-ring/component.styles.ts +0 -70
- package/metadata/packages/components/components/syn-progress-ring/component.ts +0 -83
- package/metadata/packages/components/components/syn-progress-ring/component.vue +0 -66
- package/metadata/packages/components/components/syn-radio/component.angular.ts +0 -122
- package/metadata/packages/components/components/syn-radio/component.react.ts +0 -48
- package/metadata/packages/components/components/syn-radio/component.styles.ts +0 -179
- package/metadata/packages/components/components/syn-radio/component.ts +0 -131
- package/metadata/packages/components/components/syn-radio/component.vue +0 -104
- package/metadata/packages/components/components/syn-radio-button/component.angular.ts +0 -123
- package/metadata/packages/components/components/syn-radio-button/component.react.ts +0 -49
- package/metadata/packages/components/components/syn-radio-button/component.styles.ts +0 -30
- package/metadata/packages/components/components/syn-radio-button/component.ts +0 -142
- package/metadata/packages/components/components/syn-radio-button/component.vue +0 -105
- package/metadata/packages/components/components/syn-radio-group/component.angular.ts +0 -204
- package/metadata/packages/components/components/syn-radio-group/component.react.ts +0 -56
- package/metadata/packages/components/components/syn-radio-group/component.styles.ts +0 -58
- package/metadata/packages/components/components/syn-radio-group/component.ts +0 -440
- package/metadata/packages/components/components/syn-radio-group/component.vue +0 -158
- package/metadata/packages/components/components/syn-range/component.angular.ts +0 -347
- package/metadata/packages/components/components/syn-range/component.react.ts +0 -92
- package/metadata/packages/components/components/syn-range/component.styles.ts +0 -310
- package/metadata/packages/components/components/syn-range/component.ts +0 -933
- package/metadata/packages/components/components/syn-range/component.vue +0 -245
- package/metadata/packages/components/components/syn-range-tick/component.angular.ts +0 -59
- package/metadata/packages/components/components/syn-range-tick/component.react.ts +0 -33
- package/metadata/packages/components/components/syn-range-tick/component.styles.ts +0 -34
- package/metadata/packages/components/components/syn-range-tick/component.ts +0 -50
- package/metadata/packages/components/components/syn-range-tick/component.vue +0 -57
- package/metadata/packages/components/components/syn-resize-observer/component.styles.ts +0 -9
- package/metadata/packages/components/components/syn-resize-observer/component.ts +0 -91
- package/metadata/packages/components/components/syn-select/component.angular.ts +0 -439
- package/metadata/packages/components/components/syn-select/component.react.ts +0 -101
- package/metadata/packages/components/components/syn-select/component.styles.ts +0 -380
- package/metadata/packages/components/components/syn-select/component.ts +0 -1056
- package/metadata/packages/components/components/syn-select/component.vue +0 -301
- package/metadata/packages/components/components/syn-side-nav/component.angular.ts +0 -210
- package/metadata/packages/components/components/syn-side-nav/component.react.ts +0 -95
- package/metadata/packages/components/components/syn-side-nav/component.styles.ts +0 -142
- package/metadata/packages/components/components/syn-side-nav/component.ts +0 -458
- package/metadata/packages/components/components/syn-side-nav/component.vue +0 -188
- package/metadata/packages/components/components/syn-spinner/component.angular.ts +0 -44
- package/metadata/packages/components/components/syn-spinner/component.custom.styles.ts +0 -32
- package/metadata/packages/components/components/syn-spinner/component.react.ts +0 -31
- package/metadata/packages/components/components/syn-spinner/component.styles.ts +0 -48
- package/metadata/packages/components/components/syn-spinner/component.ts +0 -35
- package/metadata/packages/components/components/syn-spinner/component.vue +0 -35
- package/metadata/packages/components/components/syn-switch/component.angular.ts +0 -257
- package/metadata/packages/components/components/syn-switch/component.react.ts +0 -63
- package/metadata/packages/components/components/syn-switch/component.styles.ts +0 -252
- package/metadata/packages/components/components/syn-switch/component.ts +0 -279
- package/metadata/packages/components/components/syn-switch/component.vue +0 -183
- package/metadata/packages/components/components/syn-tab/component.angular.ts +0 -109
- package/metadata/packages/components/components/syn-tab/component.custom.styles.ts +0 -94
- package/metadata/packages/components/components/syn-tab/component.react.ts +0 -42
- package/metadata/packages/components/components/syn-tab/component.styles.ts +0 -70
- package/metadata/packages/components/components/syn-tab/component.ts +0 -125
- package/metadata/packages/components/components/syn-tab/component.vue +0 -91
- package/metadata/packages/components/components/syn-tab-group/component.angular.ts +0 -166
- package/metadata/packages/components/components/syn-tab-group/component.custom.styles.ts +0 -218
- package/metadata/packages/components/components/syn-tab-group/component.react.ts +0 -58
- package/metadata/packages/components/components/syn-tab-group/component.styles.ts +0 -193
- package/metadata/packages/components/components/syn-tab-group/component.ts +0 -551
- package/metadata/packages/components/components/syn-tab-group/component.vue +0 -126
- package/metadata/packages/components/components/syn-tab-panel/component.angular.ts +0 -68
- package/metadata/packages/components/components/syn-tab-panel/component.custom.styles.ts +0 -8
- package/metadata/packages/components/components/syn-tab-panel/component.react.ts +0 -31
- package/metadata/packages/components/components/syn-tab-panel/component.styles.ts +0 -20
- package/metadata/packages/components/components/syn-tab-panel/component.ts +0 -60
- package/metadata/packages/components/components/syn-tab-panel/component.vue +0 -60
- package/metadata/packages/components/components/syn-tag/component.angular.ts +0 -83
- package/metadata/packages/components/components/syn-tag/component.custom.styles.ts +0 -121
- package/metadata/packages/components/components/syn-tag/component.react.ts +0 -43
- package/metadata/packages/components/components/syn-tag/component.styles.ts +0 -58
- package/metadata/packages/components/components/syn-tag/component.ts +0 -83
- package/metadata/packages/components/components/syn-tag/component.vue +0 -81
- package/metadata/packages/components/components/syn-tag-group/component.angular.ts +0 -83
- package/metadata/packages/components/components/syn-tag-group/component.react.ts +0 -33
- package/metadata/packages/components/components/syn-tag-group/component.styles.ts +0 -49
- package/metadata/packages/components/components/syn-tag-group/component.ts +0 -95
- package/metadata/packages/components/components/syn-tag-group/component.vue +0 -69
- package/metadata/packages/components/components/syn-textarea/component.angular.ts +0 -396
- package/metadata/packages/components/components/syn-textarea/component.react.ts +0 -60
- package/metadata/packages/components/components/syn-textarea/component.styles.ts +0 -208
- package/metadata/packages/components/components/syn-textarea/component.ts +0 -400
- package/metadata/packages/components/components/syn-textarea/component.vue +0 -244
- package/metadata/packages/components/components/syn-tooltip/component.angular.ts +0 -196
- package/metadata/packages/components/components/syn-tooltip/component.react.ts +0 -63
- package/metadata/packages/components/components/syn-tooltip/component.styles.ts +0 -62
- package/metadata/packages/components/components/syn-tooltip/component.ts +0 -312
- package/metadata/packages/components/components/syn-tooltip/component.vue +0 -150
- package/metadata/packages/components/components/syn-validate/component.angular.ts +0 -137
- package/metadata/packages/components/components/syn-validate/component.react.ts +0 -44
- package/metadata/packages/components/components/syn-validate/component.styles.ts +0 -9
- package/metadata/packages/components/components/syn-validate/component.ts +0 -590
- package/metadata/packages/components/components/syn-validate/component.vue +0 -107
- package/metadata/packages/components/migration/BREAKING_CHANGES.md +0 -908
- package/metadata/packages/components/static/CHANGELOG.md +0 -2140
- package/metadata/packages/components/static/LIMITATIONS.md +0 -433
- package/metadata/packages/components/static/README.md +0 -231
- package/metadata/packages/fonts/CHANGELOG.md +0 -57
- package/metadata/packages/fonts/README.md +0 -164
- package/metadata/packages/fonts/package.json +0 -72
- package/metadata/packages/react/LIMITATIONS.md +0 -31
- package/metadata/packages/react/README.md +0 -262
- package/metadata/packages/styles/BREAKING_CHANGES.md +0 -105
- package/metadata/packages/styles/CHANGELOG.md +0 -188
- package/metadata/packages/styles/README.md +0 -132
- package/metadata/packages/styles/index.css +0 -300
- package/metadata/packages/styles/link-list.css +0 -47
- package/metadata/packages/styles/link.css +0 -81
- package/metadata/packages/styles/tables.css +0 -132
- package/metadata/packages/styles/typography.css +0 -52
- package/metadata/packages/tokens/BREAKING_CHANGES.md +0 -180
- package/metadata/packages/tokens/CHANGELOG.md +0 -949
- package/metadata/packages/tokens/README.md +0 -435
- package/metadata/packages/tokens/dark.css +0 -454
- package/metadata/packages/tokens/index.js +0 -2224
- package/metadata/packages/tokens/light.css +0 -454
- package/metadata/packages/tokens/sick2018_dark.css +0 -454
- package/metadata/packages/tokens/sick2018_light.css +0 -454
- package/metadata/packages/tokens/sick2025_dark.css +0 -454
- package/metadata/packages/tokens/sick2025_light.css +0 -454
- package/metadata/packages/vue/LIMITATIONS.md +0 -53
- package/metadata/packages/vue/README.md +0 -252
- package/metadata/static/assets/index.md +0 -10
- package/metadata/static/components/index.md +0 -10
- package/metadata/static/components/syn-accordion/docs.md +0 -449
- package/metadata/static/components/syn-alert/docs.md +0 -282
- package/metadata/static/components/syn-badge/docs.md +0 -106
- package/metadata/static/components/syn-breadcrumb/docs.md +0 -265
- package/metadata/static/components/syn-breadcrumb-item/docs.md +0 -49
- package/metadata/static/components/syn-button/docs.md +0 -472
- package/metadata/static/components/syn-button-group/docs.md +0 -259
- package/metadata/static/components/syn-card/docs.md +0 -314
- package/metadata/static/components/syn-checkbox/docs.md +0 -176
- package/metadata/static/components/syn-combobox/docs.md +0 -2633
- package/metadata/static/components/syn-details/docs.md +0 -227
- package/metadata/static/components/syn-dialog/docs.md +0 -220
- package/metadata/static/components/syn-divider/docs.md +0 -77
- package/metadata/static/components/syn-drawer/docs.md +0 -269
- package/metadata/static/components/syn-dropdown/docs.md +0 -316
- package/metadata/static/components/syn-file/docs.md +0 -239
- package/metadata/static/components/syn-header/docs.md +0 -209
- package/metadata/static/components/syn-icon/docs.md +0 -177
- package/metadata/static/components/syn-icon-button/docs.md +0 -142
- package/metadata/static/components/syn-input/docs.md +0 -462
- package/metadata/static/components/syn-menu/docs.md +0 -162
- package/metadata/static/components/syn-menu-item/docs.md +0 -216
- package/metadata/static/components/syn-menu-label/docs.md +0 -29
- package/metadata/static/components/syn-nav-item/docs.md +0 -166
- package/metadata/static/components/syn-optgroup/docs.md +0 -167
- package/metadata/static/components/syn-option/docs.md +0 -137
- package/metadata/static/components/syn-popup/docs.md +0 -812
- package/metadata/static/components/syn-prio-nav/docs.md +0 -54
- package/metadata/static/components/syn-progress-bar/docs.md +0 -77
- package/metadata/static/components/syn-progress-ring/docs.md +0 -89
- package/metadata/static/components/syn-radio/docs.md +0 -178
- package/metadata/static/components/syn-radio-group/docs.md +0 -484
- package/metadata/static/components/syn-range/docs.md +0 -438
- package/metadata/static/components/syn-range-tick/docs.md +0 -110
- package/metadata/static/components/syn-select/docs.md +0 -811
- package/metadata/static/components/syn-side-nav/docs.md +0 -593
- package/metadata/static/components/syn-spinner/docs.md +0 -45
- package/metadata/static/components/syn-switch/docs.md +0 -121
- package/metadata/static/components/syn-tab/docs.md +0 -47
- package/metadata/static/components/syn-tab-group/docs.md +0 -1094
- package/metadata/static/components/syn-tab-panel/docs.md +0 -91
- package/metadata/static/components/syn-tag/docs.md +0 -50
- package/metadata/static/components/syn-tag-group/docs.md +0 -269
- package/metadata/static/components/syn-textarea/docs.md +0 -215
- package/metadata/static/components/syn-tooltip/docs.md +0 -217
- package/metadata/static/components/syn-validate/docs.md +0 -305
- package/metadata/static/fonts/index.md +0 -4
- package/metadata/static/migration/index.md +0 -57
- package/metadata/static/migration/v2-2018-to-v2-2025.md +0 -481
- package/metadata/static/migration/v2-2018-to-v3-2018.md +0 -147
- package/metadata/static/migration/v2-2018-to-v3-2025.md +0 -150
- package/metadata/static/migration/v2-2025-to-v3-2025.md +0 -133
- package/metadata/static/setup/icon-usage.md +0 -411
- package/metadata/static/setup/prerequisites.md +0 -319
- package/metadata/static/styles/syn-body.md +0 -5
- package/metadata/static/styles/syn-heading.md +0 -5
- package/metadata/static/styles/syn-link-list.md +0 -325
- package/metadata/static/styles/syn-link.md +0 -156
- package/metadata/static/styles/syn-table-cell.md +0 -127
- package/metadata/static/styles/syn-table.md +0 -201
- package/metadata/static/styles/syn-weight.md +0 -5
- package/metadata/static/templates/appshell.md +0 -2053
- package/metadata/static/templates/breadcrumb.md +0 -379
- package/metadata/static/templates/footer.md +0 -340
- package/metadata/static/templates/forms.md +0 -558
- package/metadata/static/templates/localization.md +0 -279
- package/metadata/static/templates/table.md +0 -1425
- package/metadata/static/templates/tag-group.md +0 -833
- /package/dist/{build/build.d.ts → utilities/logging-types.js} +0 -0
- /package/{metadata/static/component-info/index.md → rules/component-info.md} +0 -0
|
@@ -1,1684 +0,0 @@
|
|
|
1
|
-
/* eslint-disable lit-a11y/click-events-have-key-events */
|
|
2
|
-
/* eslint-disable no-param-reassign */
|
|
3
|
-
/* eslint-disable no-underscore-dangle */
|
|
4
|
-
import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
5
|
-
import { classMap } from 'lit/directives/class-map.js';
|
|
6
|
-
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
7
|
-
import { html } from 'lit';
|
|
8
|
-
import { property, query, state } from 'lit/decorators.js';
|
|
9
|
-
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
10
|
-
import { animateTo, stopAnimations } from '../../internal/animate.js';
|
|
11
|
-
import { FormControlController } from '../../internal/form.js';
|
|
12
|
-
import { getAnimation, setDefaultAnimation } from '../../utilities/animation-registry.js';
|
|
13
|
-
import { HasSlotController } from '../../internal/slot.js';
|
|
14
|
-
import { LocalizeController } from '../../utilities/localize.js';
|
|
15
|
-
import { waitForEvent } from '../../internal/event.js';
|
|
16
|
-
import { watch } from '../../internal/watch.js';
|
|
17
|
-
import componentStyles from '../../styles/component.styles.js';
|
|
18
|
-
import formControlStyles from '../../styles/form-control.styles.js';
|
|
19
|
-
import SynergyElement from '../../internal/synergy-element.js';
|
|
20
|
-
import SynIcon from '../icon/icon.component.js';
|
|
21
|
-
import SynPopup from '../popup/popup.component.js';
|
|
22
|
-
import type { SynergyFormControl } from '../../internal/synergy-element.js';
|
|
23
|
-
import SynOption from '../option/option.component.js';
|
|
24
|
-
import type SynOptGroup from '../optgroup/optgroup.js';
|
|
25
|
-
import SynTag from '../tag/tag.component.js';
|
|
26
|
-
import styles from './combobox.styles.js';
|
|
27
|
-
import {
|
|
28
|
-
checkValueBelongsToOption,
|
|
29
|
-
createOptionFromDifferentTypes, filterOnlyOptgroups, getAllOptions, getAssignedElementsForSlot,
|
|
30
|
-
getValueFromOption, getValuesFromOptions, normalizeString,
|
|
31
|
-
} from './utils.js';
|
|
32
|
-
import { scrollIntoView } from '../../internal/scroll.js';
|
|
33
|
-
import { type OptionRenderer, defaultOptionRenderer } from './option-renderer.js';
|
|
34
|
-
import { enableDefaultSettings } from '../../utilities/defaultSettings/decorator.js';
|
|
35
|
-
import type { SynRemoveEvent } from '../../events/events.js';
|
|
36
|
-
import { compareValues, isAllowedValue } from '../select/utility.js';
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @summary A combobox component that combines the functionality of a text input with a dropdown listbox,
|
|
40
|
-
* allowing users to either select from predefined options or enter custom values (when not restricted).
|
|
41
|
-
*
|
|
42
|
-
* @documentation https://synergy-design-system.github.io/?path=/docs/components-syn-combobox--docs
|
|
43
|
-
* @status stable
|
|
44
|
-
*
|
|
45
|
-
* @dependency syn-icon
|
|
46
|
-
* @dependency syn-popup
|
|
47
|
-
* @dependency syn-tag
|
|
48
|
-
*
|
|
49
|
-
* @slot - The listbox options. Must be `<syn-option>` elements.
|
|
50
|
-
* You can use `<syn-optgroup>`'s to group items visually.
|
|
51
|
-
* @slot label - The combobox's label. Alternatively, you can use the `label` attribute.
|
|
52
|
-
* @slot prefix - Used to prepend a presentational icon or similar element to the combobox.
|
|
53
|
-
* @slot suffix - Used to append a presentational icon or similar element to the combobox.
|
|
54
|
-
* @slot clear-icon - An icon to use in lieu of the default clear icon.
|
|
55
|
-
* @slot expand-icon - The icon to show when the control is expanded and collapsed.
|
|
56
|
-
* Rotates on open and close.
|
|
57
|
-
* @slot help-text - Text that describes how to use the combobox.
|
|
58
|
-
* Alternatively, you can use the `help-text` attribute.
|
|
59
|
-
*
|
|
60
|
-
* @event syn-change - Emitted when the control's value changes.
|
|
61
|
-
* @event syn-clear - Emitted when the control's value is cleared.
|
|
62
|
-
* @event syn-input - Emitted when the control receives input.
|
|
63
|
-
* @event syn-focus - Emitted when the control gains focus.
|
|
64
|
-
* @event syn-blur - Emitted when the control loses focus.
|
|
65
|
-
* @event syn-show - Emitted when the combobox's menu opens.
|
|
66
|
-
* @event syn-after-show - Emitted after the combobox's menu opens and all animations are complete.
|
|
67
|
-
* @event syn-hide - Emitted when the combobox's menu closes.
|
|
68
|
-
* @event syn-after-hide - Emitted after the combobox's menu closes and all animations are complete.
|
|
69
|
-
* @event syn-invalid - Emitted when the form control has been checked for validity
|
|
70
|
-
* and its constraints aren't satisfied.
|
|
71
|
-
* @event syn-error - Emitted when the combobox menu fails to open.
|
|
72
|
-
*
|
|
73
|
-
* @csspart form-control - The form control that wraps the label, combobox, and help text.
|
|
74
|
-
* @csspart form-control-label - The label's wrapper.
|
|
75
|
-
* @csspart form-control-input - The combobox's wrapper.
|
|
76
|
-
* @csspart form-control-help-text - The help text's wrapper.
|
|
77
|
-
* @csspart combobox - The container that wraps the prefix, combobox, clear icon, and expand button.
|
|
78
|
-
* @csspart prefix - The container that wraps the prefix slot.
|
|
79
|
-
* @csspart suffix - The container that wraps the suffix slot.
|
|
80
|
-
* @csspart display-input - The element that displays the selected option's label,
|
|
81
|
-
* an `<input>` element.
|
|
82
|
-
* @csspart listbox - The listbox container where the options are slotted
|
|
83
|
-
* and the filtered options list exists.
|
|
84
|
-
* @csspart filtered-listbox - The container that wraps the filtered options.
|
|
85
|
-
* @csspart clear-button - The clear button.
|
|
86
|
-
* @csspart expand-icon - The container that wraps the expand icon.
|
|
87
|
-
* @csspart popup - The popup's exported `popup` part.
|
|
88
|
-
* Use this to target the tooltip's popup container.
|
|
89
|
-
* @csspart no-results - The container that wraps the "no results" message.
|
|
90
|
-
* @csspart tags - The container that houses option tags when `multiple` is used.
|
|
91
|
-
* @csspart tag - The individual tags that represent each selected option in `multiple`.
|
|
92
|
-
* @csspart tag__base - The tag's base part.
|
|
93
|
-
* @csspart tag__content - The tag's content part.
|
|
94
|
-
* @csspart tag__remove-button - The tag's remove button.
|
|
95
|
-
* @csspart tag__remove-button__base - The tag's remove button base part.
|
|
96
|
-
*
|
|
97
|
-
* @animation combobox.show - The animation to use when showing the combobox.
|
|
98
|
-
* @animation combobox.hide - The animation to use when hiding the combobox.
|
|
99
|
-
*/
|
|
100
|
-
@enableDefaultSettings('SynCombobox')
|
|
101
|
-
export default class SynCombobox extends SynergyElement implements SynergyFormControl {
|
|
102
|
-
static styles: CSSResultGroup = [
|
|
103
|
-
componentStyles,
|
|
104
|
-
formControlStyles,
|
|
105
|
-
styles,
|
|
106
|
-
];
|
|
107
|
-
|
|
108
|
-
static dependencies = {
|
|
109
|
-
'syn-icon': SynIcon,
|
|
110
|
-
'syn-popup': SynPopup,
|
|
111
|
-
'syn-tag': SynTag,
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
private readonly formControlController = new FormControlController(this, {
|
|
115
|
-
assumeInteractionOn: ['syn-blur', 'syn-input'],
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
private readonly hasSlotController = new HasSlotController(this, 'help-text', 'label');
|
|
119
|
-
|
|
120
|
-
private readonly localize = new LocalizeController(this);
|
|
121
|
-
|
|
122
|
-
private closeWatcher: CloseWatcher | null;
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Cache of the last syn-options that were selected by user interaction (click or keyboard navigation).
|
|
126
|
-
* Used to track user selections and maintain selection state during value changes.
|
|
127
|
-
*/
|
|
128
|
-
private lastOptions: SynOption[] = [];
|
|
129
|
-
|
|
130
|
-
private isInitialized: boolean = false;
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Flag to prevent infinite loops when the option renderer programmatically updates options.
|
|
134
|
-
* Set to true during option rendering to ignore slot change events triggered by our own updates.
|
|
135
|
-
*/
|
|
136
|
-
private isOptionRendererTriggered: boolean = false;
|
|
137
|
-
|
|
138
|
-
private resizeObserver: ResizeObserver;
|
|
139
|
-
|
|
140
|
-
private mutationObserver: MutationObserver;
|
|
141
|
-
|
|
142
|
-
@query('.combobox') popup: SynPopup;
|
|
143
|
-
|
|
144
|
-
@query('.combobox__inputs') combobox: HTMLSlotElement;
|
|
145
|
-
|
|
146
|
-
@query('.combobox__display-input') displayInput: HTMLInputElement;
|
|
147
|
-
|
|
148
|
-
@query('.combobox__value-input') valueInput: HTMLInputElement;
|
|
149
|
-
|
|
150
|
-
@query('.combobox__listbox') listbox: HTMLSlotElement;
|
|
151
|
-
|
|
152
|
-
@query('slot:not([name])') private defaultSlot: HTMLSlotElement;
|
|
153
|
-
|
|
154
|
-
@query('.combobox__tags') tagContainer: HTMLDivElement;
|
|
155
|
-
|
|
156
|
-
@state() private hasFocus = false;
|
|
157
|
-
|
|
158
|
-
@state() private isUserInput = false;
|
|
159
|
-
|
|
160
|
-
@state() displayLabel = '';
|
|
161
|
-
|
|
162
|
-
@state() selectedOptions: SynOption[] = [];
|
|
163
|
-
|
|
164
|
-
@state() numberFilteredOptions = 0;
|
|
165
|
-
|
|
166
|
-
@state() cachedOptions: SynOption[] = [];
|
|
167
|
-
|
|
168
|
-
@state() private valueHasChanged: boolean = false;
|
|
169
|
-
|
|
170
|
-
@state() private hideOptions = false;
|
|
171
|
-
|
|
172
|
-
/** The name of the combobox, submitted as a name/value pair with form data. */
|
|
173
|
-
@property() name = '';
|
|
174
|
-
|
|
175
|
-
private _value: string | number | Array<string | number> = '';
|
|
176
|
-
|
|
177
|
-
get value() {
|
|
178
|
-
return this._value;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* The current value of the combobox, submitted as a name/value pair with form data. When `multiple` is enabled, the
|
|
183
|
-
* value attribute will be a list of values separated by the delimiter, based on the options selected, and the value property will
|
|
184
|
-
* be an array. **For this reason, values must not contain the delimiter character.**
|
|
185
|
-
*/
|
|
186
|
-
@state()
|
|
187
|
-
set value(val: string | number | Array<string | number>) {
|
|
188
|
-
if (this.multiple) {
|
|
189
|
-
if (!Array.isArray(val)) {
|
|
190
|
-
val = typeof val === 'string' ? val.split(this.delimiter) : [val].filter(isAllowedValue);
|
|
191
|
-
}
|
|
192
|
-
} else {
|
|
193
|
-
val = Array.isArray(val) ? val.join(this.delimiter) : val;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (compareValues(this._value, val)) {
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
this.valueHasChanged = true;
|
|
201
|
-
this._value = val;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/** The default value of the form control. Primarily used for resetting the form control. */
|
|
205
|
-
@property({ attribute: 'value' }) defaultValue: string | number | Array<string | number> = '';
|
|
206
|
-
|
|
207
|
-
/** The combobox's size. */
|
|
208
|
-
@property({ reflect: true }) size: 'small' | 'medium' | 'large' = 'medium';
|
|
209
|
-
|
|
210
|
-
/** Placeholder text to show as a hint when the combobox is empty. */
|
|
211
|
-
@property() placeholder = '';
|
|
212
|
-
|
|
213
|
-
/** Disables the combobox control. */
|
|
214
|
-
@property({ reflect: true, type: Boolean }) disabled = false;
|
|
215
|
-
|
|
216
|
-
/** Sets the combobox to a readonly state. */
|
|
217
|
-
@property({ reflect: true, type: Boolean }) readonly = false;
|
|
218
|
-
|
|
219
|
-
/** Adds a clear button when the combobox is not empty. */
|
|
220
|
-
@property({ type: Boolean }) clearable = false;
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Indicates whether or not the combobox is open.
|
|
224
|
-
* You can toggle this attribute to show and hide the listbox, or you can use the `show()`
|
|
225
|
-
* and `hide()` methods and this attribute will reflect the combobox's open state.
|
|
226
|
-
*/
|
|
227
|
-
@property({ reflect: true, type: Boolean }) open = false;
|
|
228
|
-
|
|
229
|
-
/** The combobox's label. If you need to display HTML, use the `label` slot instead. */
|
|
230
|
-
@property() label = '';
|
|
231
|
-
|
|
232
|
-
/** The maximum length of input that will be considered valid. */
|
|
233
|
-
@property({ type: Number }) maxlength: number;
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* The preferred placement of the combobox's menu.
|
|
237
|
-
* Note that the actual placement may vary as needed to keep the listbox inside of the viewport.
|
|
238
|
-
*/
|
|
239
|
-
@property({ reflect: true }) placement: 'top' | 'bottom' = 'bottom';
|
|
240
|
-
|
|
241
|
-
/** The combobox's help text. If you need to display HTML, use the `help-text` slot instead. */
|
|
242
|
-
@property({ attribute: 'help-text' }) helpText = '';
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* By default, form controls are associated with the nearest containing `<form>` element.
|
|
246
|
-
* This attribute allows you to place the form control outside of a form and associate it
|
|
247
|
-
* with the form that has this `id`.
|
|
248
|
-
* The form must be in the same document or shadow root for this to work.
|
|
249
|
-
*/
|
|
250
|
-
@property({ reflect: true }) form = '';
|
|
251
|
-
|
|
252
|
-
/** The combobox's required attribute. */
|
|
253
|
-
@property({ reflect: true, type: Boolean }) required = false;
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* When set to `true`, restricts the combobox to only allow selection from the available options.
|
|
257
|
-
* Users will not be able to enter custom values that are not present in the list.
|
|
258
|
-
* This will always be true, if `multiple` is active.
|
|
259
|
-
*/
|
|
260
|
-
@property({ reflect: true, type: Boolean }) restricted = false;
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Allows more than one option to be selected.
|
|
264
|
-
* If `multiple` is set, the combobox will always be `restricted` to the available options
|
|
265
|
-
* */
|
|
266
|
-
@property({ reflect: true, type: Boolean }) multiple = false;
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* A function that customizes the rendered option. The first argument is the option, the second
|
|
270
|
-
* is the query string, which is typed into the combobox.
|
|
271
|
-
* The function should return either a Lit TemplateResult or a string containing trusted HTML
|
|
272
|
-
* to render in the shown list of filtered options.
|
|
273
|
-
* If the query string should be highlighted use the `highlightOptionRenderer` function.
|
|
274
|
-
*/
|
|
275
|
-
@property() getOption: OptionRenderer = defaultOptionRenderer;
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* A function used to filter options in the combobox component.
|
|
279
|
-
* The default filter method is a case- and diacritic-insensitive string comparison.
|
|
280
|
-
*
|
|
281
|
-
* @param option - The option to be filtered.
|
|
282
|
-
* @param queryString - The query string used for filtering.
|
|
283
|
-
* @returns A boolean indicating whether the option should be included in the filtered results.
|
|
284
|
-
*/
|
|
285
|
-
// eslint-disable-next-line class-methods-use-this
|
|
286
|
-
@property() filter: (option: SynOption, queryString: string) => boolean = (option, queryStr) => {
|
|
287
|
-
let content = option?.textContent || '';
|
|
288
|
-
if (option instanceof SynOption) {
|
|
289
|
-
content = option.getTextLabel();
|
|
290
|
-
}
|
|
291
|
-
const normalizedOption = normalizeString(content);
|
|
292
|
-
const normalizedQuery = normalizeString(queryStr);
|
|
293
|
-
|
|
294
|
-
if (normalizedOption.includes(normalizedQuery)) {
|
|
295
|
-
return true;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
return option?.value?.toString() === queryStr;
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* The delimiter to use when setting the value when `multiple` is enabled.
|
|
303
|
-
* The default is a space ' ', but you can set it to a comma or other character(s).
|
|
304
|
-
* @example <syn-combobox delimiter="~" value="option-1~option-2"></syn-combobox>
|
|
305
|
-
*/
|
|
306
|
-
@property() delimiter = ' ';
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* The maximum number of selected options to show when `multiple` is true. After the maximum, "+n" will be shown to
|
|
310
|
-
* indicate the number of additional items that are selected. Set to 0 to remove the limit.
|
|
311
|
-
*/
|
|
312
|
-
@property({ attribute: 'max-options-visible', type: Number }) maxOptionsVisible = 3;
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* A function that customizes the tags to be rendered when `multiple` is true. The first argument is the option, the second
|
|
316
|
-
* is the current tag's index. The function should return either a Lit TemplateResult or a string containing trusted HTML of the symbol to render at
|
|
317
|
-
* the specified value.
|
|
318
|
-
*/
|
|
319
|
-
@property() getTag: (option: SynOption, index: number) => TemplateResult | string | HTMLElement = option => html`
|
|
320
|
-
<syn-tag
|
|
321
|
-
part="tag"
|
|
322
|
-
exportparts="
|
|
323
|
-
base:tag__base,
|
|
324
|
-
content:tag__content,
|
|
325
|
-
remove-button:tag__remove-button,
|
|
326
|
-
remove-button__base:tag__remove-button__base
|
|
327
|
-
"
|
|
328
|
-
size=${this.size}
|
|
329
|
-
removable
|
|
330
|
-
@syn-remove=${(event: SynRemoveEvent) => this.handleTagRemove(event, option)}
|
|
331
|
-
>
|
|
332
|
-
${option.getTextLabel()}
|
|
333
|
-
</syn-tag>
|
|
334
|
-
`;
|
|
335
|
-
|
|
336
|
-
/** Gets the validity state object */
|
|
337
|
-
get validity() {
|
|
338
|
-
return this.valueInput.validity;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
/** Gets the validation message */
|
|
342
|
-
get validationMessage() {
|
|
343
|
-
return this.valueInput.validationMessage;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
private calculateTagMaxWidth = (entries: ResizeObserverEntry[]) => {
|
|
347
|
-
const input = entries.at(0);
|
|
348
|
-
if (!input || !this.tagContainer) return;
|
|
349
|
-
|
|
350
|
-
const inputWidth = input.contentRect.width;
|
|
351
|
-
const tagsWidth = this.tagContainer.getBoundingClientRect().width;
|
|
352
|
-
|
|
353
|
-
// The min-width of the input is 48px, this should stay available for the input
|
|
354
|
-
// The min-width of the tags is 85px, so we should not go below that
|
|
355
|
-
const availableTagSpace = Math.max(85, tagsWidth + inputWidth - 48);
|
|
356
|
-
|
|
357
|
-
this.tagContainer.style.setProperty('--syn-select-tag-max-width', `${availableTagSpace}px`);
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
private enableResizeObserver() {
|
|
361
|
-
if (!this.multiple) return;
|
|
362
|
-
|
|
363
|
-
if (!this.resizeObserver) {
|
|
364
|
-
this.resizeObserver = new ResizeObserver(this.calculateTagMaxWidth);
|
|
365
|
-
}
|
|
366
|
-
// We use the `displayInput`, as the observer is fired for the initial state if someone is selecting an option
|
|
367
|
-
// and when the combobox size changes e.g. via window resize
|
|
368
|
-
this.resizeObserver.observe(this.displayInput);
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
connectedCallback() {
|
|
372
|
-
super.connectedCallback();
|
|
373
|
-
|
|
374
|
-
this.mutationObserver = new MutationObserver((entries) => {
|
|
375
|
-
// Only process attribute mutations on SynOption instances for the 'value' attribute. This is needed for changing of "delimiter"
|
|
376
|
-
const hasRelevantValueChange = entries.some(entry => {
|
|
377
|
-
// Check if the target is a SynOption instance
|
|
378
|
-
if (!(entry.target instanceof SynOption)) {
|
|
379
|
-
return false;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
// Check if it's an attribute mutation for the 'value' attribute
|
|
383
|
-
if (entry.type !== 'attributes' || entry.attributeName !== 'value') {
|
|
384
|
-
return false;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
// Check if the value actually changed and is not nullish
|
|
388
|
-
const currentValue = (entry.target as HTMLElement).getAttribute('value');
|
|
389
|
-
return entry.oldValue !== currentValue && !!currentValue;
|
|
390
|
-
});
|
|
391
|
-
|
|
392
|
-
if (hasRelevantValueChange) {
|
|
393
|
-
this.handleSlotContentChange();
|
|
394
|
-
}
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
this.mutationObserver.observe(this, {
|
|
398
|
-
attributeFilter: ['value'],
|
|
399
|
-
attributeOldValue: true,
|
|
400
|
-
attributes: true,
|
|
401
|
-
childList: true,
|
|
402
|
-
subtree: true,
|
|
403
|
-
});
|
|
404
|
-
|
|
405
|
-
setTimeout(() => {
|
|
406
|
-
// #813 needed to catch initial value via property binding
|
|
407
|
-
this.handleSlotContentChange();
|
|
408
|
-
});
|
|
409
|
-
|
|
410
|
-
// Because this is a form control, it shouldn't be opened initially
|
|
411
|
-
this.open = false;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
disconnectedCallback() {
|
|
415
|
-
super.disconnectedCallback();
|
|
416
|
-
|
|
417
|
-
this.resizeObserver?.disconnect();
|
|
418
|
-
this.mutationObserver?.disconnect();
|
|
419
|
-
this.removeOpenListeners();
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
firstUpdated() {
|
|
423
|
-
this.isInitialized = true;
|
|
424
|
-
this.formControlController.updateValidity();
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
protected updated(changedProperties: PropertyValues<this>) {
|
|
428
|
-
super.updated(changedProperties);
|
|
429
|
-
if (changedProperties.has('multiple')) {
|
|
430
|
-
if (!this.multiple) {
|
|
431
|
-
this.resizeObserver?.disconnect();
|
|
432
|
-
} else {
|
|
433
|
-
this.enableResizeObserver();
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
// eslint-disable-next-line complexity
|
|
439
|
-
protected override willUpdate(changedProperties: PropertyValues) {
|
|
440
|
-
super.willUpdate(changedProperties);
|
|
441
|
-
|
|
442
|
-
// Check for defaultValue if it is not undefined, null, empty string or empty array
|
|
443
|
-
const isDefaultValueEmpty = this.defaultValue == null
|
|
444
|
-
|| this.defaultValue === ''
|
|
445
|
-
|| (Array.isArray(this.defaultValue) && this.defaultValue.length === 0);
|
|
446
|
-
|
|
447
|
-
if (changedProperties.has('value') && isDefaultValueEmpty && this.value && !this.isUserInput) {
|
|
448
|
-
// If the value was set initially via property binding instead of attribute, we need to set the defaultValue manually
|
|
449
|
-
// to be able to reset forms and the dynamic loading of options are working correctly.
|
|
450
|
-
if (this.multiple && Array.isArray(this.value)) {
|
|
451
|
-
this.defaultValue = this.value.join(this.delimiter);
|
|
452
|
-
} else {
|
|
453
|
-
this.defaultValue = this.value;
|
|
454
|
-
}
|
|
455
|
-
this.valueHasChanged = false;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
// This is needed, as the result otherwise is different on the attribute order of "multiple", "delimiter" and "value".
|
|
459
|
-
if (!this.isInitialized && changedProperties.has('value') && this.value !== undefined && changedProperties.has('multiple') && this.multiple) {
|
|
460
|
-
if (!Array.isArray(this.defaultValue)) {
|
|
461
|
-
const cachedValueHasChanged = this.valueHasChanged;
|
|
462
|
-
this.value = typeof this.defaultValue === 'string' ? this.defaultValue.split(this.delimiter) : [this.defaultValue].filter(isAllowedValue);
|
|
463
|
-
|
|
464
|
-
// Set it back to false since this isn't an interaction.
|
|
465
|
-
this.valueHasChanged = cachedValueHasChanged;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
attributeChangedCallback(name: string, oldVal: string | null, newVal: string | null) {
|
|
471
|
-
super.attributeChangedCallback(name, oldVal, newVal);
|
|
472
|
-
|
|
473
|
-
/** This is a backwards compatibility call. In a new major version we should make a clean separation between "value" the attribute mapping to "defaultValue" property and "value" the property not reflecting. */
|
|
474
|
-
if (name === 'value') {
|
|
475
|
-
const cachedValueHasChanged = this.valueHasChanged;
|
|
476
|
-
this.value = this.defaultValue;
|
|
477
|
-
|
|
478
|
-
// Set it back to false since this isn't an interaction.
|
|
479
|
-
this.valueHasChanged = cachedValueHasChanged;
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
protected get tags() {
|
|
484
|
-
return this.selectedOptions.map((option, index) => {
|
|
485
|
-
if (index < this.maxOptionsVisible || this.maxOptionsVisible <= 0) {
|
|
486
|
-
const tag = this.getTag(option, index);
|
|
487
|
-
// Wrap so we can handle the remove
|
|
488
|
-
return html`<div @syn-remove=${(e: SynRemoveEvent) => this.handleTagRemove(e, option)}>
|
|
489
|
-
${typeof tag === 'string' ? unsafeHTML(tag) : tag}
|
|
490
|
-
</div>`;
|
|
491
|
-
} if (index === this.maxOptionsVisible) {
|
|
492
|
-
// Hit tag limit
|
|
493
|
-
return html`<syn-tag size=${this.size}>+${this.selectedOptions.length - index}</syn-tag>`;
|
|
494
|
-
}
|
|
495
|
-
return html``;
|
|
496
|
-
});
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
private addOpenListeners() {
|
|
500
|
-
//
|
|
501
|
-
// Listen on the root node instead of the document in case the elements are inside a shadow root
|
|
502
|
-
//
|
|
503
|
-
// https://github.com/synergy-design-system/synergy/issues/1763
|
|
504
|
-
//
|
|
505
|
-
document.addEventListener('focusin', this.handleDocumentFocusIn);
|
|
506
|
-
document.addEventListener('mousedown', this.handleDocumentMouseDown);
|
|
507
|
-
|
|
508
|
-
// If the component is rendered in a shadow root,
|
|
509
|
-
// we need to attach the focusin listener there too
|
|
510
|
-
if (this.getRootNode() !== document) {
|
|
511
|
-
this.getRootNode().addEventListener('focusin', this.handleDocumentFocusIn);
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
if ('CloseWatcher' in window) {
|
|
515
|
-
this.closeWatcher?.destroy();
|
|
516
|
-
this.closeWatcher = new CloseWatcher();
|
|
517
|
-
this.closeWatcher.onclose = () => {
|
|
518
|
-
if (this.open) {
|
|
519
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
520
|
-
this.hide();
|
|
521
|
-
this.displayInput.focus({ preventScroll: true });
|
|
522
|
-
}
|
|
523
|
-
};
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
private removeOpenListeners() {
|
|
528
|
-
document.removeEventListener('focusin', this.handleDocumentFocusIn);
|
|
529
|
-
document.removeEventListener('mousedown', this.handleDocumentMouseDown);
|
|
530
|
-
|
|
531
|
-
if (this.getRootNode() !== document) {
|
|
532
|
-
this.getRootNode().removeEventListener('focusin', this.handleDocumentFocusIn);
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
this.closeWatcher?.destroy();
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
private handleFocus() {
|
|
539
|
-
this.hasFocus = true;
|
|
540
|
-
this.emit('syn-focus');
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
private handleBlur() {
|
|
544
|
-
this.hasFocus = false;
|
|
545
|
-
this.emit('syn-blur');
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
private handleDocumentFocusIn = (event: KeyboardEvent) => {
|
|
549
|
-
// Close when focusing out of the combobox
|
|
550
|
-
const path = event.composedPath();
|
|
551
|
-
if (this && !path.includes(this)) {
|
|
552
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
553
|
-
this.hide();
|
|
554
|
-
}
|
|
555
|
-
};
|
|
556
|
-
|
|
557
|
-
/* eslint-disable @typescript-eslint/no-floating-promises */
|
|
558
|
-
// eslint-disable-next-line complexity
|
|
559
|
-
private handleDocumentKeyDown = (event: KeyboardEvent) => {
|
|
560
|
-
const target = event.target as HTMLElement;
|
|
561
|
-
const isClearButton = target.closest('.combobox__clear') !== null;
|
|
562
|
-
|
|
563
|
-
if (isClearButton) {
|
|
564
|
-
return;
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
// Close when pressing escape and open / clear input if not open
|
|
568
|
-
if (event.key === 'Escape') {
|
|
569
|
-
if (this.open && !this.closeWatcher) {
|
|
570
|
-
event.preventDefault();
|
|
571
|
-
event.stopPropagation();
|
|
572
|
-
this.hide();
|
|
573
|
-
this.displayInput.focus({ preventScroll: true });
|
|
574
|
-
} else if (!this.open) {
|
|
575
|
-
if (this.multiple) {
|
|
576
|
-
// In multiple mode, only clear the input field but preserve selected options
|
|
577
|
-
this.clearInputField();
|
|
578
|
-
} else {
|
|
579
|
-
// In single mode, clear everything as before
|
|
580
|
-
this.clearCombobox();
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
// Handle enter - either select option or submit form
|
|
586
|
-
if (event.key === 'Enter') {
|
|
587
|
-
const currentOption = this.getCurrentOption();
|
|
588
|
-
|
|
589
|
-
// Pressing enter when focused on an input should submit the form like a native input, but
|
|
590
|
-
// we wait a tick before submitting to allow users to cancel the keydown event if they need to
|
|
591
|
-
const hasModifier = event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;
|
|
592
|
-
if (!this.open && !hasModifier) {
|
|
593
|
-
setTimeout(() => {
|
|
594
|
-
if (!event.defaultPrevented) {
|
|
595
|
-
this.formControlController.submit();
|
|
596
|
-
}
|
|
597
|
-
});
|
|
598
|
-
return;
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
if (!this.open || (currentOption && currentOption.disabled)) {
|
|
602
|
-
return;
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
// Update the value based on the current selection and close it
|
|
606
|
-
if (currentOption) {
|
|
607
|
-
this.isUserInput = true;
|
|
608
|
-
this.valueHasChanged = true;
|
|
609
|
-
const oldValue = this.lastOptions ? getValuesFromOptions(this.lastOptions) : [];
|
|
610
|
-
|
|
611
|
-
if (this.multiple) {
|
|
612
|
-
this.toggleOptionSelection(currentOption);
|
|
613
|
-
} else {
|
|
614
|
-
this.setSelectedOptions(currentOption);
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
this.selectionChanged();
|
|
618
|
-
|
|
619
|
-
const value = Array.isArray(this.value) ? this.value : [this.value];
|
|
620
|
-
|
|
621
|
-
// Make reset in forms work correctly via isUserInput flag
|
|
622
|
-
this.updateComplete.then(() => {
|
|
623
|
-
this.isUserInput = false;
|
|
624
|
-
});
|
|
625
|
-
|
|
626
|
-
if (!compareValues(oldValue, value)) {
|
|
627
|
-
// Emit after updating
|
|
628
|
-
this.updateComplete.then(() => {
|
|
629
|
-
this.emit('syn-input');
|
|
630
|
-
this.emit('syn-change');
|
|
631
|
-
});
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
if (!this.multiple) {
|
|
636
|
-
this.hide();
|
|
637
|
-
}
|
|
638
|
-
this.displayInput.focus({ preventScroll: true });
|
|
639
|
-
return;
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
// Navigate options
|
|
643
|
-
if (['ArrowUp', 'ArrowDown'].includes(event.key)) {
|
|
644
|
-
// Prevent scrolling
|
|
645
|
-
event.preventDefault();
|
|
646
|
-
event.stopPropagation();
|
|
647
|
-
// Open it
|
|
648
|
-
if (!this.open) {
|
|
649
|
-
this.show();
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
this.selectNextOption(event.key === 'ArrowDown');
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
// Move cursor
|
|
656
|
-
if (['Home', 'End'].includes(event.key)) {
|
|
657
|
-
// Prevent scrolling
|
|
658
|
-
event.preventDefault();
|
|
659
|
-
event.stopPropagation();
|
|
660
|
-
if (event.key === 'Home') {
|
|
661
|
-
this.displayInput.setSelectionRange(0, 0);
|
|
662
|
-
} else if (event.key === 'End') {
|
|
663
|
-
this.displayInput.setSelectionRange(
|
|
664
|
-
this.displayLabel.length,
|
|
665
|
-
this.displayLabel.length,
|
|
666
|
-
);
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
};
|
|
670
|
-
/* eslint-enable @typescript-eslint/no-floating-promises */
|
|
671
|
-
|
|
672
|
-
private handleDocumentMouseDown = (event: MouseEvent) => {
|
|
673
|
-
// Close when clicking outside of the combobox
|
|
674
|
-
const path = event.composedPath();
|
|
675
|
-
if (this && !path.includes(this)) {
|
|
676
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
677
|
-
this.hide();
|
|
678
|
-
}
|
|
679
|
-
};
|
|
680
|
-
|
|
681
|
-
private handleFormControlClick() {
|
|
682
|
-
if (this.readonly) {
|
|
683
|
-
this.displayInput.focus();
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
private handleLabelClick() {
|
|
688
|
-
this.displayInput.focus();
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
private handleTagRemove(event: SynRemoveEvent, option: SynOption) {
|
|
692
|
-
event.stopPropagation();
|
|
693
|
-
|
|
694
|
-
this.valueHasChanged = true;
|
|
695
|
-
|
|
696
|
-
if (!this.disabled && !this.readonly) {
|
|
697
|
-
this.toggleOptionSelection(option, false);
|
|
698
|
-
this.selectionChanged();
|
|
699
|
-
|
|
700
|
-
// Emit after updating
|
|
701
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
702
|
-
this.updateComplete.then(() => {
|
|
703
|
-
this.emit('syn-input');
|
|
704
|
-
this.emit('syn-change');
|
|
705
|
-
});
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
private handleComboboxMouseDown(event: MouseEvent) {
|
|
710
|
-
const path = event.composedPath();
|
|
711
|
-
const isIconButton = path.some(el => el instanceof Element && el.tagName.toLowerCase() === 'syn-icon-button');
|
|
712
|
-
|
|
713
|
-
// Ignore disabled controls and clicks on tags (remove buttons)
|
|
714
|
-
if (this.disabled || this.readonly || isIconButton) {
|
|
715
|
-
return;
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
const toggleListboxOpen = () => (this.open ? this.hide() : this.show());
|
|
719
|
-
event.preventDefault();
|
|
720
|
-
|
|
721
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
722
|
-
toggleListboxOpen().then(() => {
|
|
723
|
-
setTimeout(() => this.displayInput.focus({ preventScroll: true }));
|
|
724
|
-
});
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
private handleComboboxKeyDown(event: KeyboardEvent) {
|
|
728
|
-
if (event.key === 'Tab') {
|
|
729
|
-
return;
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
this.handleDocumentKeyDown(event);
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
private handleClearClick(event: MouseEvent) {
|
|
736
|
-
event.stopPropagation();
|
|
737
|
-
this.clearCombobox();
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
private clearInputField() {
|
|
741
|
-
if (this.displayLabel !== '') {
|
|
742
|
-
const cachedValueHasChanged = this.valueHasChanged;
|
|
743
|
-
// remove the text from the input field only by reset value to selected options
|
|
744
|
-
this.value = getValuesFromOptions(this.selectedOptions);
|
|
745
|
-
this.valueHasChanged = cachedValueHasChanged;
|
|
746
|
-
this.displayInput.focus({ preventScroll: true });
|
|
747
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
748
|
-
this.updateComplete.then(() => {
|
|
749
|
-
this.emit('syn-input');
|
|
750
|
-
});
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
private clearCombobox() {
|
|
755
|
-
this.valueHasChanged = true;
|
|
756
|
-
|
|
757
|
-
if (this.value !== '') {
|
|
758
|
-
this.value = '';
|
|
759
|
-
this.displayLabel = '';
|
|
760
|
-
this.lastOptions = [];
|
|
761
|
-
this.setSelectedOptions([]);
|
|
762
|
-
this.selectionChanged();
|
|
763
|
-
this.displayInput.focus({ preventScroll: true });
|
|
764
|
-
|
|
765
|
-
// Emit after update
|
|
766
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
767
|
-
this.updateComplete.then(() => {
|
|
768
|
-
this.emit('syn-clear');
|
|
769
|
-
this.emit('syn-input');
|
|
770
|
-
this.emit('syn-change');
|
|
771
|
-
});
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
// eslint-disable-next-line class-methods-use-this
|
|
776
|
-
private preventLoosingFocus(event: MouseEvent) {
|
|
777
|
-
// Don't lose focus of the input or propagate events
|
|
778
|
-
event.stopPropagation();
|
|
779
|
-
event.preventDefault();
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
/* eslint-disable @typescript-eslint/no-floating-promises */
|
|
783
|
-
private handleOptionClick(event: MouseEvent) {
|
|
784
|
-
const target = event.target as HTMLElement;
|
|
785
|
-
const option = target.closest('syn-option');
|
|
786
|
-
const oldValue = this.lastOptions ? getValuesFromOptions(this.lastOptions) : [];
|
|
787
|
-
if (option && !option.disabled) {
|
|
788
|
-
this.isUserInput = true;
|
|
789
|
-
|
|
790
|
-
this.valueHasChanged = true;
|
|
791
|
-
if (this.multiple) {
|
|
792
|
-
this.toggleOptionSelection(option);
|
|
793
|
-
} else {
|
|
794
|
-
this.setSelectedOptions(option);
|
|
795
|
-
}
|
|
796
|
-
this.selectionChanged();
|
|
797
|
-
|
|
798
|
-
// Set focus after updating so the value is announced by screen readers
|
|
799
|
-
// and make the reset in forms work correctly via isUserInput flag
|
|
800
|
-
this.updateComplete.then(() => {
|
|
801
|
-
this.displayInput.focus({ preventScroll: true });
|
|
802
|
-
this.isUserInput = false;
|
|
803
|
-
});
|
|
804
|
-
|
|
805
|
-
const value = Array.isArray(this.value) ? this.value : [this.value];
|
|
806
|
-
|
|
807
|
-
if (!compareValues(oldValue, value)) {
|
|
808
|
-
// Emit after updating
|
|
809
|
-
this.updateComplete.then(() => {
|
|
810
|
-
this.emit('syn-input');
|
|
811
|
-
this.emit('syn-change');
|
|
812
|
-
});
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
if (!this.multiple) {
|
|
816
|
-
this.hide();
|
|
817
|
-
this.displayInput.focus({ preventScroll: true });
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
/* eslint-enable @typescript-eslint/no-floating-promises */
|
|
822
|
-
|
|
823
|
-
/**
|
|
824
|
-
* Selects the following or previous option.
|
|
825
|
-
*
|
|
826
|
-
* @param isNext - A boolean indicating whether to select the following option (true)
|
|
827
|
-
* or the previous option (false).
|
|
828
|
-
*/
|
|
829
|
-
private selectNextOption(isNext: boolean) {
|
|
830
|
-
const filteredOptions = this.getAllFilteredOptions();
|
|
831
|
-
|
|
832
|
-
if (filteredOptions.length === 0) {
|
|
833
|
-
return;
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
const currentOption = this.getCurrentOption();
|
|
837
|
-
const currentIndex = filteredOptions.indexOf(currentOption!);
|
|
838
|
-
let newIndex = Math.max(0, currentIndex);
|
|
839
|
-
|
|
840
|
-
if (isNext) {
|
|
841
|
-
const nextIndex = currentIndex + 1;
|
|
842
|
-
newIndex = (nextIndex > filteredOptions.length - 1) ? 0 : nextIndex;
|
|
843
|
-
} else {
|
|
844
|
-
const previousIndex = currentIndex - 1;
|
|
845
|
-
newIndex = previousIndex < 0 ? filteredOptions.length - 1 : previousIndex;
|
|
846
|
-
}
|
|
847
|
-
this.setCurrentOption(filteredOptions[newIndex]);
|
|
848
|
-
scrollIntoView(this.getCurrentOption()!, this.listbox, 'vertical', 'auto');
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
// Toggles an option's selected state
|
|
852
|
-
// eslint-disable-next-line class-methods-use-this
|
|
853
|
-
private toggleOptionSelection(option: SynOption, force?: boolean) {
|
|
854
|
-
if (force === true || force === false) {
|
|
855
|
-
option.selected = force;
|
|
856
|
-
} else {
|
|
857
|
-
option.selected = !option.selected;
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
// This is needed so the highlight option renderer is working correctly for `restricted` and `multiple` comboboxes
|
|
861
|
-
const cachedOption = this.cachedOptions.find(opt => opt.id === option.id);
|
|
862
|
-
if (cachedOption) {
|
|
863
|
-
cachedOption.selected = option.selected;
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
// Sets the selected option(s)
|
|
868
|
-
private setSelectedOptions(option: SynOption | SynOption[]) {
|
|
869
|
-
const newSelectedOptions = Array.isArray(option) ? option : [option];
|
|
870
|
-
// In single-select mode, if multiple options are provided, keep only the first one to select
|
|
871
|
-
if (!this.multiple && newSelectedOptions.length > 1) {
|
|
872
|
-
newSelectedOptions.splice(1);
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
const slottedOptions = this.getSlottedOptions();
|
|
876
|
-
slottedOptions.forEach((opt) => {
|
|
877
|
-
opt.selected = newSelectedOptions.some(
|
|
878
|
-
selectedOpt => selectedOpt.id === opt.id,
|
|
879
|
-
);
|
|
880
|
-
});
|
|
881
|
-
// This is needed so the highlight option renderer is working correctly for `restricted` and `multiple` comboboxes
|
|
882
|
-
this.cachedOptions.forEach((opt) => {
|
|
883
|
-
opt.selected = newSelectedOptions.some(
|
|
884
|
-
selectedOpt => selectedOpt.id === opt.id,
|
|
885
|
-
);
|
|
886
|
-
});
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
private getAllFilteredOptions() {
|
|
890
|
-
return this.getSlottedOptions().filter(option => !option.hidden);
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
private getCurrentOption() {
|
|
894
|
-
return this.getAllFilteredOptions().find(option => option.current);
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
// Sets the current option, which is the option the user is currently interacting with
|
|
898
|
-
// (e.g. via keyboard). Only one option may be "current" at a time.
|
|
899
|
-
private setCurrentOption(option: SynOption | null) {
|
|
900
|
-
const allOptions = this.getAllFilteredOptions();
|
|
901
|
-
|
|
902
|
-
// Clear selection
|
|
903
|
-
this.displayInput.removeAttribute('aria-activedescendant');
|
|
904
|
-
|
|
905
|
-
allOptions.forEach(el => {
|
|
906
|
-
// eslint-disable-next-line no-param-reassign
|
|
907
|
-
el.current = false;
|
|
908
|
-
el.setAttribute('aria-selected', 'false');
|
|
909
|
-
});
|
|
910
|
-
|
|
911
|
-
// Select the target option
|
|
912
|
-
if (option) {
|
|
913
|
-
// eslint-disable-next-line no-param-reassign
|
|
914
|
-
option.current = true;
|
|
915
|
-
option.setAttribute('aria-selected', 'true');
|
|
916
|
-
this.displayInput.setAttribute('aria-activedescendant', option.id);
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
/**
|
|
921
|
-
* Updates the component state after selection changes.
|
|
922
|
-
*
|
|
923
|
-
* This method synchronizes:
|
|
924
|
-
* 1. The selectedOptions cache with currently selected options
|
|
925
|
-
* 2. The component's value property (string or array)
|
|
926
|
-
* 3. The display label shown in the input
|
|
927
|
-
* 4. Form validation state
|
|
928
|
-
*
|
|
929
|
-
* **Validation Logic:**
|
|
930
|
-
* - In restricted mode, invalid values trigger a reset to last valid state
|
|
931
|
-
* - Multiple mode requires all values to correspond to existing options
|
|
932
|
-
* - Single mode allows free text input when not restricted
|
|
933
|
-
*/
|
|
934
|
-
// eslint-disable-next-line complexity
|
|
935
|
-
private selectionChanged() {
|
|
936
|
-
const options = this.getSlottedOptions();
|
|
937
|
-
this.selectedOptions = options.filter(opt => opt.selected);
|
|
938
|
-
|
|
939
|
-
// This is needed if there are no valid options and therefore just the typed in value should be displayed
|
|
940
|
-
if (this.selectedOptions.length === 0) {
|
|
941
|
-
this.displayLabel = Array.isArray(this.value) ? this.value.join(', ') : String(this.value);
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
let optionValue;
|
|
945
|
-
|
|
946
|
-
// Keep a reference to the previous `valueHasChanged`. Changes made here don't count has changing the value.
|
|
947
|
-
const cachedValueHasChanged = this.valueHasChanged;
|
|
948
|
-
|
|
949
|
-
if (this.multiple) {
|
|
950
|
-
this.value = this.selectedOptions.map(opt => getValueFromOption(opt));
|
|
951
|
-
if (this.value.length === 0 && this.selectedOptions.length !== 0) {
|
|
952
|
-
this.valueHasChanged = cachedValueHasChanged;
|
|
953
|
-
this.resetToLastValidValue();
|
|
954
|
-
return;
|
|
955
|
-
}
|
|
956
|
-
} else {
|
|
957
|
-
if (this.selectedOptions.length !== 0) {
|
|
958
|
-
// This is only for non multiple
|
|
959
|
-
optionValue = getValueFromOption(this.selectedOptions[0]);
|
|
960
|
-
} else if (this.restricted && !this.isValidValue(this.displayLabel) && this.displayLabel !== '' && !this.isUserInput) {
|
|
961
|
-
// if an invalid value was set via property binding for `restricted`comboboxes,
|
|
962
|
-
// reset to last valid value
|
|
963
|
-
this.resetToLastValidValue();
|
|
964
|
-
this.valueHasChanged = cachedValueHasChanged;
|
|
965
|
-
return;
|
|
966
|
-
}
|
|
967
|
-
this.value = optionValue ?? this.displayLabel;
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
this.valueHasChanged = cachedValueHasChanged;
|
|
971
|
-
|
|
972
|
-
// Store the new last selected options
|
|
973
|
-
this.lastOptions = [...this.selectedOptions];
|
|
974
|
-
|
|
975
|
-
// Update validity and display label
|
|
976
|
-
// Make sure to still show the display label if we are in multiple and readonly mode
|
|
977
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
978
|
-
this.updateComplete.then(() => {
|
|
979
|
-
let newLabel = this.displayLabel;
|
|
980
|
-
|
|
981
|
-
if (this.multiple && this.readonly) {
|
|
982
|
-
// For multiple and readonly, we want to show the labels of the selected options, otherwise we would just show the value which is not useful in readonly mode and multiple mode
|
|
983
|
-
newLabel = this.selectedOptions.map(opt => opt.getTextLabel()).join(', ');
|
|
984
|
-
} else if (this.multiple && !this.readonly) {
|
|
985
|
-
// For multiple and not readonly, we want to show the typed in value instead of the selected options, otherwise the user would not see what they typed in if they select an option which is not ideal. Showing the selected options is also not ideal in this case, because it would just be a long list of options which is not useful. So we show the typed in value which is more useful in this case. If there are no options selected, we want to show an empty string instead of the typed in value, because the typed in value is not valid in this case and showing it would be confusing.
|
|
986
|
-
newLabel = '';
|
|
987
|
-
} else {
|
|
988
|
-
// For single, we want to show the label of the selected option, if there is one, otherwise we show the typed in value which is already in displayLabel. This is also needed for `restricted` comboboxes, because if the user types in an invalid value, we want to show that value instead of the label of the selected option which would be confusing. If there are no options selected and no typed in value, we want to show an empty string instead of the label of the selected option, because showing the label of the selected option would be confusing in this case.
|
|
989
|
-
newLabel = this.selectedOptions[0]?.getTextLabel() ?? this.displayLabel;
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
this.displayLabel = newLabel;
|
|
993
|
-
this.formControlController.updateValidity();
|
|
994
|
-
});
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
private handleInvalid(event: Event) {
|
|
998
|
-
this.formControlController.setValidity(false);
|
|
999
|
-
this.formControlController.emitInvalidEvent(event);
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
@watch(['filter', 'getOption'], { waitUntilFirstUpdate: true })
|
|
1003
|
-
handlePropertiesChange() {
|
|
1004
|
-
this.createComboboxOptionsFromQuery(this.displayLabel);
|
|
1005
|
-
if (this.open) {
|
|
1006
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
1007
|
-
this.updateComplete.then(() => {
|
|
1008
|
-
this.open = this.multiple || this.restricted || this.numberFilteredOptions > 0;
|
|
1009
|
-
});
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
@watch('displayLabel', { waitUntilFirstUpdate: true })
|
|
1014
|
-
handleDisplayInputValueChange() {
|
|
1015
|
-
this.createComboboxOptionsFromQuery(this.displayLabel);
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
@watch(['disabled', 'readonly'], { waitUntilFirstUpdate: true })
|
|
1019
|
-
handleDisabledChange() {
|
|
1020
|
-
// Disabled form controls are always valid
|
|
1021
|
-
if (this.disabled) {
|
|
1022
|
-
this.formControlController.setValidity(this.disabled);
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
// Close the listbox when the control is disabled or readonly
|
|
1026
|
-
if (this.disabled || this.readonly) {
|
|
1027
|
-
this.open = false;
|
|
1028
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
1029
|
-
this.handleOpenChange();
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
// Recalculate display label when readonly changes
|
|
1033
|
-
this.selectionChanged();
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
|
-
@watch('delimiter')
|
|
1037
|
-
handleDelimiterChange() {
|
|
1038
|
-
this.getSlottedOptions().forEach(option => {
|
|
1039
|
-
option.delimiter = this.delimiter;
|
|
1040
|
-
});
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
@watch(['defaultValue', 'value', 'delimiter', 'multiple', 'restricted'], { waitUntilFirstUpdate: true })
|
|
1044
|
-
handleValueChange() {
|
|
1045
|
-
if (!this.valueHasChanged) {
|
|
1046
|
-
const cachedValueHasChanged = this.valueHasChanged;
|
|
1047
|
-
this.value = this.defaultValue;
|
|
1048
|
-
|
|
1049
|
-
// Set it back to false since this isn't an interaction.
|
|
1050
|
-
this.valueHasChanged = cachedValueHasChanged;
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
this.updateSelectedOptionFromValue();
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
|
-
@watch('open', { waitUntilFirstUpdate: true })
|
|
1057
|
-
async handleOpenChange() {
|
|
1058
|
-
if (this.open && (!this.disabled && !this.readonly)) {
|
|
1059
|
-
if (this.numberFilteredOptions === 0 && !this.restricted && !this.multiple) {
|
|
1060
|
-
// Don't open the listbox if there are no options and it is not restricted or multiple
|
|
1061
|
-
this.open = false;
|
|
1062
|
-
this.emit('syn-error');
|
|
1063
|
-
return;
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
// Show
|
|
1067
|
-
this.emit('syn-show');
|
|
1068
|
-
this.addOpenListeners();
|
|
1069
|
-
|
|
1070
|
-
await stopAnimations(this);
|
|
1071
|
-
this.listbox.hidden = false;
|
|
1072
|
-
this.popup.active = true;
|
|
1073
|
-
|
|
1074
|
-
const { keyframes, options } = getAnimation(this, 'combobox.show', { dir: this.localize.dir() });
|
|
1075
|
-
await animateTo(this.popup.popup, keyframes, options);
|
|
1076
|
-
|
|
1077
|
-
this.emit('syn-after-show');
|
|
1078
|
-
return;
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
this.setCurrentOption(null);
|
|
1082
|
-
this.displayInput.removeAttribute('aria-activedescendant');
|
|
1083
|
-
// Hide
|
|
1084
|
-
this.emit('syn-hide');
|
|
1085
|
-
this.removeOpenListeners();
|
|
1086
|
-
|
|
1087
|
-
await stopAnimations(this);
|
|
1088
|
-
const { keyframes, options } = getAnimation(this, 'combobox.hide', { dir: this.localize.dir() });
|
|
1089
|
-
await animateTo(this.popup.popup, keyframes, options);
|
|
1090
|
-
this.listbox.hidden = true;
|
|
1091
|
-
this.popup.active = false;
|
|
1092
|
-
|
|
1093
|
-
this.emit('syn-after-hide');
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
/**
|
|
1097
|
-
* Shows the listbox. If it is not possible to open the listbox, because there are no
|
|
1098
|
-
* appropriate filtered options, a syn-error is emitted and the listbox stays closed.
|
|
1099
|
-
*/
|
|
1100
|
-
async show() {
|
|
1101
|
-
if (this.open || this.disabled || this.readonly) {
|
|
1102
|
-
this.open = false;
|
|
1103
|
-
return undefined;
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
this.open = true;
|
|
1107
|
-
return Promise.race([waitForEvent(this, 'syn-after-show'), waitForEvent(this, 'syn-error')]);
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
/** Hides the listbox. */
|
|
1111
|
-
async hide() {
|
|
1112
|
-
if (!this.open || this.disabled || this.readonly) {
|
|
1113
|
-
this.open = false;
|
|
1114
|
-
return undefined;
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
this.open = false;
|
|
1118
|
-
return waitForEvent(this, 'syn-after-hide');
|
|
1119
|
-
}
|
|
1120
|
-
|
|
1121
|
-
/**
|
|
1122
|
-
* Checks for validity but does not show a validation message.
|
|
1123
|
-
* Returns `true` when valid and `false` when invalid.
|
|
1124
|
-
*/
|
|
1125
|
-
checkValidity() {
|
|
1126
|
-
return this.valueInput.checkValidity();
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
/** Gets the associated form, if one exists. */
|
|
1130
|
-
getForm(): HTMLFormElement | null {
|
|
1131
|
-
return this.formControlController.getForm();
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
/** Checks for validity and shows the browser's validation message if the control is invalid. */
|
|
1135
|
-
reportValidity() {
|
|
1136
|
-
return this.valueInput.reportValidity();
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
|
-
/** Sets a custom validation message. Pass an empty string to restore validity. */
|
|
1140
|
-
setCustomValidity(message: string) {
|
|
1141
|
-
this.valueInput.setCustomValidity(message);
|
|
1142
|
-
this.formControlController.updateValidity();
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
/** Sets focus on the control. */
|
|
1146
|
-
focus(options?: FocusOptions) {
|
|
1147
|
-
this.displayInput.focus(options);
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
/** Removes focus from the control. */
|
|
1151
|
-
blur() {
|
|
1152
|
-
this.displayInput.blur();
|
|
1153
|
-
}
|
|
1154
|
-
|
|
1155
|
-
/**
|
|
1156
|
-
* Updates the visibility and rendering of options based on the current query string.
|
|
1157
|
-
*
|
|
1158
|
-
* This method performs several critical tasks:
|
|
1159
|
-
* 1. **Option Filtering**: Uses the `filter` function to determine which options should be visible
|
|
1160
|
-
* 2. **Custom Rendering**: Applies the `getOption` function to customize option appearance
|
|
1161
|
-
* 3. **Optgroup Management**: Shows/hides optgroups based on their visible children
|
|
1162
|
-
* 4. **Counts visible options**: Tracks the number of visible options for UI logic
|
|
1163
|
-
*
|
|
1164
|
-
* **Performance Considerations:**
|
|
1165
|
-
* - Uses cached options to avoid repeated DOM queries
|
|
1166
|
-
* - Prevents infinite loops during option updates with `isOptionRendererTriggered`
|
|
1167
|
-
*
|
|
1168
|
-
* @param queryString - The current user input to filter and highlight options with
|
|
1169
|
-
*/
|
|
1170
|
-
/* eslint-disable no-param-reassign, @typescript-eslint/no-floating-promises */
|
|
1171
|
-
private createComboboxOptionsFromQuery(queryString: string) {
|
|
1172
|
-
this.numberFilteredOptions = 0;
|
|
1173
|
-
|
|
1174
|
-
// Prevent slot change events during option updates to avoid infinite loops
|
|
1175
|
-
this.isOptionRendererTriggered = true;
|
|
1176
|
-
|
|
1177
|
-
// This is needed for angular. For some reason the handleSlotContentChange is not triggered
|
|
1178
|
-
// initially and therefore the cachedOptions are not set.
|
|
1179
|
-
if (this.cachedOptions.length === 0) {
|
|
1180
|
-
this.cacheSlottedOptionsAndOptgroups();
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
// Update each syn-option based on the query string and custom getOption renderer
|
|
1184
|
-
this.getSlottedOptions()
|
|
1185
|
-
.forEach(option => {
|
|
1186
|
-
// Use the original cached option, to do changes on it
|
|
1187
|
-
const cachedOption = this.cachedOptions.find(o => o.id === option.id) || option;
|
|
1188
|
-
|
|
1189
|
-
// Apply custom option rendering
|
|
1190
|
-
const optionResult = this.getOption(cachedOption, queryString);
|
|
1191
|
-
let updatedOption = createOptionFromDifferentTypes(optionResult);
|
|
1192
|
-
|
|
1193
|
-
// Fall back to original option if rendering fails
|
|
1194
|
-
if (!updatedOption) {
|
|
1195
|
-
updatedOption = cachedOption;
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
|
-
// Apply filtering logic to determine visibility
|
|
1199
|
-
const hideOption = !(this.filter(updatedOption, queryString) || queryString === '');
|
|
1200
|
-
updatedOption.hidden = hideOption;
|
|
1201
|
-
|
|
1202
|
-
option.replaceWith(updatedOption);
|
|
1203
|
-
|
|
1204
|
-
if (!hideOption) {
|
|
1205
|
-
this.numberFilteredOptions += 1;
|
|
1206
|
-
}
|
|
1207
|
-
});
|
|
1208
|
-
|
|
1209
|
-
// Update optgroup visibility based on their children
|
|
1210
|
-
const visibleOptgroups = this.getSlottedOptGroups().filter(optgroup => {
|
|
1211
|
-
const options = getAllOptions(Array.from(optgroup.children) as HTMLElement[]).flat();
|
|
1212
|
-
const isVisible = options.some(option => !option.hidden);
|
|
1213
|
-
optgroup.hidden = !isVisible;
|
|
1214
|
-
return isVisible;
|
|
1215
|
-
});
|
|
1216
|
-
|
|
1217
|
-
// Hide the divider of the first visible optgroup, as it can unfortunately not be hidden via css
|
|
1218
|
-
visibleOptgroups[0]?.style.setProperty('--display-divider', 'none');
|
|
1219
|
-
|
|
1220
|
-
// Reset flag after updates are complete to re-enable slot change handling
|
|
1221
|
-
setTimeout(() => {
|
|
1222
|
-
this.isOptionRendererTriggered = false;
|
|
1223
|
-
});
|
|
1224
|
-
}
|
|
1225
|
-
/* eslint-enable no-param-reassign, @typescript-eslint/no-floating-promises */
|
|
1226
|
-
|
|
1227
|
-
// eslint-disable-next-line complexity
|
|
1228
|
-
private async handleInput() {
|
|
1229
|
-
const inputValue = this.displayInput.value;
|
|
1230
|
-
this.displayLabel = inputValue;
|
|
1231
|
-
const cachedLastOption = this.lastOptions;
|
|
1232
|
-
this.isUserInput = true;
|
|
1233
|
-
|
|
1234
|
-
// Do the reset of the selected options before the value setting, as otherwise we are getting endless default slot triggering in safari
|
|
1235
|
-
if (!this.multiple) {
|
|
1236
|
-
this.selectedOptions = [];
|
|
1237
|
-
}
|
|
1238
|
-
|
|
1239
|
-
if (this.multiple) {
|
|
1240
|
-
// In multiple mode, combine selected option values with current input
|
|
1241
|
-
const validValues = getValuesFromOptions(this.selectedOptions);
|
|
1242
|
-
this.value = [...validValues, inputValue];
|
|
1243
|
-
} else {
|
|
1244
|
-
// In single mode, replace value with current input
|
|
1245
|
-
this.value = inputValue;
|
|
1246
|
-
}
|
|
1247
|
-
|
|
1248
|
-
await this.updateComplete;
|
|
1249
|
-
this.isUserInput = false;
|
|
1250
|
-
this.lastOptions = cachedLastOption;
|
|
1251
|
-
this.open = this.multiple || this.restricted || this.numberFilteredOptions > 0;
|
|
1252
|
-
|
|
1253
|
-
this.formControlController.updateValidity();
|
|
1254
|
-
this.emit('syn-input');
|
|
1255
|
-
}
|
|
1256
|
-
|
|
1257
|
-
/**
|
|
1258
|
-
* Checks if the value is available in the options list.
|
|
1259
|
-
* This is used to determine if the value is valid when the combobox is restricted.
|
|
1260
|
-
* @param value - The value to check for validity.
|
|
1261
|
-
* @returns `true` if the current value is available in the options list,
|
|
1262
|
-
* otherwise `false`.
|
|
1263
|
-
*/
|
|
1264
|
-
private isValidValue(value: string | number): boolean {
|
|
1265
|
-
const isValid = this.cachedOptions.some(
|
|
1266
|
-
option => checkValueBelongsToOption(value, option),
|
|
1267
|
-
);
|
|
1268
|
-
return isValid;
|
|
1269
|
-
}
|
|
1270
|
-
|
|
1271
|
-
private getOptionsFromValue(): SynOption[] {
|
|
1272
|
-
// Use defaultValue only if the value has not been changed by the user
|
|
1273
|
-
const value = this.valueHasChanged ? this.value : this.defaultValue;
|
|
1274
|
-
// #845: if value is undefined return empty array
|
|
1275
|
-
let convertedValue: (string | number)[];
|
|
1276
|
-
if (Array.isArray(value)) {
|
|
1277
|
-
convertedValue = value;
|
|
1278
|
-
} else if (value === undefined || value == null) {
|
|
1279
|
-
convertedValue = [];
|
|
1280
|
-
} else if (this.multiple && typeof value === 'string') {
|
|
1281
|
-
convertedValue = value.split(this.delimiter);
|
|
1282
|
-
} else {
|
|
1283
|
-
convertedValue = [value];
|
|
1284
|
-
}
|
|
1285
|
-
|
|
1286
|
-
return convertedValue
|
|
1287
|
-
.map((val) => this.cachedOptions.find(option => checkValueBelongsToOption(val, option)))
|
|
1288
|
-
.filter((opt) => opt !== undefined);
|
|
1289
|
-
}
|
|
1290
|
-
|
|
1291
|
-
/**
|
|
1292
|
-
* Resets the value to the last valid value or to an empty string.
|
|
1293
|
-
*/
|
|
1294
|
-
private resetToLastValidValue() {
|
|
1295
|
-
let label = '';
|
|
1296
|
-
let value: Array<string | number> = [];
|
|
1297
|
-
|
|
1298
|
-
if (this.lastOptions.length !== 0) {
|
|
1299
|
-
value = getValuesFromOptions(this.lastOptions);
|
|
1300
|
-
|
|
1301
|
-
if (!this.multiple) {
|
|
1302
|
-
label = this.lastOptions[0].getTextLabel();
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1305
|
-
|
|
1306
|
-
// Wait for the popup close animation to be finished before updating the value.
|
|
1307
|
-
// This is to prevent flickering of the listbox, as the value is potentially reset to empty
|
|
1308
|
-
// string and the whole options would be shown again.
|
|
1309
|
-
const popupAnimations = this.popup?.popup?.getAnimations?.() ?? [];
|
|
1310
|
-
const waitForAnimations = popupAnimations.length
|
|
1311
|
-
? Promise.all(
|
|
1312
|
-
popupAnimations.map(animation => (animation.playState === 'finished'
|
|
1313
|
-
? Promise.resolve()
|
|
1314
|
-
: new Promise<void>(resolve => { animation.addEventListener('finish', () => resolve(), { once: true }); }))),
|
|
1315
|
-
)
|
|
1316
|
-
: Promise.resolve();
|
|
1317
|
-
|
|
1318
|
-
this.hideOptions = true;
|
|
1319
|
-
|
|
1320
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
1321
|
-
waitForAnimations.then(() => {
|
|
1322
|
-
// restore options after the animation
|
|
1323
|
-
this.hideOptions = false;
|
|
1324
|
-
});
|
|
1325
|
-
// Keep a reference to the previous `valueHasChanged`. Changes made here don't count has changing the value.
|
|
1326
|
-
const cachedValueHasChanged = this.valueHasChanged;
|
|
1327
|
-
this.value = value;
|
|
1328
|
-
this.displayLabel = label;
|
|
1329
|
-
this.formControlController.updateValidity();
|
|
1330
|
-
this.valueHasChanged = cachedValueHasChanged;
|
|
1331
|
-
}
|
|
1332
|
-
|
|
1333
|
-
// eslint-disable-next-line complexity
|
|
1334
|
-
private handleChange() {
|
|
1335
|
-
// Only update the value and emit the event, if the change event occurred by
|
|
1336
|
-
// the user typing something in and removing focus of the combobox
|
|
1337
|
-
const isSameSelection = (this.selectedOptions.length !== 0 && this.selectedOptions.length === this.getOptionsFromValue().length);
|
|
1338
|
-
let values: (string | number)[];
|
|
1339
|
-
if (Array.isArray(this.value)) {
|
|
1340
|
-
values = this.value;
|
|
1341
|
-
} else if (typeof this.value === 'string') {
|
|
1342
|
-
values = this.value.split(this.delimiter);
|
|
1343
|
-
} else {
|
|
1344
|
-
values = [this.value];
|
|
1345
|
-
}
|
|
1346
|
-
const allValuesValid = values.every((val) => this.isValidValue(val));
|
|
1347
|
-
const isMultipleAndUserInput = this.multiple && isSameSelection && allValuesValid;
|
|
1348
|
-
const isNonMultipleAndUserInput = !this.multiple && this.selectedOptions.length > 0;
|
|
1349
|
-
if (isNonMultipleAndUserInput || isMultipleAndUserInput) {
|
|
1350
|
-
return;
|
|
1351
|
-
}
|
|
1352
|
-
|
|
1353
|
-
const oldValue = this.lastOptions ? getValuesFromOptions(this.lastOptions) : [];
|
|
1354
|
-
|
|
1355
|
-
// If the value is not valid, we need to reset the value to the last valid value
|
|
1356
|
-
if ((this.restricted || this.multiple) && !this.isValidValue(this.displayLabel) && this.displayLabel !== '') {
|
|
1357
|
-
this.resetToLastValidValue();
|
|
1358
|
-
return;
|
|
1359
|
-
}
|
|
1360
|
-
const options = this.getOptionsFromValue();
|
|
1361
|
-
|
|
1362
|
-
this.setSelectedOptions(options);
|
|
1363
|
-
this.selectionChanged();
|
|
1364
|
-
this.lastOptions = [...options];
|
|
1365
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
1366
|
-
this.updateComplete.then(() => {
|
|
1367
|
-
this.formControlController.updateValidity();
|
|
1368
|
-
});
|
|
1369
|
-
|
|
1370
|
-
const value = Array.isArray(this.value) ? this.value : [this.value];
|
|
1371
|
-
if (!compareValues(oldValue, value)) {
|
|
1372
|
-
this.emit('syn-change');
|
|
1373
|
-
}
|
|
1374
|
-
}
|
|
1375
|
-
|
|
1376
|
-
private getSlottedOptions() {
|
|
1377
|
-
if (!this.defaultSlot) {
|
|
1378
|
-
return [];
|
|
1379
|
-
}
|
|
1380
|
-
return getAllOptions(getAssignedElementsForSlot(this.defaultSlot)).flat();
|
|
1381
|
-
}
|
|
1382
|
-
|
|
1383
|
-
private getSlottedOptGroups(): SynOptGroup[] {
|
|
1384
|
-
return filterOnlyOptgroups(getAssignedElementsForSlot(this.defaultSlot));
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
/* eslint-disable no-param-reassign */
|
|
1388
|
-
private cacheSlottedOptionsAndOptgroups() {
|
|
1389
|
-
const slottedOptions = this.getSlottedOptions();
|
|
1390
|
-
const slottedOptgroups = this.getSlottedOptGroups();
|
|
1391
|
-
|
|
1392
|
-
slottedOptions.forEach((option, index) => {
|
|
1393
|
-
option.id = option.id || `syn-combobox-option-${index}`;
|
|
1394
|
-
});
|
|
1395
|
-
|
|
1396
|
-
slottedOptgroups.forEach((optgroup, index) => {
|
|
1397
|
-
optgroup.id = optgroup.id || `syn-combobox-optgroup-${index}`;
|
|
1398
|
-
});
|
|
1399
|
-
|
|
1400
|
-
// Cache the slotted options
|
|
1401
|
-
this.cachedOptions = [...slottedOptions];
|
|
1402
|
-
}
|
|
1403
|
-
/* eslint-enable no-param-reassign */
|
|
1404
|
-
|
|
1405
|
-
private updateSelectedOptionFromValue(): void {
|
|
1406
|
-
if (!this.isUserInput) {
|
|
1407
|
-
// check if the value has corresponding options via value or text content
|
|
1408
|
-
// for empty values use the text content, as then the values of the options are not set
|
|
1409
|
-
const options = this.getOptionsFromValue();
|
|
1410
|
-
|
|
1411
|
-
this.setSelectedOptions(options);
|
|
1412
|
-
this.selectionChanged();
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1415
|
-
let queryString = '';
|
|
1416
|
-
if (this.multiple) {
|
|
1417
|
-
queryString = this.displayLabel;
|
|
1418
|
-
} else {
|
|
1419
|
-
queryString = Array.isArray(this.value) ? this.value.join(', ') : String(this.value);
|
|
1420
|
-
}
|
|
1421
|
-
this.createComboboxOptionsFromQuery(queryString);
|
|
1422
|
-
}
|
|
1423
|
-
|
|
1424
|
-
/**
|
|
1425
|
-
* Synchronizes the internal component state with changes to slotted options.
|
|
1426
|
-
*
|
|
1427
|
-
* This method is automatically triggered by:
|
|
1428
|
-
* - MutationObserver when option 'value' attributes change
|
|
1429
|
-
* - Initial component setup during connectedCallback (after timeout)
|
|
1430
|
-
* - Default slot changes (via handleDefaultSlotChange)
|
|
1431
|
-
* - Custom element registration completion for syn-option (deferred execution)
|
|
1432
|
-
*
|
|
1433
|
-
* The synchronization process:
|
|
1434
|
-
* 1. Waits for syn-option custom elements to be registered before processing
|
|
1435
|
-
* 2. Updates delimiter settings on all slotted options
|
|
1436
|
-
* 3. Refreshes the internal cache of options and optgroups
|
|
1437
|
-
* 4. Synchronizes selected options based on current component value
|
|
1438
|
-
* 5. Auto-opens listbox if component has focus, has value, and is currently closed
|
|
1439
|
-
*
|
|
1440
|
-
* This ensures the component's internal state stays consistent with the slotted
|
|
1441
|
-
* DOM content after options are added, removed, or their values change.
|
|
1442
|
-
*
|
|
1443
|
-
*/
|
|
1444
|
-
/* eslint-disable @typescript-eslint/no-floating-promises */
|
|
1445
|
-
private handleSlotContentChange() {
|
|
1446
|
-
// Rerun this handler when <syn-option> is registered
|
|
1447
|
-
if (!customElements.get('syn-option')) {
|
|
1448
|
-
customElements.whenDefined('syn-option').then(() => this.handleSlotContentChange());
|
|
1449
|
-
return;
|
|
1450
|
-
}
|
|
1451
|
-
|
|
1452
|
-
this.handleDelimiterChange();
|
|
1453
|
-
this.cacheSlottedOptionsAndOptgroups();
|
|
1454
|
-
|
|
1455
|
-
this.updateSelectedOptionFromValue();
|
|
1456
|
-
|
|
1457
|
-
// Auto-open listbox for better UX when new options are added during interaction
|
|
1458
|
-
let hasValue: boolean;
|
|
1459
|
-
if (Array.isArray(this.value)) {
|
|
1460
|
-
hasValue = this.value.length > 0;
|
|
1461
|
-
} else if (typeof this.value === 'string') {
|
|
1462
|
-
hasValue = this.value.length > 0;
|
|
1463
|
-
} else {
|
|
1464
|
-
hasValue = this.value !== undefined && this.value !== null;
|
|
1465
|
-
}
|
|
1466
|
-
|
|
1467
|
-
if (this.hasFocus && hasValue && !this.open) {
|
|
1468
|
-
this.show();
|
|
1469
|
-
}
|
|
1470
|
-
}
|
|
1471
|
-
/* eslint-enable @typescript-eslint/no-floating-promises */
|
|
1472
|
-
|
|
1473
|
-
public handleDefaultSlotChange() {
|
|
1474
|
-
// Ignore slot changes triggered by our own option updates
|
|
1475
|
-
if (this.isOptionRendererTriggered) {
|
|
1476
|
-
return;
|
|
1477
|
-
}
|
|
1478
|
-
|
|
1479
|
-
this.handleSlotContentChange();
|
|
1480
|
-
}
|
|
1481
|
-
|
|
1482
|
-
/* eslint-disable @typescript-eslint/unbound-method */
|
|
1483
|
-
// eslint-disable-next-line complexity
|
|
1484
|
-
render() {
|
|
1485
|
-
const hasLabelSlot = this.hasSlotController.test('label');
|
|
1486
|
-
const hasHelpTextSlot = this.hasSlotController.test('help-text');
|
|
1487
|
-
const hasLabel = this.label ? true : !!hasLabelSlot;
|
|
1488
|
-
const hasHelpText = this.helpText ? true : !!hasHelpTextSlot;
|
|
1489
|
-
let hasValue: boolean;
|
|
1490
|
-
if (Array.isArray(this.value)) {
|
|
1491
|
-
hasValue = this.value.length > 0;
|
|
1492
|
-
} else if (typeof this.value === 'string') {
|
|
1493
|
-
hasValue = this.value.length > 0;
|
|
1494
|
-
} else {
|
|
1495
|
-
hasValue = this.value !== undefined && this.value !== null && typeof this.value === 'number';
|
|
1496
|
-
}
|
|
1497
|
-
|
|
1498
|
-
const hasClearIcon = this.clearable && (!this.disabled && !this.readonly) && hasValue;
|
|
1499
|
-
const isPlaceholderVisible = this.placeholder && !hasValue;
|
|
1500
|
-
const tagsVisible = this.multiple && this.selectedOptions.length > 0;
|
|
1501
|
-
|
|
1502
|
-
return html`
|
|
1503
|
-
<div
|
|
1504
|
-
part="form-control"
|
|
1505
|
-
class=${classMap({
|
|
1506
|
-
'form-control': true,
|
|
1507
|
-
'form-control--has-help-text': hasHelpText,
|
|
1508
|
-
'form-control--has-label': hasLabel,
|
|
1509
|
-
'form-control--large': this.size === 'large',
|
|
1510
|
-
'form-control--medium': this.size === 'medium',
|
|
1511
|
-
'form-control--small': this.size === 'small',
|
|
1512
|
-
})}
|
|
1513
|
-
@click=${this.handleFormControlClick}
|
|
1514
|
-
>
|
|
1515
|
-
<label
|
|
1516
|
-
id="label"
|
|
1517
|
-
part="form-control-label"
|
|
1518
|
-
class="form-control__label"
|
|
1519
|
-
aria-hidden=${hasLabel ? 'false' : 'true'}
|
|
1520
|
-
@click=${this.handleLabelClick}
|
|
1521
|
-
>
|
|
1522
|
-
<slot name="label">${this.label}</slot>
|
|
1523
|
-
</label>
|
|
1524
|
-
|
|
1525
|
-
<div part="form-control-input" class="form-control-input">
|
|
1526
|
-
<syn-popup
|
|
1527
|
-
class=${classMap({
|
|
1528
|
-
combobox: true,
|
|
1529
|
-
'combobox--bottom': this.placement === 'bottom',
|
|
1530
|
-
'combobox--disabled': this.disabled,
|
|
1531
|
-
'combobox--focused': this.hasFocus,
|
|
1532
|
-
'combobox--large': this.size === 'large',
|
|
1533
|
-
'combobox--medium': this.size === 'medium',
|
|
1534
|
-
'combobox--multiple': this.multiple,
|
|
1535
|
-
'combobox--open': this.open,
|
|
1536
|
-
'combobox--placeholder-visible': isPlaceholderVisible,
|
|
1537
|
-
'combobox--readonly': this.readonly,
|
|
1538
|
-
'combobox--small': this.size === 'small',
|
|
1539
|
-
'combobox--standard': true,
|
|
1540
|
-
'combobox--tags-visible': tagsVisible,
|
|
1541
|
-
'combobox--top': this.placement === 'top',
|
|
1542
|
-
})}
|
|
1543
|
-
placement=${`${this.placement}-start`}
|
|
1544
|
-
flip
|
|
1545
|
-
shift
|
|
1546
|
-
sync="width"
|
|
1547
|
-
auto-size="vertical"
|
|
1548
|
-
auto-size-padding="10"
|
|
1549
|
-
exportparts="popup"
|
|
1550
|
-
>
|
|
1551
|
-
<div
|
|
1552
|
-
part="combobox"
|
|
1553
|
-
class="combobox__inputs"
|
|
1554
|
-
slot="anchor"
|
|
1555
|
-
@keydown=${this.handleComboboxKeyDown}
|
|
1556
|
-
@mousedown=${this.handleComboboxMouseDown}
|
|
1557
|
-
>
|
|
1558
|
-
<slot part="prefix" name="prefix" class="combobox__prefix"></slot>
|
|
1559
|
-
|
|
1560
|
-
${this.multiple && !this.readonly ? html`<div part="tags" class="combobox__tags">${this.tags}</div>` : ''}
|
|
1561
|
-
|
|
1562
|
-
<input
|
|
1563
|
-
part="display-input"
|
|
1564
|
-
class="combobox__display-input"
|
|
1565
|
-
type="text"
|
|
1566
|
-
placeholder=${this.placeholder}
|
|
1567
|
-
.disabled=${this.disabled}
|
|
1568
|
-
.readOnly=${this.readonly}
|
|
1569
|
-
.value=${this.displayLabel}
|
|
1570
|
-
maxlength=${ifDefined(this.maxlength)}
|
|
1571
|
-
autocomplete="off"
|
|
1572
|
-
spellcheck="false"
|
|
1573
|
-
autocapitalize="off"
|
|
1574
|
-
aria-controls="listbox"
|
|
1575
|
-
aria-expanded=${this.open ? 'true' : 'false'}
|
|
1576
|
-
aria-haspopup="listbox"
|
|
1577
|
-
aria-labelledby="label"
|
|
1578
|
-
aria-disabled=${this.disabled ? 'true' : 'false'}
|
|
1579
|
-
aria-describedby="help-text"
|
|
1580
|
-
role="combobox"
|
|
1581
|
-
tabindex="0"
|
|
1582
|
-
@focus=${this.handleFocus}
|
|
1583
|
-
@blur=${this.handleBlur}
|
|
1584
|
-
|
|
1585
|
-
aria-autocomplete="list"
|
|
1586
|
-
aria-owns="listbox"
|
|
1587
|
-
@input=${this.handleInput}
|
|
1588
|
-
@change=${this.handleChange}
|
|
1589
|
-
/>
|
|
1590
|
-
|
|
1591
|
-
<input
|
|
1592
|
-
class="combobox__value-input"
|
|
1593
|
-
type="text"
|
|
1594
|
-
?disabled=${this.disabled}
|
|
1595
|
-
?readonly=${this.readonly}
|
|
1596
|
-
?required=${this.required}
|
|
1597
|
-
.value=${Array.isArray(this.value) ? this.value.join(', ') : this.value?.toString()}
|
|
1598
|
-
tabindex="-1"
|
|
1599
|
-
aria-hidden="true"
|
|
1600
|
-
@focus=${() => this.focus()}
|
|
1601
|
-
@invalid=${this.handleInvalid}
|
|
1602
|
-
/>
|
|
1603
|
-
|
|
1604
|
-
${hasClearIcon
|
|
1605
|
-
? html`
|
|
1606
|
-
<button
|
|
1607
|
-
part="clear-button"
|
|
1608
|
-
class="combobox__clear"
|
|
1609
|
-
type="button"
|
|
1610
|
-
aria-label=${this.localize.term('clearEntry')}
|
|
1611
|
-
@mousedown=${this.preventLoosingFocus}
|
|
1612
|
-
@click=${this.handleClearClick}
|
|
1613
|
-
tabindex="-1"
|
|
1614
|
-
>
|
|
1615
|
-
<slot name="clear-icon">
|
|
1616
|
-
<syn-icon name="x-circle-fill" library="system"></syn-icon>
|
|
1617
|
-
</slot>
|
|
1618
|
-
</button>
|
|
1619
|
-
`
|
|
1620
|
-
: ''}
|
|
1621
|
-
|
|
1622
|
-
<slot name="suffix" part="suffix" class="combobox__suffix"></slot>
|
|
1623
|
-
|
|
1624
|
-
<slot name="expand-icon" part="expand-icon" class="combobox__expand-icon">
|
|
1625
|
-
<syn-icon library="system" name="chevron-down"></syn-icon>
|
|
1626
|
-
</slot>
|
|
1627
|
-
</div>
|
|
1628
|
-
|
|
1629
|
-
<div
|
|
1630
|
-
id="listbox"
|
|
1631
|
-
role="listbox"
|
|
1632
|
-
aria-expanded=${this.open ? 'true' : 'false'}
|
|
1633
|
-
aria-labelledby="label"
|
|
1634
|
-
aria-multiselectable=${this.multiple ? 'true' : 'false'}
|
|
1635
|
-
part="listbox"
|
|
1636
|
-
class="combobox__listbox"
|
|
1637
|
-
tabindex="-1"
|
|
1638
|
-
@mousedown=${this.preventLoosingFocus}
|
|
1639
|
-
@mouseup=${this.handleOptionClick}
|
|
1640
|
-
>
|
|
1641
|
-
<div class="listbox__options" part="filtered-listbox">
|
|
1642
|
-
${this.hideOptions || this.numberFilteredOptions === 0
|
|
1643
|
-
? html`<span
|
|
1644
|
-
class="listbox__no-results"
|
|
1645
|
-
aria-hidden="true"
|
|
1646
|
-
part="no-results"
|
|
1647
|
-
>${this.localize.term('noResults')}</span
|
|
1648
|
-
>`
|
|
1649
|
-
: ''}
|
|
1650
|
-
<slot class=${classMap({ options__hide: this.hideOptions })} @slotchange=${this.handleDefaultSlotChange}></slot>
|
|
1651
|
-
</div>
|
|
1652
|
-
</div>
|
|
1653
|
-
</syn-popup>
|
|
1654
|
-
</div>
|
|
1655
|
-
|
|
1656
|
-
<div
|
|
1657
|
-
part="form-control-help-text"
|
|
1658
|
-
id="help-text"
|
|
1659
|
-
class="form-control__help-text"
|
|
1660
|
-
aria-hidden=${hasHelpText ? 'false' : 'true'}
|
|
1661
|
-
>
|
|
1662
|
-
<slot name="help-text">${this.helpText}</slot>
|
|
1663
|
-
</div>
|
|
1664
|
-
</div>
|
|
1665
|
-
`;
|
|
1666
|
-
}
|
|
1667
|
-
/* eslint-enable @typescript-eslint/unbound-method */
|
|
1668
|
-
}
|
|
1669
|
-
|
|
1670
|
-
setDefaultAnimation('combobox.show', {
|
|
1671
|
-
keyframes: [
|
|
1672
|
-
{ opacity: 0, scale: 0.9 },
|
|
1673
|
-
{ opacity: 1, scale: 1 },
|
|
1674
|
-
],
|
|
1675
|
-
options: { duration: 100, easing: 'ease' },
|
|
1676
|
-
});
|
|
1677
|
-
|
|
1678
|
-
setDefaultAnimation('combobox.hide', {
|
|
1679
|
-
keyframes: [
|
|
1680
|
-
{ opacity: 1, scale: 1 },
|
|
1681
|
-
{ opacity: 0, scale: 0.9 },
|
|
1682
|
-
],
|
|
1683
|
-
options: { duration: 100, easing: 'ease' },
|
|
1684
|
-
});
|