@lion/ui 0.0.2 → 0.0.4
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/src/SlotMixin.js +180 -42
- package/components/core/test/SlotMixin.test.js +355 -145
- package/components/core/types/SlotMixinTypes.ts +12 -1
- package/components/input-tel/src/LionInputTel.js +0 -9
- package/components/input-tel-dropdown/src/LionInputTelDropdown.js +32 -29
- package/components/input-tel-dropdown/test-suites/LionInputTelDropdown.suite.js +5 -6
- package/components/localize/src/number/parseNumber.js +15 -36
- package/components/localize/test/number/parseNumber.test.js +3 -12
- package/components/localize/types/LocalizeMixinTypes.ts +1 -1
- package/custom-elements.json +1435 -133
- package/dist-types/components/calendar/src/LionCalendar.d.ts +1 -37
- package/dist-types/components/calendar/src/LionCalendar.d.ts.map +1 -1
- package/dist-types/components/core/src/SlotMixin.d.ts +2 -0
- package/dist-types/components/core/src/SlotMixin.d.ts.map +1 -1
- package/dist-types/components/core/test/SlotMixin.test.d.ts +1 -1
- package/dist-types/components/core/test/SlotMixin.test.d.ts.map +1 -1
- package/dist-types/components/core/types/SlotMixinTypes.d.ts +9 -1
- package/dist-types/components/core/types/SlotMixinTypes.d.ts.map +1 -1
- package/dist-types/components/input-amount/src/LionInputAmount.d.ts +1 -37
- package/dist-types/components/input-amount/src/LionInputAmount.d.ts.map +1 -1
- package/dist-types/components/input-date/src/LionInputDate.d.ts +1 -37
- package/dist-types/components/input-date/src/LionInputDate.d.ts.map +1 -1
- package/dist-types/components/input-datepicker/src/LionCalendarOverlayFrame.d.ts +1 -37
- package/dist-types/components/input-datepicker/src/LionCalendarOverlayFrame.d.ts.map +1 -1
- package/dist-types/components/input-email/src/LionInputEmail.d.ts +1 -37
- package/dist-types/components/input-email/src/LionInputEmail.d.ts.map +1 -1
- package/dist-types/components/input-iban/src/LionInputIban.d.ts +1 -37
- package/dist-types/components/input-iban/src/LionInputIban.d.ts.map +1 -1
- package/dist-types/components/input-tel/src/LionInputTel.d.ts +1 -42
- package/dist-types/components/input-tel/src/LionInputTel.d.ts.map +1 -1
- package/dist-types/components/input-tel-dropdown/src/LionInputTelDropdown.d.ts +14 -8
- package/dist-types/components/input-tel-dropdown/src/LionInputTelDropdown.d.ts.map +1 -1
- package/dist-types/components/input-tel-dropdown/test-suites/LionInputTelDropdown.suite.d.ts.map +1 -1
- package/dist-types/components/localize/src/LocalizeMixin.d.ts +1 -37
- package/dist-types/components/localize/src/LocalizeMixin.d.ts.map +1 -1
- package/dist-types/components/localize/src/number/parseNumber.d.ts.map +1 -1
- package/dist-types/components/localize/types/LocalizeMixinTypes.d.ts +1 -1
- package/dist-types/components/localize/types/LocalizeMixinTypes.d.ts.map +1 -1
- package/dist-types/components/pagination/src/LionPagination.d.ts +1 -37
- package/dist-types/components/pagination/src/LionPagination.d.ts.map +1 -1
- package/dist-types/components/progress-indicator/src/LionProgressIndicator.d.ts +1 -37
- package/dist-types/components/progress-indicator/src/LionProgressIndicator.d.ts.map +1 -1
- package/dist-types/exports/core.d.ts +1 -0
- package/dist-types/exports/core.d.ts.map +1 -1
- package/dist-types/exports/form-core.d.ts +2 -0
- package/dist-types/exports/form-core.d.ts.map +1 -1
- package/dist-types/exports/input-tel-dropdown.d.ts +2 -0
- package/dist-types/exports/input-tel-dropdown.d.ts.map +1 -1
- package/dist-types/exports/input-tel.d.ts +1 -0
- package/dist-types/exports/input-tel.d.ts.map +1 -1
- package/dist-types/exports/localize.d.ts +3 -0
- package/dist-types/exports/localize.d.ts.map +1 -1
- package/dist-types/exports/overlays.d.ts +4 -0
- package/dist-types/exports/overlays.d.ts.map +1 -1
- 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/core.js +2 -0
- package/exports/form-core.js +3 -0
- package/exports/input-tel-dropdown.js +3 -0
- package/exports/input-tel.js +2 -0
- package/exports/localize.js +4 -0
- package/exports/overlays.js +5 -0
- package/package.json +3 -2
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# How To >> Create a custom field ||20
|
|
2
|
+
|
|
3
|
+
```js script
|
|
4
|
+
import { html, css, LitElement } from '@mdjs/mdjs-preview';
|
|
5
|
+
import { LionField } from '@lion/ui/form-core.js';
|
|
6
|
+
import '@lion/ui/define/lion-field.js';
|
|
7
|
+
import '@lion/ui/define/lion-validation-feedback.js';
|
|
8
|
+
|
|
9
|
+
import '../../fundamentals/systems/form/assets/h-output.js';
|
|
10
|
+
|
|
11
|
+
// A) the custom [slot=input] or 'HTMLElementWithValue'
|
|
12
|
+
class DummySlider extends LitElement {
|
|
13
|
+
// A1) it should have a .value property of type 'string'
|
|
14
|
+
static properties = { value: String, reflect: true };
|
|
15
|
+
|
|
16
|
+
static styles = [
|
|
17
|
+
css`
|
|
18
|
+
:host {
|
|
19
|
+
display: block;
|
|
20
|
+
padding-top: 16px;
|
|
21
|
+
padding-bottom: 16px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
[part='rail'] {
|
|
25
|
+
position: relative;
|
|
26
|
+
display: block;
|
|
27
|
+
background: #eee;
|
|
28
|
+
height: 8px;
|
|
29
|
+
border-radius: 8px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
[part='thumb'] {
|
|
33
|
+
position: absolute;
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
font-size: 10px;
|
|
38
|
+
background: black;
|
|
39
|
+
color: white;
|
|
40
|
+
border-radius: 50%;
|
|
41
|
+
height: 24px;
|
|
42
|
+
width: 24px;
|
|
43
|
+
top: 50%;
|
|
44
|
+
transform: translateY(-50%);
|
|
45
|
+
transition: left 0.5s ease 0s;
|
|
46
|
+
}
|
|
47
|
+
`,
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
constructor() {
|
|
51
|
+
super();
|
|
52
|
+
this.value = '0';
|
|
53
|
+
this.addEventListener('click', ev => {
|
|
54
|
+
this.value = `${Math.round(
|
|
55
|
+
((ev.clientX - this.getClientRects()[0].x) / this.offsetWidth) * 5,
|
|
56
|
+
)}`;
|
|
57
|
+
// A2) it should have a way to tell LionField its value changed
|
|
58
|
+
this.dispatchEvent(new Event('dummy-slider-changed', { bubbles: true }));
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
connectedCallback() {
|
|
63
|
+
super.connectedCallback();
|
|
64
|
+
this.setAttribute('tabindex', 0);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
render() {
|
|
68
|
+
return html` <div part="rail">
|
|
69
|
+
<span part="thumb" style="left:${Number(this.value) * 20}%;">${this.value}</span>
|
|
70
|
+
</div>`;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (!customElements.get('dummy-slider')) {
|
|
74
|
+
customElements.define('dummy-slider', DummySlider);
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Custom Fields can be created in just a few steps. All you need is an interaction element (like for instance a slider, a listbox or a combobox) and connect it to the [LionField](https://github.com/ing-bank/lion/blob/edc6920a90aa7658358819e7c324daf6badf7d30/docs/components/input/overview.md).
|
|
79
|
+
|
|
80
|
+
> In case you want to extend a native element, follow [Extend a native Input](https://github.com/ing-bank/lion/blob/edc6920a90aa7658358819e7c324daf6badf7d30/docs/guides/how-to/extend-a-native-input.md).
|
|
81
|
+
|
|
82
|
+
## A) an interaction element
|
|
83
|
+
|
|
84
|
+
An interaction element (.\_inputNode) provides the means for the end user to enter a certain value,
|
|
85
|
+
just like native elements provide in this (think of input, textarea and select).
|
|
86
|
+
An example of a non native element is the [slider design pattern](https://www.w3.org/TR/wai-aria-practices-1.1/#slider) described here.
|
|
87
|
+
|
|
88
|
+
For this tutorial, we create a dummy component 'dummy-slider' that exposes its value via
|
|
89
|
+
property `.value` and sends an event `dummy-slider-changed` on every value change.
|
|
90
|
+
To make it focusable, it has a tabindex=“0” applied.
|
|
91
|
+
|
|
92
|
+
```js preview-story
|
|
93
|
+
export const createAnInteractiveElement = () => {
|
|
94
|
+
// A) the custom [slot=input] or 'HTMLElementWithValue'
|
|
95
|
+
class DummySlider extends LitElement {
|
|
96
|
+
// A1) it should have a .value property of type 'string'
|
|
97
|
+
static properties = { value: String };
|
|
98
|
+
|
|
99
|
+
constructor() {
|
|
100
|
+
super();
|
|
101
|
+
this.value = 0;
|
|
102
|
+
this.addEventListener('click', ev => {
|
|
103
|
+
this.value = `${Math.round(
|
|
104
|
+
((ev.clientX - this.getClientRects()[0].x) / this.offsetWidth) * 5,
|
|
105
|
+
)}`;
|
|
106
|
+
// A2) it should have a way to tell LionField its value changed
|
|
107
|
+
this.dispatchEvent(new Event('dummy-slider-changed', { bubbles: true }));
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
connectedCallback() {
|
|
112
|
+
super.connectedCallback();
|
|
113
|
+
this.setAttribute('tabindex', 0);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
render() {
|
|
117
|
+
return html` <div part="rail">
|
|
118
|
+
<span part="thumb" style="left:${Number(this.value) * 20}%;">${this.value}</span>
|
|
119
|
+
</div>`;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return html`<dummy-slider></dummy-slider>`;
|
|
123
|
+
};
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## B) your LionField extension
|
|
127
|
+
|
|
128
|
+
Now we want to integrate the slider in our form system to enrich the user interface, get
|
|
129
|
+
validation support and all other [benefits of LionField](https://github.com/ing-bank/lion/blob/edc6920a90aa7658358819e7c324daf6badf7d30/docs/components/input/overview.md).
|
|
130
|
+
We start by creating a component `<slider-field>` that extends from `LionField`.
|
|
131
|
+
Then we follow the steps below:
|
|
132
|
+
|
|
133
|
+
- **Add your interaction element**
|
|
134
|
+
|
|
135
|
+
Here you return the element the user interacts with. By configuring it as a slot, it will end up in
|
|
136
|
+
light DOM, ensuring the best accessibility for the end user.
|
|
137
|
+
|
|
138
|
+
- **Connect modelValue**
|
|
139
|
+
|
|
140
|
+
The `user-input-changed` event is listened to by the FormatMixin: it should be regarded as the
|
|
141
|
+
equivalent of the `input` event of the platform, but for custom built interaction elements.
|
|
142
|
+
You now synchronized [modelValue](https://github.com/ing-bank/lion/blob/edc6920a90aa7658358819e7c324daf6badf7d30/docs/fundamentals/systems/form/model-value.md), which can be regarded as
|
|
143
|
+
the glue to integrate all other functionality like parsing/formatting/serializing, validating,
|
|
144
|
+
tracking interaction states etc.
|
|
145
|
+
|
|
146
|
+
> N.B. Make sure you never override other property getters than the one mentioned in this tutorial,
|
|
147
|
+
> because those properties will loose their reactivity (they won't be considered anymore in the
|
|
148
|
+
> update loop of LitElement).
|
|
149
|
+
> Whenever a .modelValue/.formattedValue/.serializedValue needs to be computed, use
|
|
150
|
+
> [parser/formatter/serializer](https://github.com/ing-bank/lion/blob/edc6920a90aa7658358819e7c324daf6badf7d30/docs/fundamentals/systems/form/formatting-and-parsing.md)
|
|
151
|
+
|
|
152
|
+
Implement with the following code:
|
|
153
|
+
|
|
154
|
+
```js preview-story
|
|
155
|
+
export const createAField = () => {
|
|
156
|
+
// B) your extension with all the Field goodness...
|
|
157
|
+
class SliderField extends LionField {
|
|
158
|
+
// B1) Add your interaction element as ‘input slot'
|
|
159
|
+
get slots() {
|
|
160
|
+
return {
|
|
161
|
+
...super.slots,
|
|
162
|
+
input: () => document.createElement('dummy-slider'),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// B2) Connect modelValue
|
|
167
|
+
constructor() {
|
|
168
|
+
super();
|
|
169
|
+
this.addEventListener('dummy-slider-changed', ev => {
|
|
170
|
+
ev.stopPropagation();
|
|
171
|
+
this.dispatchEvent(new Event('user-input-changed'));
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
get value() {
|
|
176
|
+
// Remember we should always return type 'string' here
|
|
177
|
+
return this._inputNode.value;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
set value(newV) {
|
|
181
|
+
this._inputNode.value = newV;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
customElements.define('slider-field', SliderField);
|
|
185
|
+
|
|
186
|
+
return html`<slider-field
|
|
187
|
+
label="SliderField"
|
|
188
|
+
help-text="Press to see how modelValue is synchronized"
|
|
189
|
+
></slider-field>
|
|
190
|
+
<h-output .show="${['modelValue', 'touched', 'dirty', 'focused']}"></h-output>`;
|
|
191
|
+
};
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
That was all!
|
|
195
|
+
Now that your .modelValue is connected your component is fully compatible with our form system
|
|
196
|
+
|
|
197
|
+
> Is your `.modelValue` still undefined? Please make sure you're `.value` is of type 'string'.
|
|
198
|
+
|
|
199
|
+
Now you can enhance your slider by writing custom Validators for it or by
|
|
200
|
+
writing a parser to get a custom modelValue type.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# How To >> Extend a native Input ||20
|
|
2
|
+
|
|
3
|
+
```js script
|
|
4
|
+
import { html } from '@mdjs/mdjs-preview';
|
|
5
|
+
import { LionInput } from '@lion/ui/input.js';
|
|
6
|
+
import { LionInputDate } from '@lion/ui/input-date.js';
|
|
7
|
+
import { loadDefaultFeedbackMessages } from '@lion/ui/validate-messages.js';
|
|
8
|
+
import '@lion/ui/define/lion-input.js';
|
|
9
|
+
import '../../fundamentals/systems/form/assets/h-output.js';
|
|
10
|
+
|
|
11
|
+
loadDefaultFeedbackMessages();
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Input fields can be created by extending [LionInput](https://github.com/ing-bank/lion/blob/edc6920a90aa7658358819e7c324daf6badf7d30/docs/components/input/overview.md).
|
|
15
|
+
|
|
16
|
+
> In case you want to wrap a custom form element, follow [Create a custom Field](https://github.com/ing-bank/lion/blob/edc6920a90aa7658358819e7c324daf6badf7d30/docs/guides/how-to/create-a-custom-field.md).
|
|
17
|
+
|
|
18
|
+
For this tutorial, we create an input that wraps native `input[type=datetime-local]`.
|
|
19
|
+
This is as simple as adding a type:
|
|
20
|
+
|
|
21
|
+
```js preview-story
|
|
22
|
+
export const extendLionInput = () => {
|
|
23
|
+
class LionInputDatetime extends LionInput {
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
this.type = 'datetime-local';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
customElements.define('lion-input-datetime', LionInputDatetime);
|
|
30
|
+
|
|
31
|
+
return html`<lion-input-datetime label="With Date string"></lion-input-datetime>
|
|
32
|
+
<h-output .show="${['modelValue', 'touched', 'dirty', 'focused']}"></h-output>`;
|
|
33
|
+
};
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
However, we might want to have a more advanced modelValue. In the example above, our modelValue is
|
|
37
|
+
a serialized datetime string.
|
|
38
|
+
If we want our modelValue to be of type Date, we should do the following:
|
|
39
|
+
|
|
40
|
+
```js preview-story
|
|
41
|
+
export const extendLionInputDate = () => {
|
|
42
|
+
function toIsoDatetime(d) {
|
|
43
|
+
return d && new Date(d.getTime() - d.getTimezoneOffset() * 60000).toISOString().split('.')[0];
|
|
44
|
+
}
|
|
45
|
+
function fromIsoDatetime(value) {
|
|
46
|
+
return new Date(value);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
class LionInputDatetimeWithObject extends LionInputDate {
|
|
50
|
+
constructor() {
|
|
51
|
+
super();
|
|
52
|
+
this.type = 'datetime-local';
|
|
53
|
+
this.parser = fromIsoDatetime;
|
|
54
|
+
this.deserializer = fromIsoDatetime;
|
|
55
|
+
this.serializer = toIsoDatetime;
|
|
56
|
+
this.formatter = toIsoDatetime;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
customElements.define('lion-input-datetime-with-object', LionInputDatetimeWithObject);
|
|
60
|
+
|
|
61
|
+
return html`<lion-input-datetime-with-object
|
|
62
|
+
label="With Date object"
|
|
63
|
+
></lion-input-datetime-with-object>
|
|
64
|
+
<h-output .show="${['modelValue', 'touched', 'dirty', 'focused']}"></h-output>`;
|
|
65
|
+
};
|
|
66
|
+
```
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# How To >> Get Started ||10
|
|
2
|
+
|
|
3
|
+
## Technologies Used
|
|
4
|
+
|
|
5
|
+
Lion Web Components aims to be future proof and use well-supported proven technology. The stack we have chosen should reflect this.
|
|
6
|
+
|
|
7
|
+
Checkout the documentation of our main stack.
|
|
8
|
+
|
|
9
|
+
- [lit](https://lit.dev/) - Building on top of the Web Components standards, Lit adds just what you need to be happy and productive: reactivity, declarative templates and a handful of thoughtful features to reduce boilerplate and make your job easier.
|
|
10
|
+
- [modern-web](https://modern-web.dev) - Guides, tools and libraries for modern web development.
|
|
11
|
+
- [open-wc](https://open-wc.org) - Open Web Components provides guides, tools and libraries for developing web components.
|
|
12
|
+
|
|
13
|
+
## How to get started
|
|
14
|
+
|
|
15
|
+
Make sure you have `npm`, if you don't have it yet: [get npm](https://www.npmjs.com/get-npm).
|
|
16
|
+
|
|
17
|
+
And create a repo, we suggest to use [the generator from open-wc](https://open-wc.org/docs/development/generator/):
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm init @open-wc
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Install lion packages
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm i @lion/<package-name>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Extend a Web Component
|
|
30
|
+
|
|
31
|
+
**This is the main use case for lion**. To import component classes, and extend them for your own design system's components.
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
import { css } from 'lit';
|
|
35
|
+
import { LionInput } from '@lion/ui/input.js';
|
|
36
|
+
|
|
37
|
+
class MyInput extends LionInput {
|
|
38
|
+
static get styles() {
|
|
39
|
+
return [
|
|
40
|
+
...super.styles,
|
|
41
|
+
css`
|
|
42
|
+
/* your styles here */
|
|
43
|
+
`,
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
customElements.define('my-input', MyInput);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Use a JavaScript system
|
|
51
|
+
|
|
52
|
+
There's a couple of "systems" in lion which have a JavaScript API. Examples are `localize`, `overlays`, `ajax`, etc.
|
|
53
|
+
|
|
54
|
+
```html
|
|
55
|
+
<script type="module">
|
|
56
|
+
import { ajax } from '@lion/ajax';
|
|
57
|
+
|
|
58
|
+
ajax
|
|
59
|
+
.fetch('data.json')
|
|
60
|
+
.then(response => response.json())
|
|
61
|
+
.then(data => {
|
|
62
|
+
// do something with the data
|
|
63
|
+
});
|
|
64
|
+
</script>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Use a Web Component
|
|
68
|
+
|
|
69
|
+
You can also use the lion elements directly, although this is likely not a common use case.
|
|
70
|
+
|
|
71
|
+
```html
|
|
72
|
+
<script type="module">
|
|
73
|
+
import '@lion/ui/define/lion-input.js';
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<lion-input name="firstName" label="First name"></lion-input>
|
|
77
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# How To ||20
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Guides ||30
|
|
2
|
+
|
|
3
|
+
Lion is a set of white label Web Components that can be extended to your own styled layer of components.
|
|
4
|
+
|
|
5
|
+
We know from experience that making high quality, accessible UI components is hard and time consuming: it takes many iterations, a lot of development time and a lot of testing to get a generic component that works in every context, supports many edge cases and is accessible in all relevant screen readers.
|
|
6
|
+
|
|
7
|
+
Lion aims to do the heavy lifting for you. This means you only have to apply your own Design System: by delivering styles, configuring components and adding a minimal set of custom logic on top.
|
|
8
|
+
|
|
9
|
+
## Consuming Developer
|
|
10
|
+
|
|
11
|
+
Developers consuming our web components inside an application (not extending them).
|
|
12
|
+
`Application Developers` are only allowed to interact with `public` properties and methods.
|
|
13
|
+
Can be abbreviated as `AD`. Sometimes also called `Consuming Developer`.
|
|
14
|
+
|
|
15
|
+
- [Definitions and Terms](https://github.com/ing-bank/lion/blob/edc6920a90aa7658358819e7c324daf6badf7d30/docs/guides/principles/definitions-and-terms.md)
|
|
16
|
+
- [Styling](https://github.com/ing-bank/lion/blob/edc6920a90aa7658358819e7c324daf6badf7d30/docs/guides/principles/styling.md)
|
|
17
|
+
- [Scoped Elements](https://github.com/ing-bank/lion/blob/edc6920a90aa7658358819e7c324daf6badf7d30/docs/guides/principles/scoped-elements.md)
|
|
18
|
+
|
|
19
|
+
## Extending Developer
|
|
20
|
+
|
|
21
|
+
Developers extending our web components, for instance: `class MaterialInput extends LionInput` are called `subclassers`. Subclassers have access to protected methods (prefixed with an underscore or marked as protected), but not to private methods.
|
|
22
|
+
|
|
23
|
+
Especially for subclassers we have some extra documentation:
|
|
24
|
+
|
|
25
|
+
- [Subclasser APIs](https://github.com/ing-bank/lion/blob/edc6920a90aa7658358819e7c324daf6badf7d30/docs/guides/principles/subclasser-apis.md)
|
|
26
|
+
- [Extend documentation](https://github.com/ing-bank/lion/blob/edc6920a90aa7658358819e7c324daf6badf7d30/docs/blog/extending-documentation.md)
|
|
27
|
+
|
|
28
|
+
## How To
|
|
29
|
+
|
|
30
|
+
Next to that we have some specific "How To" documentations.
|
|
31
|
+
|
|
32
|
+
- [Get started](https://github.com/ing-bank/lion/blob/edc6920a90aa7658358819e7c324daf6badf7d30/docs/guides/how-to/get-started.md)
|
|
33
|
+
- [Create a custom field](https://github.com/ing-bank/lion/blob/edc6920a90aa7658358819e7c324daf6badf7d30/docs/guides/how-to/create-a-custom-field.md)
|
|
34
|
+
- [Extend a native input](https://github.com/ing-bank/lion/blob/edc6920a90aa7658358819e7c324daf6badf7d30/docs/guides/how-to/extend-a-native-input.md)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Principles >> Definitions and Terms ||20
|
|
2
|
+
|
|
3
|
+
Below you will find a list of definitions and terms that will be used throughout our code
|
|
4
|
+
documentation.
|
|
5
|
+
|
|
6
|
+
## Public
|
|
7
|
+
|
|
8
|
+
Methods and properties are public when they are not prefixed by an underscore.
|
|
9
|
+
They can be used by Application Developers.
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
class SoccerPlayer {
|
|
13
|
+
kickBall() {
|
|
14
|
+
// Soccer player can kick a ball
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Protected
|
|
20
|
+
|
|
21
|
+
Methods and properties are protected when they contain one underscore or are explicitly marked as protected in the code. They can be used by Subclassers.
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
class SoccerPlayer {
|
|
25
|
+
_catchBall() {
|
|
26
|
+
// Soccer player usually does not need to catch a ball (with their hands)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Private
|
|
32
|
+
|
|
33
|
+
Methods and properties are private when they contain two underscores or are explicitly marked as private in the code. They can be only used within the class where they are defined (developers of Lion components).
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
class SoccerPlayer {
|
|
37
|
+
__score() {
|
|
38
|
+
// internally save how many goals have been made
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Principles ||10
|
|
2
|
+
|
|
3
|
+
Lion is a set of white label Web Components that can be extended to your own styled layer of components.
|
|
4
|
+
|
|
5
|
+
We know from experience that making high quality, accessible UI components is hard and time consuming: it takes many iterations, a lot of development time and a lot of testing to get a generic component that works in every context, supports many edge cases and is accessible in all relevant screen readers.
|
|
6
|
+
|
|
7
|
+
Lion aims to do the heavy lifting for you. This means you only have to apply your own Design System: by delivering styles, configuring components and adding a minimal set of custom logic on top.
|
|
8
|
+
|
|
9
|
+
## Consuming Developer
|
|
10
|
+
|
|
11
|
+
Developers consuming our web components inside an application (not extending them).
|
|
12
|
+
`Application Developers` are only allowed to interact with `public` properties and methods.
|
|
13
|
+
Can be abbreviated as `AD`. Sometimes also called `Consuming Developer`.
|
|
14
|
+
|
|
15
|
+
- [Definitions and Terms](https://github.com/ing-bank/lion/blob/edc6920a90aa7658358819e7c324daf6badf7d30/docs/guides/principles/definitions-and-terms.md)
|
|
16
|
+
- [Styling](https://github.com/ing-bank/lion/blob/edc6920a90aa7658358819e7c324daf6badf7d30/docs/guides/principles/styling.md)
|
|
17
|
+
- [Scoped Elements](https://github.com/ing-bank/lion/blob/edc6920a90aa7658358819e7c324daf6badf7d30/docs/guides/principles/scoped-elements.md)
|
|
18
|
+
|
|
19
|
+
## Extending Developer
|
|
20
|
+
|
|
21
|
+
Developers extending our web components, for instance: `class MaterialInput extends LionInput` are called `subclassers`. Subclassers have access to protected methods (prefixed with an underscore or marked as protected), but not to private methods.
|
|
22
|
+
|
|
23
|
+
Especially for subclassers we have some extra documentation:
|
|
24
|
+
|
|
25
|
+
- [Subclasser APIs](https://github.com/ing-bank/lion/blob/edc6920a90aa7658358819e7c324daf6badf7d30/docs/guides/principles/subclasser-apis.md)
|
|
26
|
+
- [Extend documentation](https://github.com/ing-bank/lion/blob/edc6920a90aa7658358819e7c324daf6badf7d30/docs/blog/extending-documentation.md)
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Principles >> Scoped Elements ||40
|
|
2
|
+
|
|
3
|
+
The [CustomElementRegistry](https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry) provides methods for registering custom elements. One of the limitations of working with this global registry is that multiple versions of the same element cannot co-exist. This causes bottlenecks in software delivery that should be managed by the teams and complex build systems. [Scoped Custom Element Registries](https://github.com/w3c/webcomponents/issues/716) is a proposal that will solve the problem. Since this functionality won't be available (especially not cross browser) anytime soon, we've adopted [OpenWC's Scoped Elements](https://open-wc.org/docs/development/scoped-elements/).
|
|
4
|
+
|
|
5
|
+
Whenever a lion component uses composition (meaning it uses another lion component inside), we
|
|
6
|
+
apply ScopedElementsMixin to make sure it uses the right version of this internal component.
|
|
7
|
+
|
|
8
|
+
```js
|
|
9
|
+
import { LitElement, html } from '@lion/ui/core.js';
|
|
10
|
+
import { ScopedElementsMixin, LitElement, html } from '@open-wc/scoped-elements';
|
|
11
|
+
|
|
12
|
+
import { LionInput } from '@lion/ui/input.js';
|
|
13
|
+
import { LionButton } from '@lion/ui/button.js';
|
|
14
|
+
|
|
15
|
+
class MyElement extends ScopedElementsMixin(LitElement) {
|
|
16
|
+
static get scopedElements() {
|
|
17
|
+
return {
|
|
18
|
+
'lion-input': LionInput,
|
|
19
|
+
'lion-button': LionButton,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
render() {
|
|
24
|
+
return html`
|
|
25
|
+
<lion-input label="Greeting" name="greeting" .modelValue=${'Hello world'}></lion-input>
|
|
26
|
+
<lion-button>Save</lion-button>
|
|
27
|
+
`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Query selectors
|
|
33
|
+
|
|
34
|
+
Since Scoped Elements changes tagnames under the hood, a tagname querySelector should be written like this:
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
this.querySelector(
|
|
38
|
+
this.constructor.getScopedTagName('lion-input', this.constructor.scopedElements),
|
|
39
|
+
);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## CSS selectors
|
|
43
|
+
|
|
44
|
+
Avoid tagname css selectors.
|
|
45
|
+
We already avoid query selectors internally in lion, but just be aware that a selector like
|
|
46
|
+
|
|
47
|
+
```css
|
|
48
|
+
lion-input {
|
|
49
|
+
padding: 20px;
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
will stop working.
|
|
54
|
+
|
|
55
|
+
## Edge cases
|
|
56
|
+
|
|
57
|
+
Sometimes we need to render parts of a template to light dom for [accessibility](https://wicg.github.io/aom/explainer.html). For instance we render a node via `lit-html` that we append to the host element, so it gets slotted in the right position.
|
|
58
|
+
In this case, we should also make sure that we also scope the rendered element.
|
|
59
|
+
|
|
60
|
+
We can do this as follows:
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
_myLightTemplate() {
|
|
64
|
+
return html`
|
|
65
|
+
This template may be overridden by a Subclasser.
|
|
66
|
+
Even I don't end up in shadow root, I need to be scoped to constructor.scopedElements as well.
|
|
67
|
+
<div>
|
|
68
|
+
<lion-button>True</lion-button>
|
|
69
|
+
<lion-input label="xyz"></lion-input>
|
|
70
|
+
</div>
|
|
71
|
+
`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
__getLightDomNode() {
|
|
75
|
+
const renderParent = document.createElement('div');
|
|
76
|
+
this.constructor.render(this._myLightTemplate(), renderParent, {
|
|
77
|
+
scopeName: this.localName,
|
|
78
|
+
eventContext: this,
|
|
79
|
+
});
|
|
80
|
+
// this node will be appended to the host
|
|
81
|
+
return renderParent.firstElementChild;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
connectedCallback() {
|
|
85
|
+
super.connectedCallback();
|
|
86
|
+
this.appendChild(this.__getLightDomNode());
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
In a less complex case, we might just want to add a child node to the dom.
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
import { LitElement } from 'lit';
|
|
94
|
+
import { ScopedElementsMixin, getScopedTagName } from '@open-wc/scoped-elements';
|
|
95
|
+
|
|
96
|
+
...
|
|
97
|
+
|
|
98
|
+
__getLightDomNode() {
|
|
99
|
+
return document.createElement(getScopedTagName('lion-input', this.constructor.scopedElements));
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
We encourage you to have a look at [OpenWC's Scoped elements](https://open-wc.org/docs/development/scoped-elements/).
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Principles >> Styling ||30
|
|
2
|
+
|
|
3
|
+
## Markup and styling
|
|
4
|
+
|
|
5
|
+
All Lion web components have white label styling: this means theming is not applied,
|
|
6
|
+
but functional styling is.
|
|
7
|
+
|
|
8
|
+
### Functional styling
|
|
9
|
+
|
|
10
|
+
Functional styling can be divided into defaults for `basic layout` and `accessibility`.
|
|
11
|
+
Examples for both categories can be found below:
|
|
12
|
+
|
|
13
|
+
- Basic layout examples:
|
|
14
|
+
|
|
15
|
+
- A dropdown menu has `position: absolute;`.
|
|
16
|
+
- A lion-button might behave as an `display: inline-block;` element.
|
|
17
|
+
- A suffix attached to an input is horizontally positioned (instead of vertically stacked).
|
|
18
|
+
|
|
19
|
+
- Accessibility examples:
|
|
20
|
+
- Content (for instance a caption in a table) can be `visually hidden`: it will be
|
|
21
|
+
readable by screen readers, but invisible for end users.
|
|
22
|
+
- When an html table is used, we allow [subclassers](https://github.com/ing-bank/lion/blob/edc6920a90aa7658358819e7c324daf6badf7d30/docs/guides/principles/subclasser-apis.md) to override the display property (`table-cell`) to `flex`. By putting the proper accessible roles (`role="cell"`) in the markup, we guarantee our markup stays accessible.
|
|
23
|
+
|
|
24
|
+
Although Lion components try to stay as unbiased as possible with regard to styling, defaults will be needed. In these cases we try to follow the platform as much as possible. If the platform doesn't provide defaults, the largest common denominator across existing UI systems is taken as a lead.
|
|
25
|
+
|
|
26
|
+
## CSS variables
|
|
27
|
+
|
|
28
|
+
Css variables will not be added in our white label style components, but adding them in your own extension layer would be a perfect fit.
|
|
29
|
+
|
|
30
|
+
## Parts and themes
|
|
31
|
+
|
|
32
|
+
The `::part` and `::theme` specs might currently not be widely adopted enough to be used inside style components. When they are, we could be consider to add them later to our components as a means to theme components (changing a whole Design System is not a good idea).
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Principles >> Subclasser apis ||50
|
|
2
|
+
|
|
3
|
+
In order to make it easy for Subclassers to extend our components, we follow a certain set
|
|
4
|
+
of best practices naming conventions to make our code predictable.
|
|
5
|
+
|
|
6
|
+
## Templates
|
|
7
|
+
|
|
8
|
+
### Template naming conventions
|
|
9
|
+
|
|
10
|
+
For templates that do need access to the instance of the web component there is a prefix `_render/__render`.
|
|
11
|
+
Examples are `__renderHeader` and `__renderData`.
|
|
12
|
+
|
|
13
|
+
### Separation of concerns
|
|
14
|
+
|
|
15
|
+
Our components should make it possible to override markup and styling, without having to redefine
|
|
16
|
+
functionality.
|
|
17
|
+
By using the spread directive, we can achieve this. For more info, see [explanation](https://github.com/ing-bank/lion/issues/591).
|
|
18
|
+
|
|
19
|
+
## Node references
|
|
20
|
+
|
|
21
|
+
As a Subclasser, you sometimes need access to a protected node inside the shadow dom.
|
|
22
|
+
Most functional nodes have their own getters. A Subclasser can access those in his extension and
|
|
23
|
+
in some cases, override these getters.
|
|
24
|
+
|
|
25
|
+
### Node naming conventions
|
|
26
|
+
|
|
27
|
+
A node reference will have an underscore prefix and always ends with `Node`.
|
|
28
|
+
Examples are `_inputNode` and `_formNode`.
|
package/docs/override.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This will override all md files within the folder to only contain [=> See Source <=](../path/to/source.md)
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { writeFile } from 'fs/promises';
|
|
6
|
+
import glob from 'glob';
|
|
7
|
+
|
|
8
|
+
const allFiles = glob.sync('**/*.md', { nodir: true });
|
|
9
|
+
const files = allFiles;
|
|
10
|
+
|
|
11
|
+
for (const filePath of files) {
|
|
12
|
+
const insert = 3 + filePath.match(/\//g).length;
|
|
13
|
+
const srcPath = `${'../'.repeat(insert)}docs/${filePath}`;
|
|
14
|
+
await writeFile(filePath, `[=> See Source <=](${srcPath})`);
|
|
15
|
+
}
|
package/exports/core.js
CHANGED
|
@@ -5,3 +5,5 @@ export { SlotMixin } from '../components/core/src/SlotMixin.js';
|
|
|
5
5
|
export { browserDetection } from '../components/core/src/browserDetection.js';
|
|
6
6
|
export { EventTargetShim } from '../components/core/src/EventTargetShim.js';
|
|
7
7
|
export { uuid } from '../components/core/src/uuid.js';
|
|
8
|
+
|
|
9
|
+
/** @typedef {import('../components/core/types/SlotMixinTypes.js').SlotHost} SlotHost */
|
package/exports/form-core.js
CHANGED
|
@@ -51,3 +51,6 @@ export { ChoiceGroupMixin } from '../components/form-core/src/choice-group/Choic
|
|
|
51
51
|
export { ChoiceInputMixin } from '../components/form-core/src/choice-group/ChoiceInputMixin.js';
|
|
52
52
|
|
|
53
53
|
export { FormGroupMixin } from '../components/form-core/src/form-group/FormGroupMixin.js';
|
|
54
|
+
|
|
55
|
+
/** @typedef {import('../components/form-core/types/FormControlMixinTypes.js').FormControlHost} FormControlHost */
|
|
56
|
+
/** @typedef {import('../components/form-core/types/validate/ValidateMixinTypes.js').ValidateHost} ValidateHost */
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export { getFlagSymbol } from '../components/input-tel-dropdown/src/getFlagSymbol.js';
|
|
2
2
|
export { LionInputTelDropdown } from '../components/input-tel-dropdown/src/LionInputTelDropdown.js';
|
|
3
|
+
|
|
4
|
+
/** @typedef {import('../components/input-tel-dropdown/types/index.js').RegionMeta} RegionMeta */
|
|
5
|
+
/** @typedef {import('../components/input-tel-dropdown/types/index.js').TemplateDataForDropdownInputTel} TemplateDataForDropdownInputTel */
|
package/exports/input-tel.js
CHANGED
|
@@ -3,3 +3,5 @@ export { LionInputTel } from '../components/input-tel/src/LionInputTel.js';
|
|
|
3
3
|
export { PhoneNumber } from '../components/input-tel/src/validators.js';
|
|
4
4
|
export { PhoneUtilManager } from '../components/input-tel/src/PhoneUtilManager.js';
|
|
5
5
|
export { liveFormatPhoneNumber } from '../components/input-tel/src/preprocessors.js';
|
|
6
|
+
|
|
7
|
+
/** @typedef {import('../components/input-tel/types/index.js').RegionCode} RegionCode */
|
package/exports/localize.js
CHANGED
|
@@ -19,3 +19,7 @@ export { parseNumber } from '../components/localize/src/number/parseNumber.js';
|
|
|
19
19
|
export { getLocale } from '../components/localize/src/utils/getLocale.js';
|
|
20
20
|
|
|
21
21
|
export { localize, setLocalize } from '../components/localize/src/singleton.js';
|
|
22
|
+
|
|
23
|
+
/** @typedef {import('../components/localize/types/LocalizeMixinTypes.js').FormatNumberOptions} FormatNumberOptions */
|
|
24
|
+
/** @typedef {import('../components/localize/types/LocalizeMixinTypes.js').FormatNumberPart} FormatNumberPart */
|
|
25
|
+
/** @typedef {import('../components/localize/types/LocalizeMixinTypes.js').LocalizeMixinHost } LocalizeMixinHost */
|