@lion/ui 0.2.2 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -72
- package/components/button/src/LionButton.js +1 -1
- package/components/checkbox-group/src/LionCheckboxIndeterminate.js +2 -2
- package/components/checkbox-group/test/lion-checkbox-indeterminate-integrations.test.js +6 -0
- package/components/checkbox-group/{test/lion-checkbox-indeterminate.test.js → test-suites/CheckboxIndeterminate.suite.js} +209 -187
- package/components/combobox/src/LionCombobox.js +3 -1
- package/components/combobox/test/lion-combobox.test.js +52 -0
- package/components/core/src/SlotMixin.js +3 -2
- package/components/core/test/SlotMixin.test.js +1 -1
- package/components/core/types/SlotMixinTypes.ts +4 -1
- package/components/dialog/test/lion-dialog.test.js +56 -0
- package/components/form-core/src/FocusMixin.js +33 -2
- package/components/form-core/src/LionField.js +3 -1
- package/components/form-core/src/validate/LionValidationFeedback.js +2 -5
- package/components/form-core/src/validate/ResultValidator.js +1 -1
- package/components/form-core/test/FocusMixin.test.js +33 -0
- package/components/form-core/types/validate/ValidateMixinTypes.ts +2 -2
- package/components/form-integrations/test/dialog-integrations.test.js +19 -0
- package/components/form-integrations/test/form-group-methods.test.js +11 -37
- package/components/form-integrations/test/form-integrations.test.js +4 -0
- package/components/form-integrations/test/helpers/umbrella-form.js +21 -18
- package/components/input-amount/src/LionInputAmount.js +13 -4
- package/components/input-amount/test/lion-input-amount.test.js +19 -20
- package/components/input-date/src/LionInputDate.js +2 -11
- package/components/input-datepicker/src/LionInputDatepicker.js +5 -2
- package/components/input-datepicker/test/lion-input-datepicker.test.js +20 -0
- package/components/input-file/src/FileHandle.js +98 -0
- package/components/input-file/src/LionInputFile.js +892 -0
- package/components/input-file/src/LionSelectedFileList.js +232 -0
- package/components/input-file/src/localizeNamespaceLoader.js +75 -0
- package/components/input-file/src/validators.js +114 -0
- package/components/input-file/test/FileValidators.test.js +170 -0
- package/components/input-file/test/lion-input-file.test.js +1168 -0
- package/components/input-file/test/lion-selected-file-list.test.js +207 -0
- package/components/input-file/translations/bg-BG.js +5 -0
- package/components/input-file/translations/bg.js +12 -0
- package/components/input-file/translations/cs-CZ.js +5 -0
- package/components/input-file/translations/cs.js +13 -0
- package/components/input-file/translations/de-DE.js +5 -0
- package/components/input-file/translations/de.js +12 -0
- package/components/input-file/translations/en-AU.js +5 -0
- package/components/input-file/translations/en-GB.js +5 -0
- package/components/input-file/translations/en-PH.js +5 -0
- package/components/input-file/translations/en-US.js +5 -0
- package/components/input-file/translations/en.js +12 -0
- package/components/input-file/translations/es-ES.js +5 -0
- package/components/input-file/translations/es.js +12 -0
- package/components/input-file/translations/fr-BE.js +5 -0
- package/components/input-file/translations/fr-FR.js +5 -0
- package/components/input-file/translations/fr.js +13 -0
- package/components/input-file/translations/hu-HU.js +5 -0
- package/components/input-file/translations/hu.js +12 -0
- package/components/input-file/translations/it-IT.js +5 -0
- package/components/input-file/translations/it.js +12 -0
- package/components/input-file/translations/nl-BE.js +5 -0
- package/components/input-file/translations/nl-NL.js +5 -0
- package/components/input-file/translations/nl.js +12 -0
- package/components/input-file/translations/pl-PL.js +5 -0
- package/components/input-file/translations/pl.js +12 -0
- package/components/input-file/translations/ro-RO.js +5 -0
- package/components/input-file/translations/ro.js +12 -0
- package/components/input-file/translations/ru-RU.js +5 -0
- package/components/input-file/translations/ru.js +12 -0
- package/components/input-file/translations/sk-SK.js +5 -0
- package/components/input-file/translations/sk.js +12 -0
- package/components/input-file/translations/uk-UA.js +5 -0
- package/components/input-file/translations/uk.js +12 -0
- package/components/input-file/translations/zh-CN.js +5 -0
- package/components/input-file/translations/zh.js +12 -0
- package/components/input-file/types/input-file.d.ts +32 -0
- package/components/input-tel-dropdown/src/LionInputTelDropdown.js +1 -4
- package/components/listbox/src/ListboxMixin.js +3 -2
- package/components/listbox/test-suites/ListboxMixin.suite.js +31 -1
- package/components/localize/src/number/utils/normalize-format-number-to-parts/forceNoSpaceBetweenCurrencySymbolAndNumber.js +22 -0
- package/components/localize/src/number/utils/normalize-format-number-to-parts/forceSymbols.js +64 -0
- package/components/localize/src/number/utils/normalize-format-number-to-parts/normalizeIntl.js +13 -7
- package/components/localize/test/number/formatNumber.test.js +6 -28
- package/custom-elements.json +13822 -9246
- package/dist-types/components/checkbox-group/test-suites/CheckboxIndeterminate.suite.d.ts +12 -0
- package/dist-types/components/checkbox-group/test-suites/CheckboxIndeterminate.suite.d.ts.map +1 -0
- package/dist-types/components/combobox/src/LionCombobox.d.ts.map +1 -1
- package/dist-types/components/combobox/test/lion-combobox.test.d.ts.map +1 -1
- package/dist-types/components/core/src/SlotMixin.d.ts.map +1 -1
- package/dist-types/components/core/types/SlotMixinTypes.d.ts +4 -0
- package/dist-types/components/core/types/SlotMixinTypes.d.ts.map +1 -1
- package/dist-types/components/dialog/test/lion-dialog.test.d.ts.map +1 -1
- package/dist-types/components/form-core/src/FocusMixin.d.ts.map +1 -1
- package/dist-types/components/form-core/src/LionField.d.ts +2 -1
- package/dist-types/components/form-core/src/LionField.d.ts.map +1 -1
- package/dist-types/components/form-core/src/validate/LionValidationFeedback.d.ts +4 -11
- package/dist-types/components/form-core/src/validate/LionValidationFeedback.d.ts.map +1 -1
- package/dist-types/components/form-core/src/validate/ResultValidator.d.ts +1 -1
- package/dist-types/components/form-core/types/validate/ValidateMixinTypes.d.ts +5 -0
- package/dist-types/components/form-core/types/validate/ValidateMixinTypes.d.ts.map +1 -1
- package/dist-types/components/form-integrations/test/dialog-integrations.test.d.ts.map +1 -1
- package/dist-types/components/form-integrations/test/form-group-methods.test.d.ts +1 -0
- package/dist-types/components/form-integrations/test/form-group-methods.test.d.ts.map +1 -1
- package/dist-types/components/form-integrations/test/helpers/umbrella-form.d.ts.map +1 -1
- package/dist-types/components/input-amount/src/LionInputAmount.d.ts +2 -4
- package/dist-types/components/input-amount/src/LionInputAmount.d.ts.map +1 -1
- package/dist-types/components/input-amount/test/lion-input-amount.test.d.ts +0 -1
- package/dist-types/components/input-amount/test/lion-input-amount.test.d.ts.map +1 -1
- package/dist-types/components/input-date/src/LionInputDate.d.ts.map +1 -1
- package/dist-types/components/input-datepicker/src/LionInputDatepicker.d.ts +1 -1
- package/dist-types/components/input-datepicker/src/LionInputDatepicker.d.ts.map +1 -1
- package/dist-types/components/input-file/src/FileHandle.d.ts +55 -0
- package/dist-types/components/input-file/src/FileHandle.d.ts.map +1 -0
- package/dist-types/components/input-file/src/LionInputFile.d.ts +230 -0
- package/dist-types/components/input-file/src/LionInputFile.d.ts.map +1 -0
- package/dist-types/components/input-file/src/LionSelectedFileList.d.ts +69 -0
- package/dist-types/components/input-file/src/LionSelectedFileList.d.ts.map +1 -0
- package/dist-types/components/input-file/src/localizeNamespaceLoader.d.ts +2 -0
- package/dist-types/components/input-file/src/localizeNamespaceLoader.d.ts.map +1 -0
- package/dist-types/components/input-file/src/validators.d.ts +58 -0
- package/dist-types/components/input-file/src/validators.d.ts.map +1 -0
- package/dist-types/components/input-file/test/FileValidators.test.d.ts +2 -0
- package/dist-types/components/input-file/test/FileValidators.test.d.ts.map +1 -0
- package/dist-types/components/input-file/test/lion-input-file.test.d.ts +5 -0
- package/dist-types/components/input-file/test/lion-input-file.test.d.ts.map +1 -0
- package/dist-types/components/input-file/test/lion-selected-file-list.test.d.ts +4 -0
- package/dist-types/components/input-file/test/lion-selected-file-list.test.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/bg-BG.d.ts +13 -0
- package/dist-types/components/input-file/translations/bg-BG.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/bg.d.ts +13 -0
- package/dist-types/components/input-file/translations/bg.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/cs-CZ.d.ts +13 -0
- package/dist-types/components/input-file/translations/cs-CZ.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/cs.d.ts +13 -0
- package/dist-types/components/input-file/translations/cs.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/de-DE.d.ts +13 -0
- package/dist-types/components/input-file/translations/de-DE.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/de.d.ts +13 -0
- package/dist-types/components/input-file/translations/de.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/en-AU.d.ts +13 -0
- package/dist-types/components/input-file/translations/en-AU.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/en-GB.d.ts +13 -0
- package/dist-types/components/input-file/translations/en-GB.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/en-PH.d.ts +13 -0
- package/dist-types/components/input-file/translations/en-PH.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/en-US.d.ts +13 -0
- package/dist-types/components/input-file/translations/en-US.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/en.d.ts +13 -0
- package/dist-types/components/input-file/translations/en.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/es-ES.d.ts +13 -0
- package/dist-types/components/input-file/translations/es-ES.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/es.d.ts +13 -0
- package/dist-types/components/input-file/translations/es.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/fr-BE.d.ts +13 -0
- package/dist-types/components/input-file/translations/fr-BE.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/fr-FR.d.ts +13 -0
- package/dist-types/components/input-file/translations/fr-FR.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/fr.d.ts +13 -0
- package/dist-types/components/input-file/translations/fr.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/hu-HU.d.ts +13 -0
- package/dist-types/components/input-file/translations/hu-HU.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/hu.d.ts +13 -0
- package/dist-types/components/input-file/translations/hu.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/it-IT.d.ts +13 -0
- package/dist-types/components/input-file/translations/it-IT.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/it.d.ts +13 -0
- package/dist-types/components/input-file/translations/it.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/nl-BE.d.ts +13 -0
- package/dist-types/components/input-file/translations/nl-BE.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/nl-NL.d.ts +13 -0
- package/dist-types/components/input-file/translations/nl-NL.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/nl.d.ts +13 -0
- package/dist-types/components/input-file/translations/nl.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/pl-PL.d.ts +13 -0
- package/dist-types/components/input-file/translations/pl-PL.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/pl.d.ts +13 -0
- package/dist-types/components/input-file/translations/pl.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/ro-RO.d.ts +13 -0
- package/dist-types/components/input-file/translations/ro-RO.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/ro.d.ts +13 -0
- package/dist-types/components/input-file/translations/ro.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/ru-RU.d.ts +13 -0
- package/dist-types/components/input-file/translations/ru-RU.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/ru.d.ts +13 -0
- package/dist-types/components/input-file/translations/ru.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/sk-SK.d.ts +13 -0
- package/dist-types/components/input-file/translations/sk-SK.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/sk.d.ts +13 -0
- package/dist-types/components/input-file/translations/sk.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/uk-UA.d.ts +13 -0
- package/dist-types/components/input-file/translations/uk-UA.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/uk.d.ts +13 -0
- package/dist-types/components/input-file/translations/uk.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/zh-CN.d.ts +13 -0
- package/dist-types/components/input-file/translations/zh-CN.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/zh.d.ts +13 -0
- package/dist-types/components/input-file/translations/zh.d.ts.map +1 -0
- package/dist-types/components/input-stepper/src/LionInputStepper.d.ts +6 -0
- package/dist-types/components/input-stepper/src/LionInputStepper.d.ts.map +1 -1
- package/dist-types/components/input-tel-dropdown/src/LionInputTelDropdown.d.ts +0 -1
- package/dist-types/components/input-tel-dropdown/src/LionInputTelDropdown.d.ts.map +1 -1
- package/dist-types/components/listbox/src/ListboxMixin.d.ts.map +1 -1
- package/dist-types/components/listbox/test-suites/ListboxMixin.suite.d.ts.map +1 -1
- package/dist-types/components/localize/src/number/utils/normalize-format-number-to-parts/forceNoSpaceBetweenCurrencySymbolAndNumber.d.ts +14 -0
- package/dist-types/components/localize/src/number/utils/normalize-format-number-to-parts/forceNoSpaceBetweenCurrencySymbolAndNumber.d.ts.map +1 -0
- package/dist-types/components/localize/src/number/utils/normalize-format-number-to-parts/forceSymbols.d.ts +20 -0
- package/dist-types/components/localize/src/number/utils/normalize-format-number-to-parts/forceSymbols.d.ts.map +1 -0
- package/dist-types/components/localize/src/number/utils/normalize-format-number-to-parts/normalizeIntl.d.ts.map +1 -1
- package/dist-types/exports/checkbox-group-test-suites.d.ts +2 -0
- package/dist-types/exports/checkbox-group-test-suites.d.ts.map +1 -0
- package/dist-types/exports/define/lion-input-file.d.ts +2 -0
- package/dist-types/exports/define/lion-input-file.d.ts.map +1 -0
- package/dist-types/exports/define/lion-selected-file-list.d.ts +2 -0
- package/dist-types/exports/define/lion-selected-file-list.d.ts.map +1 -0
- package/dist-types/exports/input-file.d.ts +4 -0
- package/dist-types/exports/input-file.d.ts.map +1 -0
- package/dist-types/tsconfig.tsbuildinfo +1 -1
- package/docs/components/button/extensions/bootstrap-button.mjs +240 -0
- package/docs/components/button/extensions.md +30 -0
- package/docs/components/checkbox-group/overview.md +9 -10
- package/docs/components/checkbox-group/use-cases.md +110 -142
- package/docs/components/collapsible/overview.md +1 -1
- package/docs/components/combobox/{examples.md → extensions.md} +51 -43
- package/docs/components/combobox/overview.md +1 -1
- package/docs/components/combobox/src/google-combobox/google-combobox.js +4 -1
- package/docs/components/combobox/src/md-combobox/md-combobox.js +40 -38
- package/docs/components/combobox/src/wa-combobox/wa-combobox.js +204 -209
- package/docs/components/combobox/use-cases.md +1 -1
- package/docs/components/dialog/overview.md +1 -1
- package/docs/components/fieldset/overview.md +5 -5
- package/docs/components/form/overview.md +3 -3
- package/docs/components/icon/use-cases.md +1 -1
- package/docs/components/input/overview.md +1 -1
- package/docs/components/input-amount/overview.md +3 -3
- package/docs/components/input-amount/use-cases.md +4 -2
- package/docs/components/input-date/overview.md +3 -3
- package/docs/components/input-datepicker/overview.md +5 -5
- package/docs/components/input-datepicker/use-cases.md +11 -0
- package/docs/components/input-email/overview.md +2 -2
- package/docs/components/input-file/index.md +3 -0
- package/docs/components/input-file/overview.md +32 -0
- package/docs/components/input-file/use-cases.md +424 -0
- package/docs/components/input-iban/overview.md +2 -2
- package/docs/components/input-range/overview.md +2 -2
- package/docs/components/input-stepper/overview.md +1 -1
- package/docs/components/input-tel/overview.md +1 -1
- package/docs/components/input-tel/use-cases.md +6 -6
- package/docs/components/input-tel-dropdown/{examples.md → extensions.md} +1 -1
- package/docs/components/input-tel-dropdown/overview.md +1 -1
- package/docs/components/radio-group/overview.md +3 -3
- package/docs/components/select-rich/use-cases.md +1 -1
- package/docs/components/tabs/examples.md +1 -1
- package/docs/fundamentals/index.md +4 -4
- package/docs/fundamentals/node-tools/providence-analytics/LocalConfiguration.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/QueryResult.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/analyzer.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/dashboard.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/overview.md +3 -3
- package/docs/fundamentals/node-tools/publish-docs/overview.md +3 -3
- package/docs/fundamentals/node-tools/rocket-preset-extend-lion-docs/overview.md +2 -2
- package/docs/fundamentals/rationales/accessibility.md +28 -0
- package/docs/fundamentals/systems/core/SlotMixin.md +148 -0
- package/docs/fundamentals/systems/core/overview.md +1 -1
- package/docs/fundamentals/systems/form/formatting-and-parsing.md +4 -4
- package/docs/fundamentals/systems/form/model-value.md +1 -1
- package/docs/fundamentals/systems/form/overview.md +28 -28
- package/docs/fundamentals/systems/form/use-cases.md +2 -0
- package/docs/fundamentals/systems/form/validate.md +1 -1
- package/docs/fundamentals/systems/localize/overview.md +4 -4
- package/docs/fundamentals/systems/overlays/_configuration-positioning.md +116 -0
- package/docs/fundamentals/systems/overlays/_edge-cases.md +145 -0
- package/docs/fundamentals/systems/overlays/configuration.md +2 -2
- package/docs/fundamentals/systems/overlays/overview.md +5 -5
- package/docs/fundamentals/systems/overlays/use-cases.md +2 -2
- package/docs/fundamentals/tools/helpers/overview.md +1 -1
- package/docs/fundamentals/tools/singleton-manager/example-complex/index.md +21 -0
- package/docs/fundamentals/tools/singleton-manager/example-fail/index.md +19 -0
- package/docs/fundamentals/tools/singleton-manager/example-success/index.md +18 -0
- package/docs/fundamentals/tools/singleton-manager/overview.md +4 -4
- package/docs/guides/how-to/create-a-custom-field.md +5 -5
- package/docs/guides/how-to/create-a-form.md +88 -0
- package/docs/guides/how-to/extend-a-native-input.md +2 -2
- package/docs/guides/how-to/get-started.md +28 -1
- package/docs/guides/index.md +8 -8
- package/docs/guides/principles/index.md +5 -5
- package/docs/guides/principles/styling.md +1 -1
- package/exports/checkbox-group-test-suites.js +1 -0
- package/exports/define/lion-input-file.js +3 -0
- package/exports/define/lion-selected-file-list.js +3 -0
- package/exports/input-file.js +3 -0
- package/package.json +3 -2
- package/components/localize/src/number/utils/normalize-format-number-to-parts/forceENAUSymbols.js +0 -25
- package/components/localize/src/number/utils/normalize-format-number-to-parts/forceYenSymbol.js +0 -15
- package/dist-types/components/checkbox-group/test/lion-checkbox-indeterminate.test.d.ts +0 -4
- package/dist-types/components/checkbox-group/test/lion-checkbox-indeterminate.test.d.ts.map +0 -1
- package/dist-types/components/localize/src/number/utils/normalize-format-number-to-parts/forceENAUSymbols.d.ts +0 -14
- package/dist-types/components/localize/src/number/utils/normalize-format-number-to-parts/forceENAUSymbols.d.ts.map +0 -1
- package/dist-types/components/localize/src/number/utils/normalize-format-number-to-parts/forceYenSymbol.d.ts +0 -9
- package/dist-types/components/localize/src/number/utils/normalize-format-number-to-parts/forceYenSymbol.d.ts.map +0 -1
- package/docs/components/combobox/src/google-combobox/assets/googlelogo_color_272x92dp.png +0 -0
- package/docs/components/dialog/src/demo-dialog-style.js +0 -3
- package/docs/components/select-rich/src/flags.png +0 -0
- package/docs/components/select-rich/src/flags@2x.png +0 -0
- package/docs/fundamentals/systems/form/assets/FormatMixinDiagram-1.svg +0 -1
- package/docs/fundamentals/systems/form/assets/FormatMixinDiagram-2.svg +0 -1
- package/docs/fundamentals/systems/form/assets/FormatMixinDiagram-3.svg +0 -84
- package/docs/fundamentals/tools/ajax/assets/naga.json +0 -9
- package/docs/fundamentals/tools/ajax/assets/pabu.json +0 -9
- package/docs/fundamentals/tools/singleton-manager/.gitignore +0 -1
- package/docs/override.js +0 -15
|
@@ -433,4 +433,4 @@ export const complexObjectChoiceValue = () => html` <complex-object-combobox
|
|
|
433
433
|
## Listbox compatibility
|
|
434
434
|
|
|
435
435
|
All configurations that can be applied to `lion-listbox`, can be applied to `lion-combobox` as well.
|
|
436
|
-
See the [listbox documentation](https://github.com/ing-bank/lion/blob/
|
|
436
|
+
See the [listbox documentation](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/components/listbox/overview.md) for more information.
|
|
@@ -54,6 +54,6 @@ import '@lion/ui/define/lion-dialog.js';
|
|
|
54
54
|
## Changing the configuration
|
|
55
55
|
|
|
56
56
|
You can use the `.config` property on the dialog to change the configuration.
|
|
57
|
-
The documentation of the full config object can be found in the `overlays` folder or here in [Overlay System - Configuration](https://github.com/ing-bank/lion/blob/
|
|
57
|
+
The documentation of the full config object can be found in the `overlays` folder or here in [Overlay System - Configuration](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/fundamentals/systems/overlays/configuration.md).
|
|
58
58
|
|
|
59
59
|
The `config` property uses a setter to merge the passed configuration with the current, so you only **overwrite what you pass** when updating `config`.
|
|
@@ -20,9 +20,9 @@ export const main = () => html`
|
|
|
20
20
|
|
|
21
21
|
We have three specific fieldset implementations:
|
|
22
22
|
|
|
23
|
-
- [form](https://github.com/ing-bank/lion/blob/
|
|
24
|
-
- [checkbox-group](https://github.com/ing-bank/lion/blob/
|
|
25
|
-
- [radio-group](https://github.com/ing-bank/lion/blob/
|
|
23
|
+
- [form](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/components/form/overview.md)
|
|
24
|
+
- [checkbox-group](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/components/checkbox-group/overview.md)
|
|
25
|
+
- [radio-group](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/components/radio-group/overview.md)
|
|
26
26
|
|
|
27
27
|
A native fieldset element should always have a legend-element for a11y purposes.
|
|
28
28
|
However, our fieldset element is not native and should not have a legend-element.
|
|
@@ -31,8 +31,8 @@ Our fieldset instead has a label attribute or you can add a label with a div- or
|
|
|
31
31
|
## Features
|
|
32
32
|
|
|
33
33
|
- Easy retrieval of form data based on field names
|
|
34
|
-
- Advanced user interaction scenarios via [interaction states](https://github.com/ing-bank/lion/blob/
|
|
35
|
-
- Can have [validate](https://github.com/ing-bank/lion/blob/
|
|
34
|
+
- Advanced user interaction scenarios via [interaction states](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/fundamentals/systems/form/interaction-states.md)
|
|
35
|
+
- Can have [validate](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/fundamentals/systems/form/validate.md) on fieldset level and shows the validation feedback below the fieldset
|
|
36
36
|
- Can disable input fields on fieldset level
|
|
37
37
|
- Accessible out of the box
|
|
38
38
|
|
|
@@ -8,7 +8,7 @@ import '@lion/ui/define/lion-form.js';
|
|
|
8
8
|
```
|
|
9
9
|
|
|
10
10
|
A web component that enhances the functionality of the native `form` component.
|
|
11
|
-
It is designed to interact with (instances of) the [form controls](https://github.com/ing-bank/lion/blob/
|
|
11
|
+
It is designed to interact with (instances of) the [form controls](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/fundamentals/systems/form/overview.md).
|
|
12
12
|
|
|
13
13
|
```js preview-story
|
|
14
14
|
export const main = () => html`
|
|
@@ -26,11 +26,11 @@ export const main = () => html`
|
|
|
26
26
|
- Data synchronization with models
|
|
27
27
|
- Easy retrieval of form data based on field names
|
|
28
28
|
- Advanced validation possibilities
|
|
29
|
-
- Advanced user interaction scenarios via [interaction states](https://github.com/ing-bank/lion/blob/
|
|
29
|
+
- Advanced user interaction scenarios via [interaction states](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/fundamentals/systems/form/interaction-states.md)
|
|
30
30
|
- Registration mechanism for form controls
|
|
31
31
|
- Accessible out of the box
|
|
32
32
|
|
|
33
|
-
For more information about fields that are designed for our `form`, please read [form system](https://github.com/ing-bank/lion/blob/
|
|
33
|
+
For more information about fields that are designed for our `form`, please read [form system](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/fundamentals/systems/form/overview.md).
|
|
34
34
|
|
|
35
35
|
## Installation
|
|
36
36
|
|
|
@@ -26,7 +26,7 @@ icons.addIconResolver('lion', (iconset, name) => {
|
|
|
26
26
|
## Icon sets
|
|
27
27
|
|
|
28
28
|
Icons are displayed using icon sets. These are collections of icons, lazily loaded on demand for performance.
|
|
29
|
-
See the [system documentation](https://github.com/ing-bank/lion/blob/
|
|
29
|
+
See the [system documentation](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/fundamentals/systems/icon/overview.md) to learn more about icon sets.
|
|
30
30
|
|
|
31
31
|
```js preview-story
|
|
32
32
|
export const iconSets = () => html`
|
|
@@ -23,7 +23,7 @@ export const main = () => html`<lion-input label="First Name"></lion-input>`;
|
|
|
23
23
|
- **before**: does not have an active use case yet, but the option is in place.
|
|
24
24
|
- **after**: can be used to show a currency or percentage.
|
|
25
25
|
- Delegates attributes like `type`, `disabled`, `placeholder` and `readonly` to the native input.
|
|
26
|
-
- Can make use of [validation](https://github.com/ing-bank/lion/blob/
|
|
26
|
+
- Can make use of [validation](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/fundamentals/systems/form/validate.md).
|
|
27
27
|
|
|
28
28
|
## Installation
|
|
29
29
|
|
|
@@ -24,13 +24,13 @@ export const main = () => {
|
|
|
24
24
|
|
|
25
25
|
## Features
|
|
26
26
|
|
|
27
|
-
- Based on our [input](https://github.com/ing-bank/lion/blob/
|
|
28
|
-
- Makes use of [formatNumber](https://github.com/ing-bank/lion/blob/
|
|
27
|
+
- Based on our [input](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/components/input/overview.md)
|
|
28
|
+
- Makes use of [formatNumber](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/fundamentals/systems/localize/numbers.md) for formatting and parsing.
|
|
29
29
|
- Option to show currency as a suffix
|
|
30
30
|
- Option to override locale to change the formatting and parsing
|
|
31
31
|
- Option to provide additional format options overrides
|
|
32
32
|
- Default label in different languages
|
|
33
|
-
- Can make use of number specific [validators](https://github.com/ing-bank/lion/blob/
|
|
33
|
+
- Can make use of number specific [validators](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/fundamentals/systems/form/validate.md) with corresponding error messages in different languages
|
|
34
34
|
- IsNumber (default)
|
|
35
35
|
- MinNumber
|
|
36
36
|
- MaxNumber
|
|
@@ -20,9 +20,9 @@ export const negativeNumber = () => html`
|
|
|
20
20
|
`;
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
## Set currency
|
|
23
|
+
## Set currency label
|
|
24
24
|
|
|
25
|
-
You can optionally set a currency
|
|
25
|
+
You can optionally set a currency label with the `currency` attribute, which is visible in the after slot by default.
|
|
26
26
|
|
|
27
27
|
```js preview-story
|
|
28
28
|
export const currencySuffix = () => html`
|
|
@@ -30,6 +30,8 @@ export const currencySuffix = () => html`
|
|
|
30
30
|
`;
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
+
> The slot of the currency label can be overwritten by changing the `_currencyDisplayNodeSlot` protected property, it can be prefix, suffix, before and after.
|
|
34
|
+
|
|
33
35
|
## Force locale
|
|
34
36
|
|
|
35
37
|
Locale can be forced for a specific `lion-input-amount`. It will format the amount according to this locale.
|
|
@@ -16,11 +16,11 @@ export const main = () => html` <lion-input-date label="Date"></lion-input-date>
|
|
|
16
16
|
|
|
17
17
|
## Features
|
|
18
18
|
|
|
19
|
-
- Based on our [input](https://github.com/ing-bank/lion/blob/
|
|
20
|
-
- Makes use of [formatDate](https://github.com/ing-bank/lion/blob/
|
|
19
|
+
- Based on our [input](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/components/input/overview.md)
|
|
20
|
+
- Makes use of [formatDate](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/fundamentals/systems/localize/dates.md) for formatting and parsing.
|
|
21
21
|
- Option to override locale to change the formatting and parsing
|
|
22
22
|
- Default label in different languages
|
|
23
|
-
- Can make use of date specific [validators](https://github.com/ing-bank/lion/blob/
|
|
23
|
+
- Can make use of date specific [validators](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/fundamentals/systems/form/validate.md) with corresponding error messages in different languages
|
|
24
24
|
- IsDate (default)
|
|
25
25
|
- MinDate
|
|
26
26
|
- MaxDate
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A web component based on the date text input field. Its purpose is to provide a way for users to fill in a date with a datepicker.
|
|
4
4
|
For an input field with a big range, such as `birthday-input`, a datepicker is not the best choice due to the high variance between possible inputs.
|
|
5
|
-
We encourage using our standard [input-date](https://github.com/ing-bank/lion/blob/
|
|
5
|
+
We encourage using our standard [input-date](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/components/input-date/overview.md) for this.
|
|
6
6
|
|
|
7
7
|
```js script
|
|
8
8
|
import { html } from '@mdjs/mdjs-preview';
|
|
@@ -18,11 +18,11 @@ export const main = () => {
|
|
|
18
18
|
## Features
|
|
19
19
|
|
|
20
20
|
- Input field with a datepicker to help to choose a date
|
|
21
|
-
- Based on our [input-date](https://github.com/ing-bank/lion/blob/
|
|
22
|
-
- Makes use of our [calendar](https://github.com/ing-bank/lion/blob/
|
|
23
|
-
- Makes use of [formatDate](https://github.com/ing-bank/lion/blob/
|
|
21
|
+
- Based on our [input-date](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/components/input-date/overview.md)
|
|
22
|
+
- Makes use of our [calendar](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/components/calendar/overview.md) inside the datepicker
|
|
23
|
+
- Makes use of [formatDate](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/fundamentals/systems/localize/dates.md) for formatting and parsing.
|
|
24
24
|
- Option to overwrite locale to change the formatting and parsing
|
|
25
|
-
- Can make use of date specific [validators](https://github.com/ing-bank/lion/blob/
|
|
25
|
+
- Can make use of date specific [validators](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/fundamentals/systems/form/validate.md) with corresponding error messages in different languages
|
|
26
26
|
- IsDate (default)
|
|
27
27
|
- MinDate
|
|
28
28
|
- MaxDate
|
|
@@ -76,3 +76,14 @@ export const readOnly = () => html`
|
|
|
76
76
|
</lion-input-datepicker>
|
|
77
77
|
`;
|
|
78
78
|
```
|
|
79
|
+
|
|
80
|
+
## Faulty prefilled
|
|
81
|
+
|
|
82
|
+
Faulty prefilled input will be cleared
|
|
83
|
+
|
|
84
|
+
```js preview-story
|
|
85
|
+
export const faultyPrefilled = () => html`
|
|
86
|
+
<lion-input-datepicker label="Faulty prefiiled" .modelValue="${new Date('30/01/2022')}">
|
|
87
|
+
</lion-input-datepicker>
|
|
88
|
+
`;
|
|
89
|
+
```
|
|
@@ -15,8 +15,8 @@ export const main = () => {
|
|
|
15
15
|
|
|
16
16
|
## Features
|
|
17
17
|
|
|
18
|
-
- Based on our [input](https://github.com/ing-bank/lion/blob/
|
|
19
|
-
- Makes use of email [validators](https://github.com/ing-bank/lion/blob/
|
|
18
|
+
- Based on our [input](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/components/input/overview.md)
|
|
19
|
+
- Makes use of email [validators](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/fundamentals/systems/form/validate.md) with corresponding error messages in different languages
|
|
20
20
|
- IsEmail (default)
|
|
21
21
|
|
|
22
22
|
## Installation
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Input File >> Overview ||10
|
|
2
|
+
|
|
3
|
+
A web component based on the file input field.
|
|
4
|
+
|
|
5
|
+
```js script
|
|
6
|
+
import { html } from '@mdjs/mdjs-preview';
|
|
7
|
+
import '@lion/ui/define/lion-input-file.js';
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```js preview-story
|
|
11
|
+
export const main = () => {
|
|
12
|
+
return html` <lion-input-file label="Upload" name="upload"></lion-input-file> `;
|
|
13
|
+
};
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Features
|
|
17
|
+
|
|
18
|
+
- Based on our [input](https://github.com/ing-bank/lion/blob/a19e02c443e21d4e6c62bb08bbe6db64f7446010/docs/components/input/overview.md)
|
|
19
|
+
- Default labels and validation messages in different languages
|
|
20
|
+
- Options for multi file upload and drop-zone.
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm i --save @lion/ui
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
import { LionInputFile } from '@lion/ui/input-file.js';
|
|
30
|
+
// or
|
|
31
|
+
import '@lion/ui/define/lion-input-file.js';
|
|
32
|
+
```
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
# Input File >> Use Cases ||20
|
|
2
|
+
|
|
3
|
+
```js script
|
|
4
|
+
import { Required, Validator } from '@lion/ui/form-core.js';
|
|
5
|
+
import { loadDefaultFeedbackMessages } from '@lion/ui/validate-messages.js';
|
|
6
|
+
import { html } from '@mdjs/mdjs-preview';
|
|
7
|
+
import { ScopedElementsMixin } from '@open-wc/scoped-elements';
|
|
8
|
+
import { LitElement } from 'lit';
|
|
9
|
+
import '@lion/ui/define/lion-input-file.js';
|
|
10
|
+
loadDefaultFeedbackMessages();
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
API calls to upload the selected files can be done in below two ways which is driven by `uploadOnSelect` property
|
|
16
|
+
|
|
17
|
+
- On `form` submit
|
|
18
|
+
- On file selection
|
|
19
|
+
|
|
20
|
+
## Parameters
|
|
21
|
+
|
|
22
|
+
```html
|
|
23
|
+
<lion-input-file
|
|
24
|
+
multiple
|
|
25
|
+
label="Attachments"
|
|
26
|
+
help-text="Signature scan file"
|
|
27
|
+
max-file-size="1024000"
|
|
28
|
+
accept="application/PDF"
|
|
29
|
+
upload-on-select
|
|
30
|
+
>
|
|
31
|
+
</lion-input-file>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### modelValue
|
|
35
|
+
|
|
36
|
+
Array of [File](https://developer.mozilla.org/en-US/docs/Web/API/File); Contains all the uploaded files
|
|
37
|
+
|
|
38
|
+
### multiple
|
|
39
|
+
|
|
40
|
+
Boolean; setting to `true` allows selecting multiple files.
|
|
41
|
+
|
|
42
|
+
### EnableDragAndDrop
|
|
43
|
+
|
|
44
|
+
Boolean; setting to `true` allows file upload through drag and drop.
|
|
45
|
+
|
|
46
|
+
### uploadOnSelect
|
|
47
|
+
|
|
48
|
+
Boolean;
|
|
49
|
+
|
|
50
|
+
- Set to `true` when API calls for file upload needs to be done on file selection
|
|
51
|
+
- Set to `false` when API calls for file upload needs to be done on form submit.
|
|
52
|
+
- Default is `false`.
|
|
53
|
+
|
|
54
|
+
### uploadResponse
|
|
55
|
+
|
|
56
|
+
An array of the file-specific data to display the feedback of fileUpload
|
|
57
|
+
|
|
58
|
+
Data structure for uploadResponse array:
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
[
|
|
62
|
+
{
|
|
63
|
+
name: 'file1.txt', // name of uploaded file
|
|
64
|
+
status: '', // SUCCESS | FAIL | LOADING
|
|
65
|
+
errorMessage: '', // custom error message to be displayed
|
|
66
|
+
id: '', // unique id for future execution reference
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'file2.txt', // name of uploaded file
|
|
70
|
+
status: '', // SUCCESS | FAIL | LOADING
|
|
71
|
+
errorMessage: '', // custom error message to be displayed
|
|
72
|
+
id: '', // unique id for future execution reference
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Events
|
|
78
|
+
|
|
79
|
+
### model-value-changed
|
|
80
|
+
|
|
81
|
+
Fired when modelValue property changes.
|
|
82
|
+
|
|
83
|
+
### file-list-changed
|
|
84
|
+
|
|
85
|
+
Fired when files are uploaded. Event `detail` gives list of newly added files in `newFiles` key
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
ev.detail.newFiles;
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### file-removed
|
|
92
|
+
|
|
93
|
+
Fired when a file is removed. Event `detail` gives
|
|
94
|
+
|
|
95
|
+
- File objected for removed file in `ev.detail.removedFile`
|
|
96
|
+
- Status of this file can be used as `ev.detail.status`
|
|
97
|
+
- uploadResponse for this file as set using `uploadResponse` property. Can use used as `ev.detail.uploadResponse`
|
|
98
|
+
|
|
99
|
+
## Usage
|
|
100
|
+
|
|
101
|
+
### Basic File upload
|
|
102
|
+
|
|
103
|
+
When file has to be uploaded as soon as it is selected by the user. Use `file-list-changed` event to get the newly added file, upload it to your server and set the response back to component via `uploadResponse` property.
|
|
104
|
+
|
|
105
|
+
```js preview-story
|
|
106
|
+
export const basicFileUpload = () => {
|
|
107
|
+
return html`
|
|
108
|
+
<lion-input-file
|
|
109
|
+
label="Label"
|
|
110
|
+
max-file-size="1024000"
|
|
111
|
+
accept=".jpg,.svg,.xml,image/svg+xml"
|
|
112
|
+
@file-list-changed="${ev => {
|
|
113
|
+
console.log('fileList', ev.detail.newFiles);
|
|
114
|
+
}}"
|
|
115
|
+
>
|
|
116
|
+
</lion-input-file>
|
|
117
|
+
`;
|
|
118
|
+
};
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Validation
|
|
122
|
+
|
|
123
|
+
#### Accept
|
|
124
|
+
|
|
125
|
+
The `accept` attribute value is a string that defines the file types the file input should accept. This string is a comma-separated list of unique file type specifiers.
|
|
126
|
+
|
|
127
|
+
For more info please consult the [MDN documentation for "accept"](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept).
|
|
128
|
+
|
|
129
|
+
```js preview-story
|
|
130
|
+
export const acceptValidator = () => {
|
|
131
|
+
return html`
|
|
132
|
+
<lion-input-file
|
|
133
|
+
accept=".jpg,.svg,.xml,image/svg+xml"
|
|
134
|
+
label="Upload"
|
|
135
|
+
enable-drop-zone
|
|
136
|
+
@file-list-changed="${ev => {
|
|
137
|
+
console.log(ev.detail.newFiles);
|
|
138
|
+
}}"
|
|
139
|
+
>
|
|
140
|
+
</lion-input-file>
|
|
141
|
+
`;
|
|
142
|
+
};
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
#### Maximum File Size
|
|
146
|
+
|
|
147
|
+
The `max-file-size` attribute sets the maximum file size in bytes.
|
|
148
|
+
|
|
149
|
+
```js preview-story
|
|
150
|
+
export const sizeValidator = () => {
|
|
151
|
+
return html`
|
|
152
|
+
<lion-input-file
|
|
153
|
+
max-file-size="2048"
|
|
154
|
+
label="Upload"
|
|
155
|
+
@file-list-changed="${ev => {
|
|
156
|
+
console.log(ev.detail.newFiles);
|
|
157
|
+
}}"
|
|
158
|
+
>
|
|
159
|
+
</lion-input-file>
|
|
160
|
+
`;
|
|
161
|
+
};
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Multiple file upload
|
|
165
|
+
|
|
166
|
+
When file has to be uploaded as soon as it is selected by the user. Use `file-list-changed` event to get the newly added files, upload it to your server and set the response back to component via `uploadResponse` property for each file.
|
|
167
|
+
|
|
168
|
+
```js preview-story
|
|
169
|
+
export const multipleFileUpload = () => {
|
|
170
|
+
return html`
|
|
171
|
+
<lion-input-file
|
|
172
|
+
label="Upload"
|
|
173
|
+
name="upload"
|
|
174
|
+
multiple
|
|
175
|
+
max-file-size="1024000"
|
|
176
|
+
@file-removed="${ev => {
|
|
177
|
+
console.log('removed file details', ev.detail);
|
|
178
|
+
}}"
|
|
179
|
+
@file-list-changed="${ev => {
|
|
180
|
+
console.log('file-list-changed', ev.detail.newFiles);
|
|
181
|
+
}}"
|
|
182
|
+
@model-value-changed="${ev => {
|
|
183
|
+
console.log('model-value-changed', ev);
|
|
184
|
+
}}"
|
|
185
|
+
>
|
|
186
|
+
</lion-input-file>
|
|
187
|
+
`;
|
|
188
|
+
};
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Pre-filled state
|
|
192
|
+
|
|
193
|
+
The pre-filled state of the file upload component shows the files that were being assigned by the user initially.
|
|
194
|
+
|
|
195
|
+
On every reload of page, the file upload component reverts to the initial state and using the `uploadResponse` property, shows the names(not links) of previously assigned files.
|
|
196
|
+
|
|
197
|
+
**Note:**
|
|
198
|
+
|
|
199
|
+
- the list of prefilled files will not be available in `modelValue` or `serializedValue`. This is because value cannot be assigned to native `input` with type `file`
|
|
200
|
+
- Only `Required` validation (if set on `lion-file-input`) is triggered for files which are prefilled.
|
|
201
|
+
|
|
202
|
+
```js preview-story
|
|
203
|
+
export const prefilledState = () => {
|
|
204
|
+
return html`
|
|
205
|
+
<lion-input-file
|
|
206
|
+
label="Upload"
|
|
207
|
+
name="myFiles"
|
|
208
|
+
multiple
|
|
209
|
+
.validators="${[new Required()]}"
|
|
210
|
+
.uploadResponse="${[
|
|
211
|
+
{
|
|
212
|
+
name: 'file1.txt',
|
|
213
|
+
status: 'SUCCESS',
|
|
214
|
+
errorMessage: '',
|
|
215
|
+
id: '132',
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
name: 'file2.txt',
|
|
219
|
+
status: 'SUCCESS',
|
|
220
|
+
errorMessage: '',
|
|
221
|
+
id: 'abcd',
|
|
222
|
+
},
|
|
223
|
+
]}"
|
|
224
|
+
>
|
|
225
|
+
</lion-input-file>
|
|
226
|
+
`;
|
|
227
|
+
};
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### With form submit
|
|
231
|
+
|
|
232
|
+
**Note:** When `lion-input-file` is prefilled, the list of prefilled files will not be available in `modelValue` or `serializedValue`. This is because value cannot be assigned to native `input` with type `file`.
|
|
233
|
+
|
|
234
|
+
```js preview-story
|
|
235
|
+
const myFormReset = ev => {
|
|
236
|
+
const input = ev.target.querySelector('lion-input-file');
|
|
237
|
+
input.reset();
|
|
238
|
+
console.log(input.modelValue);
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
const myFormSubmit = ev => {
|
|
242
|
+
ev.preventDefault();
|
|
243
|
+
const input = ev.target.querySelector('lion-input-file');
|
|
244
|
+
console.log(input.hasFeedbackFor);
|
|
245
|
+
console.log(input.serializedValue);
|
|
246
|
+
return false;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
export const withIngForm = () => {
|
|
250
|
+
class FilenameLengthValidator extends Validator {
|
|
251
|
+
static get validatorName() {
|
|
252
|
+
return 'FilenameLengthValidator';
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
static getMessage(data) {
|
|
256
|
+
return `Filename length should not exceed ${data.params.maxFilenameLength} characters`;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// eslint-disable-next-line class-methods-use-this
|
|
260
|
+
checkFilenameLength(val, allowedFileNameLength) {
|
|
261
|
+
return val <= allowedFileNameLength;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
execute(modelVal, { maxFilenameLength }) {
|
|
265
|
+
const invalidFileIndex = modelVal.findIndex(
|
|
266
|
+
file => !this.checkFilenameLength(file.name.length, maxFilenameLength),
|
|
267
|
+
);
|
|
268
|
+
return invalidFileIndex > -1;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
return html`
|
|
273
|
+
<form @submit="${myFormSubmit}" @reset="${myFormReset}">
|
|
274
|
+
<lion-input-file
|
|
275
|
+
label="Upload"
|
|
276
|
+
name="upload"
|
|
277
|
+
multiple
|
|
278
|
+
.validators="${[new Required(), new FilenameLengthValidator({ maxFilenameLength: 20 })]}"
|
|
279
|
+
.uploadResponse="${[
|
|
280
|
+
{
|
|
281
|
+
name: 'file1.zip',
|
|
282
|
+
status: 'SUCCESS',
|
|
283
|
+
id: '132',
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
name: 'file2.zip',
|
|
287
|
+
status: 'SUCCESS',
|
|
288
|
+
id: 'abcd',
|
|
289
|
+
},
|
|
290
|
+
]}"
|
|
291
|
+
>
|
|
292
|
+
</lion-input-file>
|
|
293
|
+
<button type="reset">Reset</button>
|
|
294
|
+
<button>Upload</button>
|
|
295
|
+
</form>
|
|
296
|
+
`;
|
|
297
|
+
};
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Without form submit
|
|
301
|
+
|
|
302
|
+
Set `uploadOnSelect` property to `true`. This option can be used when Server API calls are needed as soon as it is selected by the user.
|
|
303
|
+
|
|
304
|
+
For this scenario, the list of files is displayed based on the `uploadResponse` property which needs to maintained by the consumers of this component
|
|
305
|
+
|
|
306
|
+
Below is the flow:
|
|
307
|
+
|
|
308
|
+
#### When user uploads new file(s)
|
|
309
|
+
|
|
310
|
+
1. `file-list-changed` event is fired from component with the newly added files
|
|
311
|
+
2. Initiate the request to your backend API and set the status of the relevant files to `LOADING` in `uploadResponse` property
|
|
312
|
+
3. Once the API request in completed, set the status of relevant files to `SUCCESS` or `FAIL` in `uploadResponse` property
|
|
313
|
+
|
|
314
|
+
#### When user deletes a file
|
|
315
|
+
|
|
316
|
+
1. `file-removed` event is fired from component with the deleted file
|
|
317
|
+
2. Initiate the delete request to your backend API and set the status of the relevant files as `LOADING` in `uploadResponse` property
|
|
318
|
+
3. Once the API request is completed, delete the file object from `uploadResponse` property
|
|
319
|
+
|
|
320
|
+
```js preview-story
|
|
321
|
+
export const uploadWithoutFormSubmit = () => {
|
|
322
|
+
return html`
|
|
323
|
+
<lion-input-file
|
|
324
|
+
label="Upload"
|
|
325
|
+
name="upload"
|
|
326
|
+
multiple
|
|
327
|
+
upload-on-select
|
|
328
|
+
@file-removed="${ev => {
|
|
329
|
+
ev.target.uploadResponse[
|
|
330
|
+
ev.target.uploadResponse.findIndex(file => file.name === ev.detail.uploadResponse.name)
|
|
331
|
+
].status = 'LOADING';
|
|
332
|
+
ev.target.uploadResponse = [...ev.target.uploadResponse]; // update uploadResponse after API calls are completed
|
|
333
|
+
setTimeout(() => {
|
|
334
|
+
ev.target.uploadResponse[
|
|
335
|
+
ev.target.uploadResponse.findIndex(file => file.name === ev.detail.uploadResponse.name)
|
|
336
|
+
] = {};
|
|
337
|
+
ev.target.uploadResponse = [...ev.target.uploadResponse]; // update uploadResponse after API calls are completed
|
|
338
|
+
}, 1000);
|
|
339
|
+
}}"
|
|
340
|
+
@file-list-changed="${ev => {
|
|
341
|
+
if (!ev.detail.newFiles[0]) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
ev.target.uploadResponse[
|
|
345
|
+
ev.target.uploadResponse.findIndex(file => file.name === ev.detail.newFiles[0].name)
|
|
346
|
+
].status = 'LOADING';
|
|
347
|
+
ev.target.uploadResponse = [...ev.target.uploadResponse]; // update uploadResponse after API calls are completed
|
|
348
|
+
|
|
349
|
+
if (ev.detail.newFiles[1]) {
|
|
350
|
+
ev.target.uploadResponse[
|
|
351
|
+
ev.target.uploadResponse.findIndex(file => file.name === ev.detail.newFiles[1].name)
|
|
352
|
+
].status = 'LOADING';
|
|
353
|
+
ev.target.uploadResponse = [...ev.target.uploadResponse]; // update uploadResponse after API calls are completed
|
|
354
|
+
}
|
|
355
|
+
setTimeout(() => {
|
|
356
|
+
ev.target.uploadResponse[
|
|
357
|
+
ev.target.uploadResponse.findIndex(file => file.name === ev.detail.newFiles[0].name)
|
|
358
|
+
].status = 'SUCCESS';
|
|
359
|
+
ev.target.uploadResponse = [...ev.target.uploadResponse]; // update uploadResponse after API calls are completed
|
|
360
|
+
}, 3000);
|
|
361
|
+
|
|
362
|
+
setTimeout(() => {
|
|
363
|
+
if (ev.detail.newFiles[1]) {
|
|
364
|
+
const file1Status = {
|
|
365
|
+
name: ev.detail.newFiles[1].name,
|
|
366
|
+
status: 'FAIL',
|
|
367
|
+
errorMessage: 'error from server',
|
|
368
|
+
};
|
|
369
|
+
ev.target.uploadResponse[
|
|
370
|
+
ev.target.uploadResponse.findIndex(file => file.name === ev.detail.newFiles[1].name)
|
|
371
|
+
] = {
|
|
372
|
+
name: ev.detail.newFiles[1].name,
|
|
373
|
+
status: 'FAIL',
|
|
374
|
+
errorMessage: 'error from server',
|
|
375
|
+
};
|
|
376
|
+
ev.target.uploadResponse = [...ev.target.uploadResponse];
|
|
377
|
+
}
|
|
378
|
+
}, 3000);
|
|
379
|
+
}}"
|
|
380
|
+
>
|
|
381
|
+
</lion-input-file>
|
|
382
|
+
`;
|
|
383
|
+
};
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### Drag and Drop
|
|
387
|
+
|
|
388
|
+
Set the `enableDropZone` parameter to `true` to use the drag and drop functionality in the component.
|
|
389
|
+
|
|
390
|
+
Drag and drop the files to be uploaded to the server.
|
|
391
|
+
|
|
392
|
+
```js preview-story
|
|
393
|
+
export const dragAndDrop = () => {
|
|
394
|
+
return html`
|
|
395
|
+
<lion-input-file
|
|
396
|
+
label="Upload"
|
|
397
|
+
name="myFiles"
|
|
398
|
+
accept=".png"
|
|
399
|
+
max-file-size="1024000"
|
|
400
|
+
enable-drop-zone
|
|
401
|
+
multiple
|
|
402
|
+
.validators="${[new Required()]}"
|
|
403
|
+
>
|
|
404
|
+
</lion-input-file>
|
|
405
|
+
`;
|
|
406
|
+
};
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
### Posting file to API using axios
|
|
410
|
+
|
|
411
|
+
You can retrieve the uploaded files in `file-list-changed` event or from `modelValue` property of this component
|
|
412
|
+
|
|
413
|
+
To submit files you can refer to the following code snippet:
|
|
414
|
+
|
|
415
|
+
```js
|
|
416
|
+
const formData = new FormData();
|
|
417
|
+
const inputFile = document.querySelector('lion-input-file').modelValue;
|
|
418
|
+
formData.append('file', inputFile.querySelector('input').files);
|
|
419
|
+
axios.post('upload_file', formData, {
|
|
420
|
+
headers: {
|
|
421
|
+
'Content-Type': 'multipart/form-data',
|
|
422
|
+
},
|
|
423
|
+
});
|
|
424
|
+
```
|