@lion/ui 0.0.1 → 0.0.3
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/components/core/test/SlotMixin.test.js +28 -21
- package/components/drawer/src/LionDrawer.js +217 -0
- package/components/drawer/src/drawerStyle.js +59 -0
- package/components/drawer/test/lion-drawer.test.js +109 -0
- package/components/localize/src/number/parseNumber.js +15 -36
- package/components/localize/test/number/parseNumber.test.js +3 -12
- package/custom-elements.json +743 -0
- package/dist-types/components/drawer/src/LionDrawer.d.ts +67 -0
- package/dist-types/components/drawer/src/LionDrawer.d.ts.map +1 -0
- package/dist-types/components/drawer/src/drawerStyle.d.ts +2 -0
- package/dist-types/components/drawer/src/drawerStyle.d.ts.map +1 -0
- package/dist-types/components/drawer/test/lion-drawer.test.d.ts +3 -0
- package/dist-types/components/drawer/test/lion-drawer.test.d.ts.map +1 -0
- package/dist-types/components/localize/src/number/parseNumber.d.ts.map +1 -1
- package/dist-types/exports/define/lion-drawer.d.ts +2 -0
- package/dist-types/exports/define/lion-drawer.d.ts.map +1 -0
- package/dist-types/exports/drawer.d.ts +2 -0
- package/dist-types/exports/drawer.d.ts.map +1 -0
- package/dist-types/tsconfig.tsbuildinfo +1 -1
- package/docs/components/accordion/index.md +3 -0
- package/docs/components/accordion/overview.md +129 -0
- package/docs/components/accordion/reference.md +47 -0
- package/docs/components/accordion/use-cases.md +252 -0
- package/docs/components/button/examples.md +30 -0
- package/docs/components/button/index.md +3 -0
- package/docs/components/button/overview.md +30 -0
- package/docs/components/button/src/icon.svg.js +5 -0
- package/docs/components/button/use-cases.md +106 -0
- package/docs/components/calendar/index.md +3 -0
- package/docs/components/calendar/overview.md +49 -0
- package/docs/components/calendar/use-cases.md +192 -0
- package/docs/components/checkbox-group/index.md +3 -0
- package/docs/components/checkbox-group/overview.md +40 -0
- package/docs/components/checkbox-group/use-cases.md +256 -0
- package/docs/components/collapsible/assets/CustomCollapsible.js +113 -0
- package/docs/components/collapsible/assets/applyDemoCollapsibleStyles.js +37 -0
- package/docs/components/collapsible/examples.md +83 -0
- package/docs/components/collapsible/index.md +3 -0
- package/docs/components/collapsible/overview.md +39 -0
- package/docs/components/collapsible/use-cases.md +79 -0
- package/docs/components/combobox/examples.md +153 -0
- package/docs/components/combobox/index.md +3 -0
- package/docs/components/combobox/overview.md +51 -0
- package/docs/components/combobox/src/LinkMixin.js +60 -0
- package/docs/components/combobox/src/demo-selection-display.js +191 -0
- package/docs/components/combobox/src/gh-combobox/gh-button.js +69 -0
- package/docs/components/combobox/src/gh-combobox/gh-combobox.js +508 -0
- package/docs/components/combobox/src/google-combobox/assets/google-clear-icon.js +9 -0
- package/docs/components/combobox/src/google-combobox/assets/google-search-icon.js +9 -0
- package/docs/components/combobox/src/google-combobox/assets/google-voice-search-icon.js +19 -0
- package/docs/components/combobox/src/google-combobox/assets/googlelogo_color_272x92dp.png +0 -0
- package/docs/components/combobox/src/google-combobox/google-combobox.js +460 -0
- package/docs/components/combobox/src/lazyRender.js +29 -0
- package/docs/components/combobox/src/levenshtein.js +95 -0
- package/docs/components/combobox/src/md-combobox/MdFieldMixin.js +341 -0
- package/docs/components/combobox/src/md-combobox/md-combobox.js +89 -0
- package/docs/components/combobox/src/md-combobox/md-input.js +5 -0
- package/docs/components/combobox/src/md-combobox/style/load-roboto.js +6 -0
- package/docs/components/combobox/src/md-combobox/style/md-ripple.js +81 -0
- package/docs/components/combobox/src/wa-combobox/wa-combobox.js +368 -0
- package/docs/components/combobox/use-cases.md +377 -0
- package/docs/components/dialog/index.md +3 -0
- package/docs/components/dialog/overview.md +63 -0
- package/docs/components/dialog/src/demo-dialog-style.js +3 -0
- package/docs/components/dialog/src/demoStyle.js +39 -0
- package/docs/components/dialog/src/slots-dialog-content.js +32 -0
- package/docs/components/dialog/src/styled-dialog-content.js +38 -0
- package/docs/components/dialog/use-cases.md +154 -0
- package/docs/components/drawer/index.md +3 -0
- package/docs/components/drawer/overview.md +68 -0
- package/docs/components/drawer/src/demoStyle.js +71 -0
- package/docs/components/drawer/use-cases.md +194 -0
- package/docs/components/fieldset/index.md +3 -0
- package/docs/components/fieldset/overview.md +49 -0
- package/docs/components/fieldset/use-cases.md +185 -0
- package/docs/components/form/index.md +3 -0
- package/docs/components/form/overview.md +43 -0
- package/docs/components/form/use-cases.md +72 -0
- package/docs/components/icon/assets/bugs/bug01.svg.js +2 -0
- package/docs/components/icon/assets/bugs/bug02.svg.js +2 -0
- package/docs/components/icon/assets/bugs/bug05.svg.js +2 -0
- package/docs/components/icon/assets/bugs/bug06.svg.js +2 -0
- package/docs/components/icon/assets/bugs/bug08.svg.js +2 -0
- package/docs/components/icon/assets/bugs/bug12.svg.js +2 -0
- package/docs/components/icon/assets/bugs/bug19.svg.js +2 -0
- package/docs/components/icon/assets/bugs/bug23.svg.js +2 -0
- package/docs/components/icon/assets/bugs/bug24.svg.js +2 -0
- package/docs/components/icon/assets/iconset-bugs.js +11 -0
- package/docs/components/icon/assets/iconset-misc.js +3 -0
- package/docs/components/icon/assets/iconset-space.js +31 -0
- package/docs/components/icon/assets/misc/arrowLeft.svg.js +6 -0
- package/docs/components/icon/assets/space/aliens-spaceship.svg.js +2 -0
- package/docs/components/icon/assets/space/meteor.svg.js +2 -0
- package/docs/components/icon/assets/space/moon-flag.svg.js +2 -0
- package/docs/components/icon/assets/space/moon.svg.js +2 -0
- package/docs/components/icon/assets/space/night.svg.js +2 -0
- package/docs/components/icon/assets/space/orbit.svg.js +2 -0
- package/docs/components/icon/assets/space/planet.svg.js +2 -0
- package/docs/components/icon/assets/space/robot.svg.js +2 -0
- package/docs/components/icon/assets/space/rocket.svg.js +2 -0
- package/docs/components/icon/assets/space/satellite.svg.js +2 -0
- package/docs/components/icon/assets/space/signal.svg.js +2 -0
- package/docs/components/icon/assets/space/space-helmet.svg.js +2 -0
- package/docs/components/icon/assets/space/sun.svg.js +2 -0
- package/docs/components/icon/assets/space/telescope.svg.js +2 -0
- package/docs/components/icon/index.md +3 -0
- package/docs/components/icon/overview.md +40 -0
- package/docs/components/icon/use-cases.md +93 -0
- package/docs/components/index.md +7 -0
- package/docs/components/input/index.md +3 -0
- package/docs/components/input/overview.md +36 -0
- package/docs/components/input/use-cases.md +77 -0
- package/docs/components/input-amount/index.md +3 -0
- package/docs/components/input-amount/overview.md +49 -0
- package/docs/components/input-amount/use-cases.md +122 -0
- package/docs/components/input-date/index.md +3 -0
- package/docs/components/input-date/overview.md +39 -0
- package/docs/components/input-date/use-cases.md +83 -0
- package/docs/components/input-datepicker/index.md +3 -0
- package/docs/components/input-datepicker/overview.md +42 -0
- package/docs/components/input-datepicker/use-cases.md +78 -0
- package/docs/components/input-email/index.md +3 -0
- package/docs/components/input-email/overview.md +32 -0
- package/docs/components/input-email/use-cases.md +48 -0
- package/docs/components/input-iban/index.md +3 -0
- package/docs/components/input-iban/overview.md +37 -0
- package/docs/components/input-iban/use-cases.md +102 -0
- package/docs/components/input-range/index.md +3 -0
- package/docs/components/input-range/overview.md +34 -0
- package/docs/components/input-range/use-cases.md +108 -0
- package/docs/components/input-stepper/index.md +3 -0
- package/docs/components/input-stepper/overview.md +36 -0
- package/docs/components/input-stepper/use-cases.md +41 -0
- package/docs/components/input-tel/index.md +3 -0
- package/docs/components/input-tel/overview.md +62 -0
- package/docs/components/input-tel/src/h-region-code-table.js +109 -0
- package/docs/components/input-tel/use-cases.md +307 -0
- package/docs/components/input-tel-dropdown/examples.md +32 -0
- package/docs/components/input-tel-dropdown/index.md +3 -0
- package/docs/components/input-tel-dropdown/overview.md +38 -0
- package/docs/components/input-tel-dropdown/src/intl-input-tel-dropdown.js +127 -0
- package/docs/components/input-tel-dropdown/use-cases.md +159 -0
- package/docs/components/listbox/index.md +3 -0
- package/docs/components/listbox/overview.md +42 -0
- package/docs/components/listbox/src/listboxData.js +65 -0
- package/docs/components/listbox/use-cases.md +147 -0
- package/docs/components/pagination/index.md +3 -0
- package/docs/components/pagination/overview.md +29 -0
- package/docs/components/pagination/use-cases.md +99 -0
- package/docs/components/progress-indicator/assets/my-determinate-progress-bar.js +30 -0
- package/docs/components/progress-indicator/assets/my-indeterminate-progress-spinner.js +55 -0
- package/docs/components/progress-indicator/examples.md +125 -0
- package/docs/components/progress-indicator/index.md +3 -0
- package/docs/components/progress-indicator/overview.md +36 -0
- package/docs/components/radio-group/index.md +3 -0
- package/docs/components/radio-group/overview.md +46 -0
- package/docs/components/radio-group/use-cases.md +140 -0
- package/docs/components/select/index.md +3 -0
- package/docs/components/select/overview.md +44 -0
- package/docs/components/select/use-cases.md +55 -0
- package/docs/components/select-rich/examples.md +31 -0
- package/docs/components/select-rich/index.md +3 -0
- package/docs/components/select-rich/overview.md +46 -0
- package/docs/components/select-rich/src/flagStyles.js +1250 -0
- package/docs/components/select-rich/src/flags.png +0 -0
- package/docs/components/select-rich/src/flags@2x.png +0 -0
- package/docs/components/select-rich/src/intl-select-rich.js +194 -0
- package/docs/components/select-rich/src/regionMetaList.js +1717 -0
- package/docs/components/select-rich/use-cases.md +370 -0
- package/docs/components/steps/index.md +3 -0
- package/docs/components/steps/overview.md +63 -0
- package/docs/components/steps/use-cases.md +163 -0
- package/docs/components/switch/index.md +3 -0
- package/docs/components/switch/overview.md +75 -0
- package/docs/components/switch/reference.md +39 -0
- package/docs/components/switch/use-cases.md +76 -0
- package/docs/components/tabs/examples.md +23 -0
- package/docs/components/tabs/index.md +3 -0
- package/docs/components/tabs/overview.md +48 -0
- package/docs/components/tabs/src/lea-tab-panel.js +24 -0
- package/docs/components/tabs/src/lea-tab.js +45 -0
- package/docs/components/tabs/src/lea-tabs.js +28 -0
- package/docs/components/tabs/use-cases.md +219 -0
- package/docs/components/textarea/index.md +3 -0
- package/docs/components/textarea/overview.md +35 -0
- package/docs/components/textarea/use-cases.md +95 -0
- package/docs/components/tooltip/examples.md +39 -0
- package/docs/components/tooltip/index.md +3 -0
- package/docs/components/tooltip/overview.md +44 -0
- package/docs/components/tooltip/use-cases.md +208 -0
- package/docs/fundamentals/index.md +19 -0
- package/docs/fundamentals/node-tools/babel-plugin-extend-docs/index.md +1 -0
- package/docs/fundamentals/node-tools/babel-plugin-extend-docs/overview.md +233 -0
- package/docs/fundamentals/node-tools/index.md +1 -0
- package/docs/fundamentals/node-tools/providence-analytics/LocalConfiguration.md +68 -0
- package/docs/fundamentals/node-tools/providence-analytics/QueryResult.md +111 -0
- package/docs/fundamentals/node-tools/providence-analytics/analyzer.md +69 -0
- package/docs/fundamentals/node-tools/providence-analytics/assets/_mermaid.svg.js +1202 -0
- package/docs/fundamentals/node-tools/providence-analytics/dashboard.md +22 -0
- package/docs/fundamentals/node-tools/providence-analytics/index.md +1 -0
- package/docs/fundamentals/node-tools/providence-analytics/overview.md +192 -0
- package/docs/fundamentals/node-tools/publish-docs/index.md +1 -0
- package/docs/fundamentals/node-tools/publish-docs/overview.md +136 -0
- package/docs/fundamentals/node-tools/remark-extend/index.md +1 -0
- package/docs/fundamentals/node-tools/remark-extend/overview.md +274 -0
- package/docs/fundamentals/node-tools/rocket-preset-extend-lion-docs/index.md +1 -0
- package/docs/fundamentals/node-tools/rocket-preset-extend-lion-docs/overview.md +285 -0
- package/docs/fundamentals/rationales/TypeScript.md +18 -0
- package/docs/fundamentals/rationales/index.md +1 -0
- package/docs/fundamentals/rationales/side-effects.md +203 -0
- package/docs/fundamentals/rationales/versioning.md +35 -0
- package/docs/fundamentals/systems/core/index.md +3 -0
- package/docs/fundamentals/systems/core/overview.md +85 -0
- package/docs/fundamentals/systems/form/assets/FormatMixinDiagram-1.svg +1 -0
- package/docs/fundamentals/systems/form/assets/FormatMixinDiagram-2.svg +1 -0
- package/docs/fundamentals/systems/form/assets/FormatMixinDiagram-3.svg +84 -0
- package/docs/fundamentals/systems/form/assets/h-output.js +155 -0
- package/docs/fundamentals/systems/form/formatting-and-parsing.md +245 -0
- package/docs/fundamentals/systems/form/index.md +3 -0
- package/docs/fundamentals/systems/form/interaction-states.md +177 -0
- package/docs/fundamentals/systems/form/model-value.md +35 -0
- package/docs/fundamentals/systems/form/overview.md +82 -0
- package/docs/fundamentals/systems/form/styling.md +101 -0
- package/docs/fundamentals/systems/form/use-cases.md +156 -0
- package/docs/fundamentals/systems/form/validate.md +929 -0
- package/docs/fundamentals/systems/icon/index.md +3 -0
- package/docs/fundamentals/systems/icon/overview.md +124 -0
- package/docs/fundamentals/systems/index.md +1 -0
- package/docs/fundamentals/systems/localize/assets/all-locales.js +437 -0
- package/docs/fundamentals/systems/localize/assets/en-AU.js +6 -0
- package/docs/fundamentals/systems/localize/assets/en-GB.js +6 -0
- package/docs/fundamentals/systems/localize/assets/en-US.js +6 -0
- package/docs/fundamentals/systems/localize/assets/en.js +4 -0
- package/docs/fundamentals/systems/localize/assets/nl-BE.js +6 -0
- package/docs/fundamentals/systems/localize/assets/nl-NL.js +6 -0
- package/docs/fundamentals/systems/localize/assets/nl.js +4 -0
- package/docs/fundamentals/systems/localize/dates.md +195 -0
- package/docs/fundamentals/systems/localize/index.md +3 -0
- package/docs/fundamentals/systems/localize/numbers.md +217 -0
- package/docs/fundamentals/systems/localize/overview.md +48 -0
- package/docs/fundamentals/systems/localize/rationale.md +62 -0
- package/docs/fundamentals/systems/localize/text.md +125 -0
- package/docs/fundamentals/systems/localize/use-cases.md +319 -0
- package/docs/fundamentals/systems/overlays/assets/applyDemoOverlayStyles.js +22 -0
- package/docs/fundamentals/systems/overlays/assets/demo-overlay-backdrop.js +48 -0
- package/docs/fundamentals/systems/overlays/assets/demo-overlay-system.js +42 -0
- package/docs/fundamentals/systems/overlays/assets/umbrella-form.js +133 -0
- package/docs/fundamentals/systems/overlays/configuration.md +453 -0
- package/docs/fundamentals/systems/overlays/form-integration.md +65 -0
- package/docs/fundamentals/systems/overlays/index.md +3 -0
- package/docs/fundamentals/systems/overlays/overview.md +118 -0
- package/docs/fundamentals/systems/overlays/rationale.md +232 -0
- package/docs/fundamentals/systems/overlays/scope.md +176 -0
- package/docs/fundamentals/systems/overlays/use-cases.md +699 -0
- package/docs/fundamentals/tools/ajax/assets/naga.json +9 -0
- package/docs/fundamentals/tools/ajax/assets/pabu.json +9 -0
- package/docs/fundamentals/tools/ajax/index.md +3 -0
- package/docs/fundamentals/tools/ajax/overview.md +128 -0
- package/docs/fundamentals/tools/ajax/use-cases.md +456 -0
- package/docs/fundamentals/tools/helpers/action-logger.md +165 -0
- package/docs/fundamentals/tools/helpers/index.md +3 -0
- package/docs/fundamentals/tools/helpers/overview.md +30 -0
- package/docs/fundamentals/tools/index.md +1 -0
- package/docs/fundamentals/tools/singleton-manager/index.md +3 -0
- package/docs/fundamentals/tools/singleton-manager/overview.md +304 -0
- package/docs/guides/how-to/create-a-custom-field.md +200 -0
- package/docs/guides/how-to/extend-a-native-input.md +66 -0
- package/docs/guides/how-to/get-started.md +77 -0
- package/docs/guides/how-to/index.md +1 -0
- package/docs/guides/index.md +34 -0
- package/docs/guides/principles/definitions-and-terms.md +41 -0
- package/docs/guides/principles/index.md +26 -0
- package/docs/guides/principles/scoped-elements.md +103 -0
- package/docs/guides/principles/styling.md +32 -0
- package/docs/guides/principles/subclasser-apis.md +28 -0
- package/docs/override.js +15 -0
- package/exports/define/lion-drawer.js +3 -0
- package/exports/drawer.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
# Combobox >> Use Cases ||20
|
|
2
|
+
|
|
3
|
+
A combobox is a widget made up of the combination of two distinct elements:
|
|
4
|
+
|
|
5
|
+
- a single-line textbox
|
|
6
|
+
- an associated listbox overlay
|
|
7
|
+
|
|
8
|
+
Based on the combobox configuration and entered textbox value, options in the listbox will be
|
|
9
|
+
filtered, checked, focused and the textbox value may be autocompleted.
|
|
10
|
+
Optionally the combobox contains a graphical button adjacent to the textbox, indicating the
|
|
11
|
+
availability of the popup.
|
|
12
|
+
|
|
13
|
+
> Fore more information, consult [Combobox wai-aria design pattern](https://www.w3.org/TR/wai-aria-practices/#combobox)
|
|
14
|
+
|
|
15
|
+
```js script
|
|
16
|
+
import { LitElement, html, repeat } from '@mdjs/mdjs-preview';
|
|
17
|
+
import { listboxData } from '../listbox/src/listboxData.js';
|
|
18
|
+
import { LionCombobox } from '@lion/ui/combobox.js';
|
|
19
|
+
import '@lion/ui/define/lion-combobox.js';
|
|
20
|
+
import '@lion/ui/define/lion-option.js';
|
|
21
|
+
import './src/demo-selection-display.js';
|
|
22
|
+
import { lazyRender } from './src/lazyRender.js';
|
|
23
|
+
import levenshtein from './src/levenshtein.js';
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Autocomplete
|
|
27
|
+
|
|
28
|
+
Below you will find an overview of all possible `autocomplete` behaviors and how they correspond
|
|
29
|
+
to the configurable values `none`, `list`, `inline` and `both`.
|
|
30
|
+
|
|
31
|
+
| | list | filter | focus | check | complete |
|
|
32
|
+
| -----: | :--: | :----: | :---: | :---: | :------: |
|
|
33
|
+
| none | ✓ | | | | |
|
|
34
|
+
| list | ✓ | ✓ | ✓ | ✓ | |
|
|
35
|
+
| inline | ✓ | | ✓ | ✓ | ✓ |
|
|
36
|
+
| both | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
37
|
+
|
|
38
|
+
- **list** shows a list on keydown character press
|
|
39
|
+
- **filter** filters list of potential matches according to `matchmode` or provided `matchCondition`
|
|
40
|
+
- **focus** automatically focuses closest match (makes it the activedescendant)
|
|
41
|
+
- **check** automatically checks/selects closest match when `selection-follows-focus` is enabled (this is the default configuration)
|
|
42
|
+
- **complete** completes the textbox value inline (the 'missing characters' will be added as selected text)
|
|
43
|
+
|
|
44
|
+
When `autocomplete="none"` is configured, the suggested options in the overlay are not filtered
|
|
45
|
+
based on the characters typed in the textbox.
|
|
46
|
+
Selection will happen manually by the user.
|
|
47
|
+
|
|
48
|
+
```js preview-story
|
|
49
|
+
export const autocompleteNone = () => html`
|
|
50
|
+
<lion-combobox name="combo" label="Autocomplete 'none'" autocomplete="none">
|
|
51
|
+
${lazyRender(
|
|
52
|
+
listboxData.map(entry => html` <lion-option .choiceValue="${entry}">${entry}</lion-option> `),
|
|
53
|
+
)}
|
|
54
|
+
</lion-combobox>
|
|
55
|
+
`;
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
When `autocomplete="list"` is configured, it will filter listbox suggestions based on textbox value.
|
|
59
|
+
|
|
60
|
+
```js preview-story
|
|
61
|
+
export const autocompleteList = () => html`
|
|
62
|
+
<lion-combobox name="combo" label="Autocomplete 'list'" autocomplete="list">
|
|
63
|
+
${lazyRender(
|
|
64
|
+
listboxData.map(entry => html` <lion-option .choiceValue="${entry}">${entry}</lion-option> `),
|
|
65
|
+
)}
|
|
66
|
+
</lion-combobox>
|
|
67
|
+
`;
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
When `autocomplete="inline"` is configured, it will present a value completion prediction inside the text input itself.
|
|
71
|
+
It does NOT filter list of potential matches.
|
|
72
|
+
|
|
73
|
+
```js preview-story
|
|
74
|
+
export const autocompleteInline = () => html`
|
|
75
|
+
<lion-combobox name="combo" label="Autocomplete 'inline'" autocomplete="inline">
|
|
76
|
+
${lazyRender(
|
|
77
|
+
listboxData.map(entry => html` <lion-option .choiceValue="${entry}">${entry}</lion-option> `),
|
|
78
|
+
)}
|
|
79
|
+
</lion-combobox>
|
|
80
|
+
`;
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
When `autocomplete="both"` is configured, it combines the filtered list from `'list'` with the text input value completion prediction from `'inline'`.
|
|
84
|
+
This is the default value for `autocomplete`.
|
|
85
|
+
|
|
86
|
+
```js preview-story
|
|
87
|
+
export const autocompleteBoth = () => html`
|
|
88
|
+
<lion-combobox name="combo" label="Autocomplete 'both'" autocomplete="both">
|
|
89
|
+
${lazyRender(
|
|
90
|
+
listboxData.map(entry => html` <lion-option .choiceValue="${entry}">${entry}</lion-option> `),
|
|
91
|
+
)}
|
|
92
|
+
</lion-combobox>
|
|
93
|
+
`;
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Match Mode
|
|
97
|
+
|
|
98
|
+
When `match-mode="begin"` is applied, the entered text in the textbox only filters
|
|
99
|
+
options whose values begin with the entered text. For instance, the entered text 'ch' will match
|
|
100
|
+
with value 'Chard', but not with 'Artichoke'.
|
|
101
|
+
By default `match-mode="all"` is applied. This will also match parts of a word.
|
|
102
|
+
So 'ch' will both match 'Chard' and 'Artichoke'.
|
|
103
|
+
|
|
104
|
+
```js preview-story
|
|
105
|
+
export const matchModeBegin = () => html`
|
|
106
|
+
<lion-combobox name="combo" label="Match Mode 'begin'" match-mode="begin">
|
|
107
|
+
${lazyRender(
|
|
108
|
+
listboxData.map(entry => html` <lion-option .choiceValue="${entry}">${entry}</lion-option> `),
|
|
109
|
+
)}
|
|
110
|
+
</lion-combobox>
|
|
111
|
+
`;
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
```js preview-story
|
|
115
|
+
export const matchModeAll = () => html`
|
|
116
|
+
<lion-combobox name="combo" label="Match Mode 'all'" match-mode="all">
|
|
117
|
+
${lazyRender(
|
|
118
|
+
listboxData.map(entry => html` <lion-option .choiceValue="${entry}">${entry}</lion-option> `),
|
|
119
|
+
)}
|
|
120
|
+
</lion-combobox>
|
|
121
|
+
`;
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
When the preconfigurable `match-mode` conditions are not sufficient,
|
|
125
|
+
one can define a custom matching function.
|
|
126
|
+
The example below matches when the Levenshtein distance is below 3 (including some other conditions).
|
|
127
|
+
|
|
128
|
+
```js preview-story
|
|
129
|
+
export const customMatchCondition = () => html`
|
|
130
|
+
<lion-combobox
|
|
131
|
+
name="combo"
|
|
132
|
+
label="Custom Match Mode 'levenshtein'"
|
|
133
|
+
help-text="Spelling mistakes will be forgiven. Try typing 'Aple' instead of 'Apple'"
|
|
134
|
+
.matchCondition="${({ choiceValue }, textboxValue) => {
|
|
135
|
+
const oVal = choiceValue.toLowerCase();
|
|
136
|
+
const tVal = textboxValue.toLowerCase();
|
|
137
|
+
const t = 1; // treshold
|
|
138
|
+
return oVal.slice(0, t) === tVal.slice(0, t) && levenshtein(oVal, tVal) < 3;
|
|
139
|
+
}}"
|
|
140
|
+
>
|
|
141
|
+
${lazyRender(
|
|
142
|
+
listboxData.map(entry => html` <lion-option .choiceValue="${entry}">${entry}</lion-option> `),
|
|
143
|
+
)}
|
|
144
|
+
</lion-combobox>
|
|
145
|
+
`;
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Options
|
|
149
|
+
|
|
150
|
+
```js preview-story
|
|
151
|
+
export const showAllOnEmpty = () => html`
|
|
152
|
+
<lion-combobox
|
|
153
|
+
name="combo"
|
|
154
|
+
label="Show all on empty"
|
|
155
|
+
help-text="Shows all (options) on empty (textbox has no value)"
|
|
156
|
+
show-all-on-empty
|
|
157
|
+
>
|
|
158
|
+
${lazyRender(
|
|
159
|
+
listboxData.map(entry => html` <lion-option .choiceValue="${entry}">${entry}</lion-option> `),
|
|
160
|
+
)}
|
|
161
|
+
</lion-combobox>
|
|
162
|
+
`;
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Changing defaults
|
|
166
|
+
|
|
167
|
+
By default `selection-follows-focus` will be true (aligned with the
|
|
168
|
+
wai-aria examples and the native `<datalist>`).
|
|
169
|
+
It is possible to disable this behavior, so the active/focused and checked/selected values
|
|
170
|
+
will be kept track of independently.
|
|
171
|
+
|
|
172
|
+
> Note that, (just like in a listbox), selection-follows-focus will never be applicable for
|
|
173
|
+
> multiselect comboboxes.
|
|
174
|
+
|
|
175
|
+
```js preview-story
|
|
176
|
+
export const noSelectionFollowsFocus = () => html`
|
|
177
|
+
<lion-combobox name="combo" label="No Selection Follows focus" .selectionFollowsFocus="${false}">
|
|
178
|
+
${lazyRender(
|
|
179
|
+
listboxData.map(entry => html` <lion-option .choiceValue="${entry}">${entry}</lion-option> `),
|
|
180
|
+
)}
|
|
181
|
+
</lion-combobox>
|
|
182
|
+
`;
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
By default `rotate-keyboard-navigation` will be true (aligned with the
|
|
186
|
+
wai-aria examples and the natve `<datalist>`).
|
|
187
|
+
It is possible to disable this behavior, see example below
|
|
188
|
+
|
|
189
|
+
```js preview-story
|
|
190
|
+
export const noRotateKeyboardNavigation = () => html`
|
|
191
|
+
<lion-combobox
|
|
192
|
+
name="combo"
|
|
193
|
+
label="No Rotate Keyboard Navigation"
|
|
194
|
+
.rotateKeyboardNavigation="${false}"
|
|
195
|
+
>
|
|
196
|
+
${lazyRender(
|
|
197
|
+
listboxData.map(entry => html` <lion-option .choiceValue="${entry}">${entry}</lion-option> `),
|
|
198
|
+
)}
|
|
199
|
+
</lion-combobox>
|
|
200
|
+
`;
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Multiple choice
|
|
204
|
+
|
|
205
|
+
Add `multiple-choice` flag to allow multiple values to be selected.
|
|
206
|
+
This will:
|
|
207
|
+
|
|
208
|
+
- keep the listbox overlay open on click of an option
|
|
209
|
+
- display a list of selected option representations next to the text box
|
|
210
|
+
- make the value of type `Array` instead of `String`
|
|
211
|
+
|
|
212
|
+
> Please note that the lion-combobox-selection-display below is not exposed and only serves
|
|
213
|
+
> as an example. The selection part of a multiselect combobox is not yet accessible. Please keep
|
|
214
|
+
> in mind that for now, as a Subclasser, you would have to take care of this part yourself.
|
|
215
|
+
|
|
216
|
+
```js preview-story
|
|
217
|
+
export const multipleChoice = () => html`
|
|
218
|
+
<lion-combobox name="combo" label="Multiple" multiple-choice>
|
|
219
|
+
<demo-selection-display
|
|
220
|
+
slot="selection-display"
|
|
221
|
+
style="display: contents;"
|
|
222
|
+
></demo-selection-display>
|
|
223
|
+
${lazyRender(
|
|
224
|
+
listboxData.map(
|
|
225
|
+
(entry, i) =>
|
|
226
|
+
html` <lion-option .choiceValue="${entry}" ?checked=${i === 0}>${entry}</lion-option> `,
|
|
227
|
+
),
|
|
228
|
+
)}
|
|
229
|
+
</lion-combobox>
|
|
230
|
+
`;
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## Invoker button
|
|
234
|
+
|
|
235
|
+
```js preview-story
|
|
236
|
+
export const invokerButton = () => html`
|
|
237
|
+
<lion-combobox
|
|
238
|
+
.modelValue="${listboxData[1]}"
|
|
239
|
+
autocomplete="none"
|
|
240
|
+
name="combo"
|
|
241
|
+
label="Invoker Button"
|
|
242
|
+
@click="${({ currentTarget: el }) => {
|
|
243
|
+
el.opened = !el.opened;
|
|
244
|
+
}}"
|
|
245
|
+
>
|
|
246
|
+
<button slot="suffix" type="button" tabindex="-1">▼</button>
|
|
247
|
+
${lazyRender(
|
|
248
|
+
listboxData.map(entry => html` <lion-option .choiceValue="${entry}">${entry}</lion-option> `),
|
|
249
|
+
)}
|
|
250
|
+
</lion-combobox>
|
|
251
|
+
`;
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## Server interaction
|
|
255
|
+
|
|
256
|
+
It's possible to fetch data from server side. When options are rerendered into the combobox,
|
|
257
|
+
the autocompletion (highlighting/selecting etc.) functionality of the combobox is triggered.
|
|
258
|
+
|
|
259
|
+
```js preview-story
|
|
260
|
+
const comboboxData = ['lorem', 'ipsum', 'dolor', 'sit', 'amet'];
|
|
261
|
+
let rejectPrev;
|
|
262
|
+
/**
|
|
263
|
+
* @param {string} val
|
|
264
|
+
*/
|
|
265
|
+
function fetchMyData(val) {
|
|
266
|
+
if (rejectPrev) {
|
|
267
|
+
rejectPrev();
|
|
268
|
+
}
|
|
269
|
+
const results = listboxData.filter(item => item.toLowerCase().includes(val.toLowerCase()));
|
|
270
|
+
return new Promise((resolve, reject) => {
|
|
271
|
+
rejectPrev = reject;
|
|
272
|
+
setTimeout(() => {
|
|
273
|
+
resolve(results);
|
|
274
|
+
}, 1000);
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
class DemoServerSide extends LitElement {
|
|
278
|
+
static get properties() {
|
|
279
|
+
return { options: { type: Array } };
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
constructor() {
|
|
283
|
+
super();
|
|
284
|
+
/** @type {string[]} */
|
|
285
|
+
this.options = [];
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
get combobox() {
|
|
289
|
+
return /** @type {LionCombobox} */ (this.shadowRoot?.querySelector('#combobox'));
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* @param {InputEvent & {target: HTMLInputElement}} e
|
|
294
|
+
*/
|
|
295
|
+
async fetchMyDataAndRender(e) {
|
|
296
|
+
this.loading = true;
|
|
297
|
+
this.requestUpdate();
|
|
298
|
+
try {
|
|
299
|
+
this.options = await fetchMyData(e.target.value);
|
|
300
|
+
this.loading = false;
|
|
301
|
+
this.requestUpdate();
|
|
302
|
+
} catch (_) {}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
render() {
|
|
306
|
+
return html`
|
|
307
|
+
<lion-combobox
|
|
308
|
+
.showAllOnEmpty="${true}"
|
|
309
|
+
id="combobox"
|
|
310
|
+
@input="${this.fetchMyDataAndRender}"
|
|
311
|
+
.helpText="Returned from server: [${this.options.join(', ')}]"
|
|
312
|
+
>
|
|
313
|
+
<label slot="label" aria-live="polite"
|
|
314
|
+
>Server side completion ${this.loading
|
|
315
|
+
? html`<span style="font-style: italic;">(loading...)</span>`
|
|
316
|
+
: ''}</label
|
|
317
|
+
>
|
|
318
|
+
${repeat(
|
|
319
|
+
this.options,
|
|
320
|
+
entry => entry,
|
|
321
|
+
entry => html` <lion-option .choiceValue="${entry}">${entry}</lion-option> `,
|
|
322
|
+
)}
|
|
323
|
+
</lion-combobox>
|
|
324
|
+
`;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
customElements.define('demo-server-side', DemoServerSide);
|
|
328
|
+
export const serverSideCompletion = () => html`<demo-server-side></demo-server-side>`;
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
## Set complex object in choiceValue
|
|
332
|
+
|
|
333
|
+
A common use case is to set a complex object in the `choiceValue` property. By default, `LionCombobox` will display in the text input the `modelValue`. By overriding the `_getTextboxValueFromOption` method, you can choose which value will be used for the input value.
|
|
334
|
+
|
|
335
|
+
```js preview-story
|
|
336
|
+
class ComplexObjectCombobox extends LionCombobox {
|
|
337
|
+
/**
|
|
338
|
+
* Override how the input text is filled
|
|
339
|
+
* @param {LionOption} option
|
|
340
|
+
* @returns {string}
|
|
341
|
+
*/
|
|
342
|
+
// eslint-disable-next-line class-methods-use-this
|
|
343
|
+
_getTextboxValueFromOption(option) {
|
|
344
|
+
return option.label;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
customElements.define('complex-object-combobox', ComplexObjectCombobox);
|
|
349
|
+
|
|
350
|
+
const onModelValueChanged = event => {
|
|
351
|
+
console.log(`event.target.modelValue: ${JSON.stringify(event.target.modelValue)}`);
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
const listboxDataObject = listboxData.map(e => {
|
|
355
|
+
return { label: e, name: e };
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
export const complexObjectChoiceValue = () => html` <complex-object-combobox
|
|
359
|
+
name="combo"
|
|
360
|
+
label="Display only the label once selected"
|
|
361
|
+
@model-value-changed="${onModelValueChanged}"
|
|
362
|
+
>
|
|
363
|
+
${lazyRender(
|
|
364
|
+
listboxDataObject.map(
|
|
365
|
+
entry =>
|
|
366
|
+
html`
|
|
367
|
+
<lion-option .choiceValue="${entry}" .label="${entry.label}">${entry.label}</lion-option>
|
|
368
|
+
`,
|
|
369
|
+
),
|
|
370
|
+
)}
|
|
371
|
+
</complex-object-combobox>`;
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
## Listbox compatibility
|
|
375
|
+
|
|
376
|
+
All configurations that can be applied to `lion-listbox`, can be applied to `lion-combobox` as well.
|
|
377
|
+
See the [listbox documentation](https://github.com/ing-bank/lion/blob/fbf0bd22378e76aa4261c2a97faf8be4f5fc461e/docs/components/listbox/overview.md) for more information.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Dialog >> Overview ||10
|
|
2
|
+
|
|
3
|
+
A web component that wraps a modal dialog controller.
|
|
4
|
+
Its purpose is to make it easy to use our Overlay System declaratively.
|
|
5
|
+
|
|
6
|
+
```js script
|
|
7
|
+
import { html } from '@mdjs/mdjs-preview';
|
|
8
|
+
import '@lion/ui/define/lion-dialog.js';
|
|
9
|
+
|
|
10
|
+
import { demoStyle } from './src/demoStyle.js';
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```js preview-story
|
|
14
|
+
export const main = () => html`
|
|
15
|
+
<style>
|
|
16
|
+
${demoStyle}
|
|
17
|
+
</style>
|
|
18
|
+
<lion-dialog>
|
|
19
|
+
<button slot="invoker">Click me to open dialog</button>
|
|
20
|
+
<div slot="content" class="dialog">
|
|
21
|
+
Hello! You can close this dialog here:
|
|
22
|
+
<button
|
|
23
|
+
class="close-button"
|
|
24
|
+
@click=${e => e.target.dispatchEvent(new Event('close-overlay', { bubbles: true }))}
|
|
25
|
+
>
|
|
26
|
+
⨯
|
|
27
|
+
</button>
|
|
28
|
+
</div>
|
|
29
|
+
</lion-dialog>
|
|
30
|
+
`;
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Features
|
|
34
|
+
|
|
35
|
+
- Show content when clicking the invoker
|
|
36
|
+
- Respond to close event in the slot="content" element, to close the content
|
|
37
|
+
- Have a `.config` object to set or update the OverlayController's configuration
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm i --save @lion/ui
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
import { LionDialog } from '@lion/ui/dialog.js';
|
|
47
|
+
// or
|
|
48
|
+
import '@lion/ui/define/lion-dialog.js';
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
- Your `slot="content"` node will be moved to the global overlay container during initialization.
|
|
52
|
+
After, your content node is no longer a child of `lion-dialog`.
|
|
53
|
+
If you still need to access it from the `lion-dialog` you can do so by using the `._overlayContentNode` property.
|
|
54
|
+
- To close the overlay from within the content node, you need to dispatch a `close-overlay` event that bubbles.
|
|
55
|
+
It has to be able to reach the content node.
|
|
56
|
+
- If you need to traverse shadow boundaries, you will have to add `composed: true` as well, although this is discouraged as a practice.
|
|
57
|
+
|
|
58
|
+
## Changing the configuration
|
|
59
|
+
|
|
60
|
+
You can use the `config` property on the dialog to change the configuration.
|
|
61
|
+
The documentation of the full config object can be found in the `lion/overlay` package or here in [Overlay System - Configuration](https://github.com/ing-bank/lion/blob/fbf0bd22378e76aa4261c2a97faf8be4f5fc461e/docs/fundamentals/systems/overlays/configuration.md).
|
|
62
|
+
|
|
63
|
+
The `config` property uses a setter to merge the passed configuration with the current, so you only **overwrite what you pass** when updating `config`.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
|
|
3
|
+
export const demoStyle = css`
|
|
4
|
+
.demo-box {
|
|
5
|
+
width: 200px;
|
|
6
|
+
background-color: white;
|
|
7
|
+
border-radius: 2px;
|
|
8
|
+
border: 1px solid grey;
|
|
9
|
+
padding: 8px;
|
|
10
|
+
}
|
|
11
|
+
.demo-box_placements {
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
margin-top: 20px;
|
|
15
|
+
}
|
|
16
|
+
lion-dialog {
|
|
17
|
+
display: block;
|
|
18
|
+
padding: 10px;
|
|
19
|
+
margin-bottom: 10px;
|
|
20
|
+
}
|
|
21
|
+
.close-button {
|
|
22
|
+
color: black;
|
|
23
|
+
font-size: 28px;
|
|
24
|
+
line-height: 28px;
|
|
25
|
+
}
|
|
26
|
+
.demo-box__column {
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
}
|
|
30
|
+
.demo-dialog--content {
|
|
31
|
+
display: block;
|
|
32
|
+
position: absolute;
|
|
33
|
+
font-size: 16px;
|
|
34
|
+
color: white;
|
|
35
|
+
background-color: black;
|
|
36
|
+
border-radius: 4px;
|
|
37
|
+
padding: 8px;
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
|
|
3
|
+
class SlotsDialogContent extends LitElement {
|
|
4
|
+
static get styles() {
|
|
5
|
+
return [
|
|
6
|
+
css`
|
|
7
|
+
:host {
|
|
8
|
+
background-color: #fff;
|
|
9
|
+
}
|
|
10
|
+
.actions {
|
|
11
|
+
border-top: 2px solid green;
|
|
12
|
+
}
|
|
13
|
+
`,
|
|
14
|
+
];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
_closeOverlay() {
|
|
18
|
+
this.dispatchEvent(new Event('close-overlay', { bubbles: true }));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
render() {
|
|
22
|
+
return html`
|
|
23
|
+
<p>This content contains an actions slot</p>
|
|
24
|
+
<div class="actions">
|
|
25
|
+
<slot name="actions"></slot>
|
|
26
|
+
</div>
|
|
27
|
+
<button class="close-button" @click=${this._closeOverlay}>⨯</button>
|
|
28
|
+
`;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
customElements.define('slots-dialog-content', SlotsDialogContent);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
|
|
3
|
+
class StyledDialogContent extends LitElement {
|
|
4
|
+
static get styles() {
|
|
5
|
+
return [
|
|
6
|
+
css`
|
|
7
|
+
:host {
|
|
8
|
+
background-color: #fff;
|
|
9
|
+
}
|
|
10
|
+
.nice {
|
|
11
|
+
font-weight: bold;
|
|
12
|
+
color: green;
|
|
13
|
+
}
|
|
14
|
+
.close-button {
|
|
15
|
+
color: black;
|
|
16
|
+
font-size: 28px;
|
|
17
|
+
line-height: 28px;
|
|
18
|
+
}
|
|
19
|
+
`,
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
_closeOverlay() {
|
|
24
|
+
this.dispatchEvent(new Event('close-overlay', { bubbles: true }));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
render() {
|
|
28
|
+
return html`
|
|
29
|
+
<div><p>Hello person who opened the dialog!</p></div>
|
|
30
|
+
<div>
|
|
31
|
+
<p>Look how nice this <span class="nice">dialog</span> looks!</p>
|
|
32
|
+
</div>
|
|
33
|
+
<button class="close-button" @click=${this._closeOverlay}>⨯</button>
|
|
34
|
+
`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
customElements.define('styled-dialog-content', StyledDialogContent);
|