@mgdis/mg-components 5.22.0 → 5.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-28bf9033.js → index-0cf3e6d5.js} +22 -13
- package/dist/cjs/index-0cf3e6d5.js.map +1 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mg-action-more_34.cjs.entry.js +225 -158
- package/dist/cjs/mg-action-more_34.cjs.entry.js.map +1 -1
- package/dist/cjs/mg-components.cjs.js +2 -2
- package/dist/cjs/mg-components.cjs.js.map +1 -1
- package/dist/cjs/mg-item-more.cjs.entry.js +7 -6
- package/dist/cjs/mg-item-more.cjs.entry.js.map +1 -1
- package/dist/cjs/mg-menu.conf-0229bb75.js +333 -0
- package/dist/cjs/mg-menu.conf-0229bb75.js.map +1 -0
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +1 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.js.map +1 -1
- package/dist/collection/components/atoms/mg-button/mg-button.js +1 -1
- package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -1
- package/dist/collection/components/atoms/mg-card/mg-card.js +1 -1
- package/dist/collection/components/atoms/mg-card/mg-card.js.map +1 -1
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js.map +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.js.map +1 -1
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +1 -1
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js.map +1 -1
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +1 -1
- package/dist/collection/components/atoms/mg-tag/mg-tag.js.map +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js.map +1 -1
- package/dist/collection/components/molecules/inputs/MgInput.js +1 -1
- package/dist/collection/components/molecules/inputs/MgInput.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +10 -7
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +35 -6
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +1 -2
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js.map +1 -1
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js.map +1 -1
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +1 -1
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js.map +1 -1
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +1 -1
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js.map +1 -1
- package/dist/collection/components/molecules/mg-details/mg-details.js +1 -1
- package/dist/collection/components/molecules/mg-details/mg-details.js.map +1 -1
- package/dist/collection/components/molecules/mg-form/mg-form.js +1 -1
- package/dist/collection/components/molecules/mg-form/mg-form.js.map +1 -1
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -1
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js.map +1 -1
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.js +1 -1
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.js.map +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js.map +1 -1
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +6 -5
- package/dist/collection/components/molecules/mg-modal/mg-modal.js.map +1 -1
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +1 -1
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js.map +1 -1
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +1 -1
- package/dist/collection/components/molecules/mg-panel/mg-panel.js.map +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js.map +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover.js.map +1 -1
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -1
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js.map +1 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +1 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js.map +1 -1
- package/dist/collection/locales/en/messages.json +9 -1
- package/dist/collection/locales/fr/messages.json +9 -1
- package/dist/collection/locales/index.js +2 -2
- package/dist/collection/locales/index.js.map +1 -1
- package/dist/collection/utils/behaviors.utils.js.map +1 -1
- package/dist/collection/utils/behaviors.utils.spec.js +1 -1
- package/dist/collection/utils/behaviors.utils.spec.js.map +1 -1
- package/dist/collection/utils/unit.test.utils.js +0 -104
- package/dist/collection/utils/unit.test.utils.js.map +1 -1
- package/dist/components/MgInput.js +3 -3
- package/dist/components/MgInput.js.map +1 -1
- package/dist/components/index.es.js +75 -0
- package/dist/components/index.es.js.map +1 -0
- package/dist/components/index2.js +22 -61
- package/dist/components/index2.js.map +1 -1
- package/dist/components/mg-action-more.js +5 -4
- package/dist/components/mg-action-more.js.map +1 -1
- package/dist/components/mg-badge2.js +5 -4
- package/dist/components/mg-badge2.js.map +1 -1
- package/dist/components/mg-button2.js +6 -5
- package/dist/components/mg-button2.js.map +1 -1
- package/dist/components/mg-card2.js +4 -3
- package/dist/components/mg-card2.js.map +1 -1
- package/dist/components/mg-character-left2.js +2 -1
- package/dist/components/mg-character-left2.js.map +1 -1
- package/dist/components/mg-details.js +4 -3
- package/dist/components/mg-details.js.map +1 -1
- package/dist/components/mg-divider.js +2 -1
- package/dist/components/mg-divider.js.map +1 -1
- package/dist/components/mg-form.js +5 -4
- package/dist/components/mg-form.js.map +1 -1
- package/dist/components/mg-icon2.js +4 -3
- package/dist/components/mg-icon2.js.map +1 -1
- package/dist/components/mg-illustrated-message.js +4 -3
- package/dist/components/mg-illustrated-message.js.map +1 -1
- package/dist/components/mg-input-checkbox.js +16 -12
- package/dist/components/mg-input-checkbox.js.map +1 -1
- package/dist/components/mg-input-date.js +41 -10
- package/dist/components/mg-input-date.js.map +1 -1
- package/dist/components/mg-input-numeric.js +7 -6
- package/dist/components/mg-input-numeric.js.map +1 -1
- package/dist/components/mg-input-password.js +5 -4
- package/dist/components/mg-input-password.js.map +1 -1
- package/dist/components/mg-input-radio.js +6 -5
- package/dist/components/mg-input-radio.js.map +1 -1
- package/dist/components/mg-input-select2.js +8 -7
- package/dist/components/mg-input-select2.js.map +1 -1
- package/dist/components/mg-input-text2.js +8 -7
- package/dist/components/mg-input-text2.js.map +1 -1
- package/dist/components/mg-input-textarea.js +8 -7
- package/dist/components/mg-input-textarea.js.map +1 -1
- package/dist/components/mg-input-title2.js +4 -3
- package/dist/components/mg-input-title2.js.map +1 -1
- package/dist/components/mg-input-toggle.js +6 -5
- package/dist/components/mg-input-toggle.js.map +1 -1
- package/dist/components/mg-item-more.js +4 -3
- package/dist/components/mg-item-more.js.map +1 -1
- package/dist/components/mg-menu-item2.js +6 -5
- package/dist/components/mg-menu-item2.js.map +1 -1
- package/dist/components/mg-menu2.js +2 -1
- package/dist/components/mg-menu2.js.map +1 -1
- package/dist/components/mg-message.js +5 -4
- package/dist/components/mg-message.js.map +1 -1
- package/dist/components/mg-modal.js +12 -10
- package/dist/components/mg-modal.js.map +1 -1
- package/dist/components/mg-pagination2.js +4 -3
- package/dist/components/mg-pagination2.js.map +1 -1
- package/dist/components/mg-panel.js +6 -5
- package/dist/components/mg-panel.js.map +1 -1
- package/dist/components/mg-popover-content2.js +5 -4
- package/dist/components/mg-popover-content2.js.map +1 -1
- package/dist/components/mg-popover2.js +5 -4
- package/dist/components/mg-popover2.js.map +1 -1
- package/dist/components/mg-skip-links.js +4 -3
- package/dist/components/mg-skip-links.js.map +1 -1
- package/dist/components/mg-tabs.js +8 -7
- package/dist/components/mg-tabs.js.map +1 -1
- package/dist/components/mg-tag.js +5 -4
- package/dist/components/mg-tag.js.map +1 -1
- package/dist/components/mg-tooltip-content2.js +2 -1
- package/dist/components/mg-tooltip-content2.js.map +1 -1
- package/dist/components/mg-tooltip2.js +8 -7
- package/dist/components/mg-tooltip2.js.map +1 -1
- package/dist/esm/{index-93dafb06.js → index-91977c3d.js} +22 -13
- package/dist/esm/index-91977c3d.js.map +1 -0
- package/dist/esm/loader.js +2 -2
- package/dist/esm/mg-action-more_34.entry.js +193 -126
- package/dist/esm/mg-action-more_34.entry.js.map +1 -1
- package/dist/esm/mg-components.js +3 -3
- package/dist/esm/mg-components.js.map +1 -1
- package/dist/esm/mg-item-more.entry.js +5 -4
- package/dist/esm/mg-item-more.entry.js.map +1 -1
- package/dist/esm/mg-menu.conf-4b2d2eab.js +315 -0
- package/dist/esm/mg-menu.conf-4b2d2eab.js.map +1 -0
- package/dist/mg-components/locales/en/messages.json +9 -1
- package/dist/mg-components/locales/fr/messages.json +9 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/mg-components.esm.js.map +1 -1
- package/dist/mg-components/p-1564df7a.js +2 -0
- package/dist/mg-components/p-1564df7a.js.map +1 -0
- package/dist/mg-components/p-49e1ffcb.js +3 -0
- package/dist/mg-components/p-49e1ffcb.js.map +1 -0
- package/dist/mg-components/p-6c68c7eb.entry.js +2 -0
- package/dist/mg-components/p-6c68c7eb.entry.js.map +1 -0
- package/dist/mg-components/p-d6d71404.entry.js +2 -0
- package/dist/mg-components/p-d6d71404.entry.js.map +1 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +1 -1
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +1 -1
- package/dist/types/components/atoms/mg-card/mg-card.d.ts +1 -1
- package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +1 -1
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +1 -1
- package/dist/types/components/molecules/inputs/MgInput.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +18 -1
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +1 -1
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +1 -1
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +1 -1
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +1 -1
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +1 -1
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +1 -1
- package/dist/types/components/molecules/mg-popover/mg-popover-content/mg-popover-content.d.ts +1 -1
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +1 -1
- package/dist/types/components.d.ts +2 -2
- package/dist/types/locales/index.d.ts +1 -180
- package/dist/types/utils/unit.test.utils.d.ts +0 -82
- package/package.json +33 -32
- package/dist/cjs/components.utils-637c479d.js +0 -447
- package/dist/cjs/components.utils-637c479d.js.map +0 -1
- package/dist/cjs/index-28bf9033.js.map +0 -1
- package/dist/collection/utils/components.utils.js +0 -147
- package/dist/collection/utils/components.utils.js.map +0 -1
- package/dist/collection/utils/components.utils.spec.js +0 -156
- package/dist/collection/utils/components.utils.spec.js.map +0 -1
- package/dist/collection/utils/e2e.test.utils.js +0 -46
- package/dist/collection/utils/e2e.test.utils.js.map +0 -1
- package/dist/collection/utils/locale.utils.js +0 -57
- package/dist/collection/utils/locale.utils.js.map +0 -1
- package/dist/collection/utils/locale.utils.spec.js +0 -52
- package/dist/collection/utils/locale.utils.spec.js.map +0 -1
- package/dist/components/components.utils.js +0 -150
- package/dist/components/components.utils.js.map +0 -1
- package/dist/esm/components.utils-f7c073a0.js +0 -431
- package/dist/esm/components.utils-f7c073a0.js.map +0 -1
- package/dist/esm/index-93dafb06.js.map +0 -1
- package/dist/mg-components/p-457dd62a.entry.js +0 -2
- package/dist/mg-components/p-457dd62a.entry.js.map +0 -1
- package/dist/mg-components/p-4fa40a8f.entry.js +0 -2
- package/dist/mg-components/p-4fa40a8f.entry.js.map +0 -1
- package/dist/mg-components/p-721c4571.js +0 -2
- package/dist/mg-components/p-721c4571.js.map +0 -1
- package/dist/mg-components/p-8155d0e2.js +0 -3
- package/dist/mg-components/p-8155d0e2.js.map +0 -1
- package/dist/types/utils/components.utils.d.ts +0 -87
- package/dist/types/utils/e2e.test.utils.d.ts +0 -22
- package/dist/types/utils/locale.utils.d.ts +0 -38
package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mg-input-checkbox.js","sourceRoot":"","sources":["../../../../../src/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.tsx"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAgB,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAA6C,aAAa,EAAE,WAAW,EAA4B,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAClK,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C;;;;GAIG;AACH,MAAM,eAAe,GAAG,CAAC,KAAc,EAA2B,EAAE,CAClE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;IACpB,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,IAAI,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,SAAS,CA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C,kBAAkB,EAC3C,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACtC,EAAE,EAAC,iBAAiB,EACpB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,OAAO,EAAE,IAAI,CAAC,OAAO,GACA,CACxB,CAAC,CAAC,CAAC,CACF,IAAI,CAAC,mBAAmB,EAAE,CAC3B,CACO,CACX,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["/* eslint-disable jsx-a11y/no-redundant-roles */\nimport { Component, Element, Event, h, Prop, EventEmitter, State, Watch, Method } from '@stencil/core';\nimport { MgInput } from '../MgInput';\nimport { ClassList, cleanString, isValidString } from '../../../../utils/components.utils';\nimport { initLocales } from '../../../../locales';\nimport { CheckboxItem, CheckboxType, CheckboxValue, checkboxTypes, SectionKind, MgInputCheckboxListProps, SelectValuesButtonKey } from './mg-input-checkbox.conf';\nimport { MgInputCheckboxList } from './MgInputCheckboxList';\nimport { Handler } from '../MgInput.conf';\n\n/**\n * type CheckboxItem validation function\n * @param items - Checkbox item\n * @returns match item type\n */\nconst isCheckboxItems = (items: unknown): items is CheckboxItem[] =>\n Array.isArray(items) &&\n items.every(item => typeof item === 'object' && typeof item.title === 'string' && (item.value === null || typeof item.value === 'boolean') && item.value !== undefined);\n\n@Component({\n tag: 'mg-input-checkbox',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-input-checkbox.css',\n shadow: true,\n})\nexport class MgInputCheckbox implements Omit<MgInputCheckboxListProps, 'id' | 'checkboxes' | 'messages'> {\n /************\n * Internal *\n ************/\n\n // HTML selector\n private mgPopover: HTMLMgPopoverElement;\n private searchInput: HTMLInputElement;\n\n // Locales\n private messages;\n\n // hasDisplayedError (triggered by blur event)\n private hasDisplayedError = false;\n private handlerInProgress: Handler;\n\n private mode: 'custom' | 'auto' = 'custom';\n private legendId: string;\n\n // style\n private readonly baseClassName = 'mg-c-input--checkbox';\n\n // \"multi\" setup\n private readonly multiStart = 5;\n private readonly searchStart = 10;\n\n // popover variables\n private hasOpenedPopover = false;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgInputCheckboxElement;\n\n /**\n * Component value\n * If item.value is `null`, checkbox will be indeterminate by default\n */\n @Prop({ mutable: true }) value!: CheckboxValue[];\n @Watch('value')\n validateValue(newValue: MgInputCheckbox['value']): void {\n if (isCheckboxItems(newValue)) {\n this.checkboxItems = newValue.map((item, index) => ({\n ...item,\n _id: `${this.identifier}_${index}`,\n _handleInput: this.handleInput.bind(this),\n _handleBlur: this.handleBlur.bind(this),\n _handleKeydown: this.handleKeydown.bind(this),\n }));\n this.valueChange.emit(newValue);\n } else {\n throw new Error('<mg-input-checkbox> prop \"value\" is required and all values must be the same type, CheckboxItem.');\n }\n }\n\n /**\n * Define checkbox type\n * When it's undefined the type is dynamic:\n * - With 0-5 items type is 'checkbox'\n * - With 5-10 items type is 'multi'\n * When it set the type is locked to the defined value.\n * When type is dynamic OR with 'multi' type AND Over 10 items \"search\" feature is enabled\n */\n @Prop({ mutable: true }) type: CheckboxType;\n @Watch('type')\n validateType(newValue: MgInputCheckbox['type']): void {\n if (newValue !== undefined && !checkboxTypes.includes(newValue)) {\n throw new Error('<mg-input-checkbox> prop \"type\" must be a CheckboxType.');\n } else if (newValue === undefined) {\n this.mode = 'auto';\n this.type = checkboxTypes[0];\n } else {\n const className = `${this.baseClassName}-multi`;\n if (newValue === 'multi') {\n this.classCollection.add(className);\n this.element.dataset.mgPopoverGuard = this.getMgPopoverIdentifier();\n } else this.classCollection.delete(className);\n }\n }\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n */\n @Prop() identifier!: string;\n\n /**\n * Define input name\n * If not set the value equals the identifier\n */\n @Prop() name = this.identifier;\n\n /**\n * Define input label\n */\n @Prop() label!: string;\n\n /**\n * Define if label is displayed on top\n */\n @Prop() labelOnTop: boolean;\n\n /**\n * Define if label is visible\n */\n @Prop() labelHide = false;\n\n /**\n * Define if inputs are display verticaly\n */\n @Prop() inputVerticalList = false;\n\n /**\n * Define if mg-input-checkbox is required\n */\n @Prop() required = false;\n\n /**\n * Define if mg-input-checkbox is readonly\n */\n @Prop() readonly = false;\n\n /**\n * Display selected values list in \"multi\" type\n * This prop is only applied with prop type \"multi\" or when an \"unset\" mode render a \"multi\" type.\n */\n @Prop() displaySelectedValues: boolean;\n\n /**\n * Define if input is disabled\n */\n @Prop() disabled = false;\n @Watch('required')\n @Watch('readonly')\n @Watch('disabled')\n handleValidityChange(newValue: boolean, _oldValue: boolean, prop: string): void {\n if (prop !== 'readonly') this.updateCheckboxItems(prop, newValue);\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.hasDisplayedError = prop !== 'required';\n this.setErrorMessage(this.hasDisplayedError);\n }\n this.setButtonText();\n }\n\n @Watch('disabled')\n validateDisabled(newValue: MgInputCheckbox['disabled']): void {\n const className = `${this.baseClassName}-multi-disabled`;\n if (newValue && this.type === 'multi') this.classCollection.add(className);\n else this.classCollection.delete(className);\n }\n\n /**\n * Add a tooltip message next to the input\n */\n @Prop() tooltip: string;\n\n /**\n * Add a help text under the input, usually expected data format and example\n */\n @Prop() helpText: string;\n\n /**\n * Define input valid state\n */\n @Prop({ mutable: true }) valid: boolean;\n\n /**\n * Define input invalid state\n */\n @Prop({ mutable: true }) invalid: boolean;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList([this.baseClassName]);\n\n /**\n * Error message to display\n */\n @State() errorMessage: string;\n\n /**\n * Formated value to display in list\n */\n @State() checkboxItems: CheckboxItem[] = [];\n @Watch('checkboxItems')\n validateCheckboxItems(newValue: MgInputCheckbox['checkboxItems']): void {\n if (this.mode === 'auto' && newValue.length > this.multiStart) this.type = 'multi';\n if (this.mode === 'auto' || (this.type === 'multi' && newValue.length > this.searchStart)) {\n this.displaySearchInput = this.type === 'multi';\n // refresh search values\n this.updateSearchResults();\n }\n this.setButtonText();\n }\n\n /**\n * Display search input\n */\n @State() displaySearchInput: boolean;\n\n /**\n * Search value query\n */\n @State() searchValue = '';\n @Watch('searchValue')\n validateSearchValue(): void {\n // refresh search values\n this.updateSearchResults();\n }\n\n /**\n * Search current page\n */\n @State() searchResults: CheckboxItem[] = [];\n\n /**\n * Select values button text local key\n */\n @State() selectValuesButtonKey: SelectValuesButtonKey = SelectValuesButtonKey.EDIT;\n\n /**\n * Emitted event when value change\n */\n @Event({ eventName: 'value-change' }) valueChange: EventEmitter<HTMLMgInputCheckboxElement['value']>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<HTMLMgInputCheckboxElement['valid']>;\n\n /**\n * Display input error if it exists.\n */\n @Method()\n async displayError(): Promise<void> {\n this.checkValidity();\n this.setErrorMessage();\n this.hasDisplayedError = this.invalid;\n }\n\n /**\n * Set an error and display a custom error message.\n * This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.\n * It must be paired with an error message to display for the given context.\n * When used to set validity to `false`, you should use this method again to reset the validity to `true`.\n * @param valid - value indicating the validity\n * @param errorMessage - the error message to display\n */\n @Method()\n async setError(valid: MgInputCheckbox['valid'], errorMessage: string): Promise<void> {\n if (typeof valid !== 'boolean') {\n throw new Error('<mg-input-checkbox> method \"setError()\" param \"valid\" must be a boolean');\n } else if (!isValidString(errorMessage)) {\n throw new Error('<mg-input-checkbox> method \"setError()\" param \"errorMessage\" must be a string');\n } else {\n this.setValidity(valid);\n this.setErrorMessage(undefined, valid ? undefined : errorMessage);\n this.hasDisplayedError = this.invalid;\n }\n }\n\n /**\n * Method to set validity values\n * @param newValue - valid new value\n */\n private setValidity(newValue: MgInputCheckbox['valid']) {\n const oldValidValue = this.valid;\n this.valid = newValue;\n this.invalid = !this.valid;\n // We need to send valid event even if it is the same value\n if (this.handlerInProgress === undefined || (this.handlerInProgress === Handler.BLUR && this.valid !== oldValidValue)) this.inputValid.emit(this.valid);\n }\n\n /**\n * Handle input event\n * @param event - input event\n */\n private handleInput = (event: InputEvent & { target: HTMLInputElement }): void => {\n this.updateCheckboxItems('value', Boolean(event.target.checked), item => item._id === event.target.id);\n this.updateValues();\n this.checkValidity();\n };\n\n /**\n * Keyboard handler\n * @param event - to track \"tab\" key\n */\n private handleKeydown = (event: KeyboardEvent & { target: HTMLElement }): void => {\n // track \"Tab\" key event when popover display (is \"multi\" type selected)\n if (event.key === 'Tab' && this.mgPopover?.display) {\n // when search input and do a back tab we close the popover\n if (Boolean(this.searchInput) && event.shiftKey && this.searchInput.id === event.target.id) {\n this.mgPopover.display = false;\n return;\n }\n\n const enableInputs = Array.from(this.element.shadowRoot.querySelectorAll('input'))\n .filter(input => !input.getAttribute('disabled'))\n .map(({ id }) => id);\n const originInputIndex = enableInputs.findIndex(id => id === event.target.id);\n\n // close popover when tab trigger focus outside its DOM\n if ((originInputIndex + 1 >= enableInputs.length && !event.shiftKey) || (originInputIndex === 0 && event.shiftKey && !this.searchInput)) this.mgPopover.display = false;\n }\n };\n\n /**\n * Handle blur event\n */\n private handleBlur = (): void => {\n // set guard\n this.handlerInProgress = Handler.BLUR;\n\n // Check validity\n this.checkValidity();\n this.setErrorMessage();\n\n // reset guard\n this.handlerInProgress = undefined;\n };\n\n /**\n * Handle input search value-change event\n * @param event - input value-change event\n */\n private handleSearchChange = (event: CustomEvent): void => {\n this.searchValue = event.detail;\n };\n\n /**\n * popover display-change handler\n * @param event - mg-popover display-change custom event\n */\n private handleMgPopoverDisplayChange = (event: CustomEvent): void => {\n // 1. update hasOpenedPopover guard with event value\n this.hasOpenedPopover = event.detail;\n\n // 2. update selected valued button text\n this.setButtonText();\n\n // 3. when popover display change to hide, update reset needeed props and run checkValidity\n if (!event.detail) {\n // reset search value\n this.searchValue = '';\n // reset pagintated section current page\n Array.from(this.element.shadowRoot.querySelectorAll('mg-input-checkbox-paginated')).forEach(element => {\n element.currentPage = 1;\n });\n this.checkValidity();\n }\n };\n\n /**\n * Handle select all button\n * @param event - mass action event trigger a global select/unselect on values\n */\n private handleMassAction = (event: CustomEvent): void => {\n const displayItems = this.getDisplayItems();\n\n // update only displayed items\n displayItems.forEach(item => {\n item.value = event.detail !== 'selected';\n });\n this.updateValues();\n };\n\n /**\n * Update values\n */\n private updateValues = (): void => {\n this.value = this.checkboxItems.map(o => {\n delete o._handleBlur;\n delete o._handleInput;\n delete o._handleKeydown;\n delete o._id;\n return o;\n });\n };\n\n /**\n * Update ckecboxes item\n * @param key - property to update\n * @param newValue - value to update with\n * @param condition - condtion to applu change on item\n */\n private updateCheckboxItems(key: string, newValue: unknown, condition?: (item: CheckboxItem) => boolean): void {\n this.checkboxItems = this.checkboxItems.map(item => {\n if ((typeof condition === 'function' && condition(item)) || condition === undefined) item[key] = newValue;\n return item;\n });\n }\n\n /**\n * has invalid input\n * @returns true if at least one input is invalid\n */\n private hasInvalidInput = (): boolean =>\n Array.from(this.element.shadowRoot.querySelectorAll('input[type=\"checkbox\"]')).some((input: HTMLInputElement) => !input.disabled && !input.checkValidity());\n\n /**\n * Method to update searchResults\n */\n private updateSearchResults = (): void => {\n this.searchResults = this.checkboxItems.filter(item => cleanString(item.title).includes(cleanString(this.searchValue)));\n };\n\n /**\n * Methode to validate if one of inputs value is checked id required\n * @returns truthy if condition is valid\n */\n private validateRequired = (): boolean => !this.required || this.checkboxItems.some(({ value }) => value);\n\n /**\n * Check if input is valid\n */\n private checkValidity = (): void => {\n this.setValidity(this.readonly || this.disabled || (!this.hasInvalidInput() && this.validateRequired()));\n };\n\n /**\n * Set button text locale key\n */\n private setButtonText = (): void => {\n // prevent key update while popover is openned\n if (this.hasOpenedPopover) return;\n let messageKey = SelectValuesButtonKey.EDIT;\n if (this.disabled) messageKey = SelectValuesButtonKey.SHOW;\n else if (this.getSelectedItems().length < 1) messageKey = SelectValuesButtonKey.SELECT;\n\n this.selectValuesButtonKey = messageKey;\n };\n\n /**\n * Set input error message\n * @param displayError - dispay error condition\n * @param errorMessage - errorMessage override\n */\n private setErrorMessage = (displayError = true, errorMessage?: string): void => {\n // Set error message\n this.errorMessage = undefined;\n if (displayError && !this.valid) {\n if (errorMessage !== undefined) this.errorMessage = errorMessage;\n else if (!this.validateRequired()) this.errorMessage = this.messages.errors.required;\n }\n };\n\n /**\n * Method to get mg-popover identifier\n * @returns MgPopover identifier\n */\n private getMgPopoverIdentifier = (): string => `${this.identifier}-input-mg-popover`;\n\n /**\n * Manage items to display depending on the search state\n * @returns items to display\n */\n private getDisplayItems = (): CheckboxItem[] => (this.searchValue.length > 0 ? this.searchResults : this.checkboxItems);\n\n /**\n * get list of selected checkboxItems\n * @returns selected checkboxItems\n */\n private getSelectedItems = (): CheckboxItem[] => this.checkboxItems.filter(({ value }) => value);\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n * @returns timeout\n */\n componentWillLoad(): ReturnType<typeof setTimeout> {\n // Get locales\n this.messages = initLocales(this.element).messages;\n // Validate\n this.validateType(this.type);\n this.validateValue(this.value);\n this.validateDisabled(this.disabled);\n this.legendId = `${this.identifier}-title`;\n // Check validity when component is ready\n // return a promise to process action only in the FIRST render().\n // https://stenciljs.com/docs/component-lifecycle#componentwillload\n return setTimeout(() => {\n this.checkValidity();\n }, 0);\n }\n\n /**\n * add listeners and DOM attributed\n */\n componentDidLoad(): void {\n this.element.shadowRoot.querySelector('legend').setAttribute('id', this.legendId);\n this.searchInput = this.element.shadowRoot.querySelector('mg-input-text')?.shadowRoot.querySelector('input');\n this.searchInput?.addEventListener('keydown', this.handleKeydown);\n }\n\n /**\n * Render checkboxes by section\n * @param checkboxes - checkboxes to render\n * @returns render sections of checkboxes\n */\n private renderCheckboxBySection(checkboxes: CheckboxItem[]): HTMLElement[] {\n const [checkedValues, notCheckedValues] = checkboxes.reduce(\n (acc, curr) => {\n acc[curr.value ? 0 : 1].push(curr);\n return acc;\n },\n [[], []],\n );\n\n const baseSection = {\n readonly: this.readonly,\n disabled: this.disabled,\n identifier: this.identifier,\n };\n\n const sections = [\n {\n ...baseSection,\n sectionKind: SectionKind.SELECTED,\n checkboxes: checkedValues,\n messages: this.messages.input.checkbox.sections.selected,\n },\n {\n ...baseSection,\n sectionKind: SectionKind.NOT_SELECTED,\n checkboxes: notCheckedValues,\n messages: this.messages.input.checkbox.sections.notSelected,\n },\n ];\n\n return sections.map(section => <mg-input-checkbox-paginated {...section} onMass-action={this.handleMassAction} key={section.sectionKind}></mg-input-checkbox-paginated>);\n }\n\n /**\n * render checkbox multi element\n * @returns html element\n */\n private renderCheckboxMulti(): HTMLElement[] {\n const selectedValuesNb = this.getSelectedItems().length;\n const checkboxes = this.getDisplayItems();\n\n return (\n <div\n class={{\n 'mg-c-input__input-container': true,\n 'mg-c-input__input-checkbox-multi': true,\n 'mg-c-input__input-checkbox-multi--with-values': this.displaySelectedValues,\n 'mg-c-input__input-checkbox-multi--search-mode': this.displaySearchInput,\n }}\n >\n <mg-popover\n arrowHide={true}\n identifier={this.getMgPopoverIdentifier()}\n display={this.hasOpenedPopover}\n onDisplay-change={this.handleMgPopoverDisplayChange}\n ref={(el: HTMLMgPopoverElement) => {\n if (el) this.mgPopover = el;\n }}\n >\n <mg-button variant=\"secondary\" aria-describedby={this.legendId}>\n <mg-icon icon=\"list\"></mg-icon>\n {this.messages.input.checkbox[this.selectValuesButtonKey]}\n </mg-button>\n <div slot=\"content\" class=\"mg-c-input__input-checkbox-multi-content\">\n {this.displaySearchInput ? (\n [\n <mg-input-text\n key=\"input-search\"\n identifier={`${this.identifier}-input-search`}\n icon=\"magnifying-glass\"\n type=\"search\"\n placeholder={this.messages.input.checkbox.label}\n label={this.messages.input.checkbox.label}\n mgWidth=\"full\"\n value={this.searchValue}\n labelHide={true}\n displayCharacterLeft={false}\n name=\"q\"\n onValue-change={this.handleSearchChange}\n aria-controls=\"search-results items-list\"\n ></mg-input-text>,\n <p key=\"search-results\" role=\"status\" class=\"mg-u-visually-hidden\" id=\"search-results\">\n {`${checkboxes.length} ${this.messages.input.checkbox[checkboxes.length > 0 ? 'results' : 'result']}`}\n </p>,\n <div key=\"sections-container\" class=\"mg-c-input__input-checkbox-multi-sections-container\">\n {this.renderCheckboxBySection(checkboxes)}\n </div>,\n ]\n ) : (\n <MgInputCheckboxList\n checkboxes={checkboxes}\n inputVerticalList={true}\n type={this.type}\n readonly={this.readonly}\n displaySearchInput={this.displaySearchInput}\n messages={this.messages.input.checkbox}\n id=\"checkboxes-list\"\n disabled={this.disabled}\n name={this.name}\n invalid={this.invalid}\n ></MgInputCheckboxList>\n )}\n {this.displaySearchInput && checkboxes.length === 0 && <p class=\"mg-c-input__input-checkbox-multi-no-result\">{this.messages.input.checkbox.noResult}</p>}\n </div>\n </mg-popover>\n {this.displaySelectedValues ? (\n selectedValuesNb > 0 && (\n <ul role=\"list\" class=\"mg-c-input__input-checkbox-multi-values-container\">\n {this.getSelectedItems().map(({ title }) => (\n <li class=\"mg-c-input__input-checkbox-multi-value\" key={title}>\n {title}\n </li>\n ))}\n </ul>\n )\n ) : (\n <strong>{this.messages.input.checkbox[selectedValuesNb > 1 ? 'selectedValues' : 'selectedValue'].replace('{nb}', selectedValuesNb)}</strong>\n )}\n </div>\n );\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <MgInput\n identifier={this.identifier}\n classCollection={this.classCollection}\n ariaDescribedbyIDs={[]}\n label={this.label}\n labelOnTop={this.labelOnTop}\n labelHide={this.labelHide}\n required={!this.readonly ? this.required : undefined} // required is only used display asterisk\n readonly={undefined}\n mgWidth={undefined}\n disabled={this.disabled}\n value={this.value?.toString()}\n readonlyValue={undefined}\n tooltip={!this.readonly ? this.tooltip : undefined}\n helpText={!this.readonly ? this.helpText : undefined}\n errorMessage={!this.readonly ? this.errorMessage : undefined}\n isFieldset={true}\n >\n {this.type === 'checkbox' || this.readonly ? (\n <MgInputCheckboxList\n checkboxes={this.checkboxItems}\n inputVerticalList={this.inputVerticalList}\n type={this.type}\n readonly={this.readonly}\n displaySearchInput={this.displaySearchInput}\n messages={this.messages.input.checkbox}\n id=\"checkboxes-list\"\n disabled={this.disabled}\n name={this.name}\n invalid={this.invalid}\n ></MgInputCheckboxList>\n ) : (\n this.renderCheckboxMulti()\n )}\n </MgInput>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mg-input-checkbox.js","sourceRoot":"","sources":["../../../../../src/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.tsx"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAgB,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAA6C,aAAa,EAAE,WAAW,EAA4B,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAClK,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["/* eslint-disable jsx-a11y/no-redundant-roles */\nimport { Component, Element, Event, h, Prop, EventEmitter, State, Watch, Method } from '@stencil/core';\nimport { MgInput } from '../MgInput';\nimport { ClassList, cleanString, isValidString } from '@mgdis/stencil-helpers';\nimport { initLocales } from '../../../../locales';\nimport { CheckboxItem, CheckboxType, CheckboxValue, checkboxTypes, SectionKind, MgInputCheckboxListProps, SelectValuesButtonKey } from './mg-input-checkbox.conf';\nimport { MgInputCheckboxList } from './MgInputCheckboxList';\nimport { Handler } from '../MgInput.conf';\n\n/**\n * type CheckboxItem validation function\n * @param items - Checkbox item\n * @returns match item type\n */\nconst isCheckboxItems = (items: unknown): items is CheckboxItem[] =>\n Array.isArray(items) &&\n items.every(item => typeof item === 'object' && typeof item.title === 'string' && (item.value === null || typeof item.value === 'boolean') && item.value !== undefined);\n\n@Component({\n tag: 'mg-input-checkbox',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-input-checkbox.css',\n shadow: true,\n})\nexport class MgInputCheckbox implements Omit<MgInputCheckboxListProps, 'id' | 'checkboxes' | 'messages'> {\n /************\n * Internal *\n ************/\n\n // HTML selector\n private mgPopover: HTMLMgPopoverElement;\n private searchInput: HTMLInputElement;\n\n // Locales\n private messages;\n\n // hasDisplayedError (triggered by blur event)\n private hasDisplayedError = false;\n private handlerInProgress: Handler;\n\n private mode: 'custom' | 'auto' = 'custom';\n private legendId: string;\n\n // style\n private readonly baseClassName = 'mg-c-input--checkbox';\n\n // \"multi\" setup\n private readonly multiStart = 5;\n private readonly searchStart = 10;\n\n // popover variables\n private hasOpenedPopover = false;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgInputCheckboxElement;\n\n /**\n * Component value\n * If item.value is `null`, checkbox will be indeterminate by default\n */\n @Prop({ mutable: true }) value!: CheckboxValue[];\n @Watch('value')\n validateValue(newValue: MgInputCheckbox['value']): void {\n if (isCheckboxItems(newValue)) {\n this.checkboxItems = newValue.map((item, index) => ({\n ...item,\n _id: `${this.identifier}_${index}`,\n _handleInput: this.handleInput.bind(this),\n _handleBlur: this.handleBlur.bind(this),\n _handleKeydown: this.handleKeydown.bind(this),\n }));\n this.valueChange.emit(newValue);\n } else {\n throw new Error('<mg-input-checkbox> prop \"value\" is required and all values must be the same type, CheckboxItem.');\n }\n }\n\n /**\n * Define checkbox type\n * When it's undefined the type is dynamic:\n * - With 0-5 items type is 'checkbox'\n * - With 5-10 items type is 'multi'\n * When it set the type is locked to the defined value.\n * When type is dynamic OR with 'multi' type AND Over 10 items \"search\" feature is enabled\n */\n @Prop({ mutable: true }) type: CheckboxType;\n @Watch('type')\n validateType(newValue: MgInputCheckbox['type']): void {\n if (newValue !== undefined && !checkboxTypes.includes(newValue)) {\n throw new Error('<mg-input-checkbox> prop \"type\" must be a CheckboxType.');\n } else if (newValue === undefined) {\n this.mode = 'auto';\n this.type = checkboxTypes[0];\n } else {\n const className = `${this.baseClassName}-multi`;\n if (newValue === 'multi') {\n this.classCollection.add(className);\n this.element.dataset.mgPopoverGuard = this.getMgPopoverIdentifier();\n } else this.classCollection.delete(className);\n }\n }\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n */\n @Prop() identifier!: string;\n\n /**\n * Define input name\n * If not set the value equals the identifier\n */\n @Prop() name = this.identifier;\n\n /**\n * Define input label\n */\n @Prop() label!: string;\n\n /**\n * Define if label is displayed on top\n */\n @Prop() labelOnTop: boolean;\n\n /**\n * Define if label is visible\n */\n @Prop() labelHide = false;\n\n /**\n * Define if inputs are display verticaly\n */\n @Prop() inputVerticalList = false;\n\n /**\n * Define if mg-input-checkbox is required\n */\n @Prop() required = false;\n\n /**\n * Define if mg-input-checkbox is readonly\n */\n @Prop() readonly = false;\n\n /**\n * Display selected values list in \"multi\" type\n * This prop is only applied with prop type \"multi\" or when an \"unset\" mode render a \"multi\" type.\n */\n @Prop() displaySelectedValues: boolean;\n\n /**\n * Define if input is disabled\n */\n @Prop() disabled = false;\n @Watch('required')\n @Watch('readonly')\n @Watch('disabled')\n handleValidityChange(newValue: boolean, _oldValue: boolean, prop: string): void {\n if (prop !== 'readonly') this.updateCheckboxItems(prop, newValue);\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.hasDisplayedError = prop !== 'required';\n this.setErrorMessage(this.hasDisplayedError);\n }\n this.setButtonText();\n }\n\n @Watch('disabled')\n validateDisabled(newValue: MgInputCheckbox['disabled']): void {\n const className = `${this.baseClassName}-multi-disabled`;\n if (newValue && this.type === 'multi') this.classCollection.add(className);\n else this.classCollection.delete(className);\n }\n\n /**\n * Add a tooltip message next to the input\n */\n @Prop() tooltip: string;\n\n /**\n * Add a help text under the input, usually expected data format and example\n */\n @Prop() helpText: string;\n\n /**\n * Define input valid state\n */\n @Prop({ mutable: true }) valid: boolean;\n\n /**\n * Define input invalid state\n */\n @Prop({ mutable: true }) invalid: boolean;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList([this.baseClassName]);\n\n /**\n * Error message to display\n */\n @State() errorMessage: string;\n\n /**\n * Formated value to display in list\n */\n @State() checkboxItems: CheckboxItem[] = [];\n @Watch('checkboxItems')\n validateCheckboxItems(newValue: MgInputCheckbox['checkboxItems']): void {\n // For the 'auto' mode we update the type depending on the new value's length.\n if (this.mode === 'auto') this.type = newValue.length > this.multiStart ? 'multi' : 'checkbox';\n // If the type is multi and the new value's length is greater than the search gauge, display the search input.\n this.displaySearchInput = this.type === 'multi' && newValue.length > this.searchStart;\n // refresh search values\n if (this.displaySearchInput) this.updateSearchResults();\n this.setButtonText();\n }\n\n /**\n * Display search input\n */\n @State() displaySearchInput: boolean;\n\n /**\n * Search value query\n */\n @State() searchValue = '';\n @Watch('searchValue')\n validateSearchValue(): void {\n // refresh search values\n this.updateSearchResults();\n }\n\n /**\n * Search current page\n */\n @State() searchResults: CheckboxItem[] = [];\n\n /**\n * Select values button text local key\n */\n @State() selectValuesButtonKey: SelectValuesButtonKey = SelectValuesButtonKey.EDIT;\n\n /**\n * Emitted event when value change\n */\n @Event({ eventName: 'value-change' }) valueChange: EventEmitter<HTMLMgInputCheckboxElement['value']>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<HTMLMgInputCheckboxElement['valid']>;\n\n /**\n * Display input error if it exists.\n */\n @Method()\n async displayError(): Promise<void> {\n this.checkValidity();\n this.setErrorMessage();\n this.hasDisplayedError = this.invalid;\n }\n\n /**\n * Set an error and display a custom error message.\n * This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.\n * It must be paired with an error message to display for the given context.\n * When used to set validity to `false`, you should use this method again to reset the validity to `true`.\n * @param valid - value indicating the validity\n * @param errorMessage - the error message to display\n */\n @Method()\n async setError(valid: MgInputCheckbox['valid'], errorMessage: string): Promise<void> {\n if (typeof valid !== 'boolean') {\n throw new Error('<mg-input-checkbox> method \"setError()\" param \"valid\" must be a boolean');\n } else if (!isValidString(errorMessage)) {\n throw new Error('<mg-input-checkbox> method \"setError()\" param \"errorMessage\" must be a string');\n } else {\n this.setValidity(valid);\n this.setErrorMessage(undefined, valid ? undefined : errorMessage);\n this.hasDisplayedError = this.invalid;\n }\n }\n\n /**\n * Method to set validity values\n * @param newValue - valid new value\n */\n private setValidity(newValue: MgInputCheckbox['valid']) {\n const oldValidValue = this.valid;\n this.valid = newValue;\n this.invalid = !this.valid;\n // We need to send valid event even if it is the same value\n if (this.handlerInProgress === undefined || (this.handlerInProgress === Handler.BLUR && this.valid !== oldValidValue)) this.inputValid.emit(this.valid);\n }\n\n /**\n * Handle input event\n * @param event - input event\n */\n private handleInput = (event: InputEvent & { target: HTMLInputElement }): void => {\n this.updateCheckboxItems('value', Boolean(event.target.checked), item => item._id === event.target.id);\n this.updateValues();\n this.checkValidity();\n };\n\n /**\n * Keyboard handler\n * @param event - to track \"tab\" key\n */\n private handleKeydown = (event: KeyboardEvent & { target: HTMLElement }): void => {\n // track \"Tab\" key event when popover display (is \"multi\" type selected)\n if (event.key === 'Tab' && this.mgPopover?.display) {\n // when search input and do a back tab we close the popover\n if (Boolean(this.searchInput) && event.shiftKey && this.searchInput.id === event.target.id) {\n this.mgPopover.display = false;\n return;\n }\n\n const enableInputs = Array.from(this.element.shadowRoot.querySelectorAll('input'))\n .filter(input => !input.getAttribute('disabled'))\n .map(({ id }) => id);\n const originInputIndex = enableInputs.findIndex(id => id === event.target.id);\n\n // close popover when tab trigger focus outside its DOM\n if ((originInputIndex + 1 >= enableInputs.length && !event.shiftKey) || (originInputIndex === 0 && event.shiftKey && !this.searchInput)) this.mgPopover.display = false;\n }\n };\n\n /**\n * Handle blur event\n */\n private handleBlur = (): void => {\n // set guard\n this.handlerInProgress = Handler.BLUR;\n\n // Check validity\n this.checkValidity();\n this.setErrorMessage();\n\n // reset guard\n this.handlerInProgress = undefined;\n };\n\n /**\n * Handle input search value-change event\n * @param event - input value-change event\n */\n private handleSearchChange = (event: CustomEvent): void => {\n this.searchValue = event.detail;\n };\n\n /**\n * popover display-change handler\n * @param event - mg-popover display-change custom event\n */\n private handleMgPopoverDisplayChange = (event: CustomEvent): void => {\n // 1. update hasOpenedPopover guard with event value\n this.hasOpenedPopover = event.detail;\n\n // 2. update selected valued button text\n this.setButtonText();\n\n // 3. when popover display change to hide, update reset needeed props and run checkValidity\n if (!event.detail) {\n // reset search value\n this.searchValue = '';\n // reset pagintated section current page\n Array.from(this.element.shadowRoot.querySelectorAll('mg-input-checkbox-paginated')).forEach(element => {\n element.currentPage = 1;\n });\n this.checkValidity();\n }\n };\n\n /**\n * Handle select all button\n * @param event - mass action event trigger a global select/unselect on values\n */\n private handleMassAction = (event: CustomEvent): void => {\n const displayItems = this.getDisplayItems();\n\n // update only displayed items\n displayItems.forEach(item => {\n item.value = event.detail !== 'selected';\n });\n this.updateValues();\n };\n\n /**\n * Update values\n */\n private updateValues = (): void => {\n this.value = this.checkboxItems.map(o => {\n delete o._handleBlur;\n delete o._handleInput;\n delete o._handleKeydown;\n delete o._id;\n return o;\n });\n };\n\n /**\n * Update ckecboxes item\n * @param key - property to update\n * @param newValue - value to update with\n * @param condition - condtion to applu change on item\n */\n private updateCheckboxItems(key: string, newValue: unknown, condition?: (item: CheckboxItem) => boolean): void {\n this.checkboxItems = this.checkboxItems.map(item => {\n if ((typeof condition === 'function' && condition(item)) || condition === undefined) item[key] = newValue;\n return item;\n });\n }\n\n /**\n * has invalid input\n * @returns true if at least one input is invalid\n */\n private hasInvalidInput = (): boolean =>\n Array.from(this.element.shadowRoot.querySelectorAll('input[type=\"checkbox\"]')).some((input: HTMLInputElement) => !input.disabled && !input.checkValidity());\n\n /**\n * Method to update searchResults\n */\n private updateSearchResults = (): void => {\n this.searchResults = this.checkboxItems.filter(item => cleanString(item.title).includes(cleanString(this.searchValue)));\n };\n\n /**\n * Methode to validate if one of inputs value is checked id required\n * @returns truthy if condition is valid\n */\n private validateRequired = (): boolean => !this.required || this.checkboxItems.some(({ value }) => value);\n\n /**\n * Check if input is valid\n */\n private checkValidity = (): void => {\n this.setValidity(this.readonly || this.disabled || (!this.hasInvalidInput() && this.validateRequired()));\n };\n\n /**\n * Set button text locale key\n */\n private setButtonText = (): void => {\n // prevent key update while popover is openned\n if (this.hasOpenedPopover) return;\n let messageKey = SelectValuesButtonKey.EDIT;\n if (this.disabled) messageKey = SelectValuesButtonKey.SHOW;\n else if (this.getSelectedItems().length < 1) messageKey = SelectValuesButtonKey.SELECT;\n\n this.selectValuesButtonKey = messageKey;\n };\n\n /**\n * Set input error message\n * @param displayError - dispay error condition\n * @param errorMessage - errorMessage override\n */\n private setErrorMessage = (displayError = true, errorMessage?: string): void => {\n // Set error message\n this.errorMessage = undefined;\n if (displayError && !this.valid) {\n if (errorMessage !== undefined) this.errorMessage = errorMessage;\n else if (!this.validateRequired()) this.errorMessage = this.messages.errors.required;\n }\n };\n\n /**\n * Method to get mg-popover identifier\n * @returns MgPopover identifier\n */\n private getMgPopoverIdentifier = (): string => `${this.identifier}-input-mg-popover`;\n\n /**\n * Manage items to display depending on the search state\n * @returns items to display\n */\n private getDisplayItems = (): CheckboxItem[] => (this.searchValue.length > 0 ? this.searchResults : this.checkboxItems);\n\n /**\n * get list of selected checkboxItems\n * @returns selected checkboxItems\n */\n private getSelectedItems = (): CheckboxItem[] => this.checkboxItems.filter(({ value }) => value);\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n * @returns timeout\n */\n componentWillLoad(): ReturnType<typeof setTimeout> {\n // Get locales\n this.messages = initLocales(this.element).messages;\n\n // Validate\n // `validateType` must be done before `validateValue` because we need to set mode['auto'|'custom'] from type\n // and `validateValue` updates `this.checkboxItems` watcher which requires a defined `this.type`.\n this.validateType(this.type);\n this.validateValue(this.value);\n this.validateDisabled(this.disabled);\n this.legendId = `${this.identifier}-title`;\n // Check validity when component is ready\n // return a promise to process action only in the FIRST render().\n // https://stenciljs.com/docs/component-lifecycle#componentwillload\n return setTimeout(() => {\n this.checkValidity();\n }, 0);\n }\n\n /**\n * add listeners and DOM attributed\n */\n componentDidLoad(): void {\n this.element.shadowRoot.querySelector('legend').setAttribute('id', this.legendId);\n this.searchInput = this.element.shadowRoot.querySelector('mg-input-text')?.shadowRoot.querySelector('input');\n this.searchInput?.addEventListener('keydown', this.handleKeydown);\n }\n\n /**\n * Render checkboxes by section\n * @param checkboxes - checkboxes to render\n * @returns render sections of checkboxes\n */\n private renderCheckboxBySection(checkboxes: CheckboxItem[]): HTMLElement[] {\n const [checkedValues, notCheckedValues] = checkboxes.reduce(\n (acc, curr) => {\n acc[curr.value ? 0 : 1].push(curr);\n return acc;\n },\n [[], []],\n );\n\n const baseSection = {\n readonly: this.readonly,\n disabled: this.disabled,\n identifier: this.identifier,\n };\n\n const sections = [\n {\n ...baseSection,\n sectionKind: SectionKind.SELECTED,\n checkboxes: checkedValues,\n messages: this.messages.input.checkbox.sections.selected,\n },\n {\n ...baseSection,\n sectionKind: SectionKind.NOT_SELECTED,\n checkboxes: notCheckedValues,\n messages: this.messages.input.checkbox.sections.notSelected,\n },\n ];\n\n return sections.map(section => <mg-input-checkbox-paginated {...section} onMass-action={this.handleMassAction} key={section.sectionKind}></mg-input-checkbox-paginated>);\n }\n\n /**\n * render checkbox multi element\n * @returns html element\n */\n private renderCheckboxMulti(): HTMLElement[] {\n const selectedValuesNb = this.getSelectedItems().length;\n const checkboxes = this.getDisplayItems();\n\n return (\n <div\n class={{\n 'mg-c-input__input-container': true,\n 'mg-c-input__input-checkbox-multi': true,\n 'mg-c-input__input-checkbox-multi--with-values': this.displaySelectedValues,\n 'mg-c-input__input-checkbox-multi--search-mode': this.displaySearchInput,\n }}\n >\n <mg-popover\n arrowHide={true}\n identifier={this.getMgPopoverIdentifier()}\n display={this.hasOpenedPopover}\n onDisplay-change={this.handleMgPopoverDisplayChange}\n ref={(el: HTMLMgPopoverElement) => {\n if (el) this.mgPopover = el;\n }}\n >\n <mg-button variant=\"secondary\" aria-describedby={this.legendId}>\n <mg-icon icon=\"list\"></mg-icon>\n {this.messages.input.checkbox[this.selectValuesButtonKey]}\n </mg-button>\n <div slot=\"content\" class=\"mg-c-input__input-checkbox-multi-content\">\n {this.displaySearchInput ? (\n [\n <mg-input-text\n key=\"input-search\"\n identifier={`${this.identifier}-input-search`}\n icon=\"magnifying-glass\"\n type=\"search\"\n placeholder={this.messages.input.checkbox.label}\n label={this.messages.input.checkbox.label}\n mgWidth=\"full\"\n value={this.searchValue}\n labelHide={true}\n displayCharacterLeft={false}\n name=\"q\"\n onValue-change={this.handleSearchChange}\n aria-controls=\"search-results items-list\"\n ></mg-input-text>,\n <p key=\"search-results\" role=\"status\" class=\"mg-u-visually-hidden\" id=\"search-results\">\n {`${checkboxes.length} ${this.messages.input.checkbox[checkboxes.length > 0 ? 'results' : 'result']}`}\n </p>,\n <div key=\"sections-container\" class=\"mg-c-input__input-checkbox-multi-sections-container\">\n {this.renderCheckboxBySection(checkboxes)}\n </div>,\n ]\n ) : (\n <MgInputCheckboxList\n checkboxes={checkboxes}\n inputVerticalList={true}\n type={this.type}\n readonly={this.readonly}\n displaySearchInput={this.displaySearchInput}\n messages={this.messages.input.checkbox}\n id=\"checkboxes-list\"\n disabled={this.disabled}\n name={this.name}\n invalid={this.invalid}\n ></MgInputCheckboxList>\n )}\n {this.displaySearchInput && checkboxes.length === 0 && <p class=\"mg-c-input__input-checkbox-multi-no-result\">{this.messages.input.checkbox.noResult}</p>}\n </div>\n </mg-popover>\n {this.displaySelectedValues ? (\n selectedValuesNb > 0 && (\n <ul role=\"list\" class=\"mg-c-input__input-checkbox-multi-values-container\">\n {this.getSelectedItems().map(({ title }) => (\n <li class=\"mg-c-input__input-checkbox-multi-value\" key={title}>\n {title}\n </li>\n ))}\n </ul>\n )\n ) : (\n <strong>{this.messages.input.checkbox[selectedValuesNb > 1 ? 'selectedValues' : 'selectedValue'].replace('{nb}', selectedValuesNb)}</strong>\n )}\n </div>\n );\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <MgInput\n identifier={this.identifier}\n classCollection={this.classCollection}\n ariaDescribedbyIDs={[]}\n label={this.label}\n labelOnTop={this.labelOnTop}\n labelHide={this.labelHide}\n required={!this.readonly ? this.required : undefined} // required is only used display asterisk\n readonly={undefined}\n mgWidth={undefined}\n disabled={this.disabled}\n value={this.value?.toString()}\n readonlyValue={undefined}\n tooltip={!this.readonly ? this.tooltip : undefined}\n helpText={!this.readonly ? this.helpText : undefined}\n errorMessage={!this.readonly ? this.errorMessage : undefined}\n isFieldset={true}\n >\n {this.type === 'checkbox' || this.readonly ? (\n <MgInputCheckboxList\n checkboxes={this.checkboxItems}\n inputVerticalList={this.inputVerticalList}\n type={this.type}\n readonly={this.readonly}\n displaySearchInput={this.displaySearchInput}\n messages={this.messages.input.checkbox}\n id=\"checkboxes-list\"\n disabled={this.disabled}\n name={this.name}\n invalid={this.invalid}\n ></MgInputCheckboxList>\n ) : (\n this.renderCheckboxMulti()\n )}\n </MgInput>\n );\n }\n}\n"]}
|
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import { h } from "@stencil/core";
|
|
2
2
|
import { MgInput } from "../MgInput";
|
|
3
3
|
import { InputError } from "./mg-input-date.conf";
|
|
4
|
-
import { ClassList, isValidString } from "
|
|
5
|
-
import { localeDate, dateRegExp } from "../../../../utils/locale.utils";
|
|
4
|
+
import { ClassList, isValidString, localeDate, dateRegExp, dateToString, getLocaleDatePattern } from "@mgdis/stencil-helpers";
|
|
6
5
|
import { initLocales } from "../../../../locales";
|
|
7
6
|
import { Handler } from "../MgInput.conf";
|
|
8
7
|
export class MgInputDate {
|
|
9
8
|
constructor() {
|
|
10
9
|
// hasDisplayedError (triggered by blur event)
|
|
11
10
|
this.hasDisplayedError = false;
|
|
11
|
+
/**
|
|
12
|
+
* Format help text to display
|
|
13
|
+
* @param helpText - help text format
|
|
14
|
+
* @returns formated pattern help text. Ex: Format attendu : jj/mm/aaaa (ex : 20/12/2020)
|
|
15
|
+
*/
|
|
16
|
+
this.formatHelpText = (helpText) => {
|
|
17
|
+
const defaultHelpTextVariable = '{defaultHelpText}';
|
|
18
|
+
let text = isValidString(helpText) ? helpText : this.messages.input.date.helpText;
|
|
19
|
+
if (text.includes(defaultHelpTextVariable))
|
|
20
|
+
text = text.replace(defaultHelpTextVariable, this.formatHelpText(this.messages.input.date.helpText));
|
|
21
|
+
return text.replace('{pattern}', this.renderPattern()).replace('{date}', localeDate(dateToString(new Date('2023-12-24')), this.systemLocale));
|
|
22
|
+
};
|
|
12
23
|
/**
|
|
13
24
|
* Handle input event
|
|
14
25
|
*/
|
|
@@ -80,15 +91,30 @@ export class MgInputDate {
|
|
|
80
91
|
}
|
|
81
92
|
// min, max & minMax
|
|
82
93
|
else if ([InputError.MIN, InputError.MAX, InputError.MINMAX].includes(inputError)) {
|
|
83
|
-
this.errorMessage = this.messages.errors.date[inputError]
|
|
94
|
+
this.errorMessage = this.messages.errors.date[inputError]
|
|
95
|
+
.replace('{min}', localeDate(this.min, this.systemLocale))
|
|
96
|
+
.replace('{max}', localeDate(this.max, this.systemLocale));
|
|
84
97
|
}
|
|
85
98
|
// wrong date format
|
|
86
99
|
// element.validity.badInput is default error message
|
|
87
100
|
else {
|
|
88
|
-
this.errorMessage = this.messages.errors.date.badInput
|
|
101
|
+
this.errorMessage = this.messages.errors.date.badInput
|
|
102
|
+
.replace('{min}', ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 ? localeDate(this.min, this.systemLocale) : localeDate('1900-01-01', this.systemLocale))
|
|
103
|
+
.replace('{pattern}', this.renderPattern());
|
|
89
104
|
}
|
|
90
105
|
}
|
|
91
106
|
};
|
|
107
|
+
/**
|
|
108
|
+
* Render pattern
|
|
109
|
+
* @returns translated html pattern
|
|
110
|
+
*/
|
|
111
|
+
this.renderPattern = () => {
|
|
112
|
+
let patternLocal = getLocaleDatePattern(this.systemLocale);
|
|
113
|
+
for (const key in this.messages.input.date.pattern) {
|
|
114
|
+
patternLocal = patternLocal.replace(key, this.messages.input.date.pattern[key]);
|
|
115
|
+
}
|
|
116
|
+
return `<span aria-hidden="true">${patternLocal}</span><span class="mg-u-visually-hidden">${[...patternLocal].join(' ')}</span>`;
|
|
117
|
+
};
|
|
92
118
|
this.value = undefined;
|
|
93
119
|
this.identifier = undefined;
|
|
94
120
|
this.name = this.identifier;
|
|
@@ -186,6 +212,9 @@ export class MgInputDate {
|
|
|
186
212
|
const locales = initLocales(this.element);
|
|
187
213
|
this.locale = locales.locale;
|
|
188
214
|
this.messages = locales.messages;
|
|
215
|
+
// as a native input use the OS locale to define the date pattern
|
|
216
|
+
// we need to get this locale to define the displayed pattern
|
|
217
|
+
this.systemLocale = Intl.DateTimeFormat().resolvedOptions().locale;
|
|
189
218
|
// Validate
|
|
190
219
|
this.validateValue(this.value);
|
|
191
220
|
this.validateMinMax(this.min);
|
|
@@ -202,7 +231,7 @@ export class MgInputDate {
|
|
|
202
231
|
* @returns HTML Element
|
|
203
232
|
*/
|
|
204
233
|
render() {
|
|
205
|
-
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: localeDate(this.value, this.locale), tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "date", class: "mg-c-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
|
|
234
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: localeDate(this.value, this.locale), tooltip: this.tooltip, helpText: this.formatHelpText(this.helpText), errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "date", class: "mg-c-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
|
|
206
235
|
if (el !== null)
|
|
207
236
|
this.input = el;
|
|
208
237
|
} })));
|
|
@@ -408,7 +437,7 @@ export class MgInputDate {
|
|
|
408
437
|
"optional": false,
|
|
409
438
|
"docs": {
|
|
410
439
|
"tags": [],
|
|
411
|
-
"text": "Add a help text under the input, usually expected data format and example"
|
|
440
|
+
"text": "Add a help text under the input, usually expected data format and example\nAvailable string variables:\n - `{pattern}`: render innerHTML pattern based on system\n - `{date}`: render innerText date with a pattern base format.\n - `{defaultHelpText}`: render default `helpText` usefull to concat helpText local with your custom text.\nex: `Input use {pattern} pattern` as `helpText` prop value will be render as `Input use mm/dd/yyyy pattern`"
|
|
412
441
|
},
|
|
413
442
|
"attribute": "help-text",
|
|
414
443
|
"reflect": false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mg-input-date.js","sourceRoot":"","sources":["../../../../../src/components/molecules/inputs/mg-input-date/mg-input-date.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAO1C,MAAM,OAAO,WAAW;;QAYtB,8CAA8C;QACtC,sBAAiB,GAAG,KAAK,CAAC;QAuLlC;;WAEG;QACK,gBAAW,GAAG,GAAS,EAAE;YAC/B,IAAI,CAAC,aAAa,EAAE,CAAC;YACrB,IAAI,IAAI,CAAC,iBAAiB,EAAE;gBAC1B,IAAI,CAAC,eAAe,EAAE,CAAC;aACxB;YACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QAChC,CAAC,CAAC;QAEF;;WAEG;QACK,eAAU,GAAG,GAAS,EAAE;YAC9B,IAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;YACtC,IAAI,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE;gBAC/B,cAAc;gBACd,IAAI,CAA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AAG,EACb,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,EAAE,EAAE,IAAI,CAAC,UAAU,EACnB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ,kBACT,CAAC,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,QAAQ,EAAE,EAChD,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,MAAM,EAAE,IAAI,CAAC,UAAU,EACvB,GAAG,EAAE,CAAC,EAAoB,EAAE,EAAE;oBAC5B,IAAI,EAAE,KAAK,IAAI;wBAAE,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;gBACnC,CAAC,GACD,CACM,CACX,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Prop, State, Watch, Method } from '@stencil/core';\nimport { MgInput } from '../MgInput';\nimport { InputError } from './mg-input-date.conf';\nimport { ClassList, isValidString } from '../../../../utils/components.utils';\nimport { localeDate, dateRegExp } from '../../../../utils/locale.utils';\nimport { initLocales } from '../../../../locales';\nimport { Handler } from '../MgInput.conf';\n\n@Component({\n tag: 'mg-input-date',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-input-date.css',\n shadow: true,\n})\nexport class MgInputDate {\n /************\n * Internal *\n ************/\n\n // HTML selector\n private input: HTMLInputElement;\n\n // Locales\n private messages;\n private locale: string;\n\n // hasDisplayedError (triggered by blur event)\n private hasDisplayedError = false;\n private handlerInProgress: Handler;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgInputDateElement;\n\n /**\n * Component value\n */\n @Prop({ mutable: true, reflect: true }) value: string;\n @Watch('value')\n validateValue(newValue: MgInputDate['value']): void {\n // When the input is not fully completed or has been cleared, the value becomes an empty string.\n if (newValue === '') newValue = null;\n if (newValue !== undefined && newValue !== null && (typeof newValue !== 'string' || !dateRegExp.test(newValue))) {\n throw new Error(\"<mg-input-date> props 'value' doesn't match pattern: yyyy-mm-dd\");\n } else {\n this.valueChange.emit(newValue);\n }\n }\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n */\n @Prop() identifier!: string;\n\n /**\n * Input name\n * If not set the value equals the identifier\n */\n @Prop() name: string = this.identifier;\n\n /**\n * Input label\n */\n @Prop() label!: string;\n\n /**\n * Define if label is displayed on top\n */\n @Prop() labelOnTop: boolean;\n\n /**\n * Define if label is visible\n */\n @Prop() labelHide = false;\n\n /**\n * Define if input is required\n */\n @Prop() required = false;\n\n /**\n * Define if input is readonly\n */\n @Prop() readonly = false;\n\n /**\n * Define if input is disabled\n */\n @Prop() disabled = false;\n @Watch('required')\n @Watch('readonly')\n @Watch('disabled')\n handleValidityChange(newValue: boolean, _oldValue: boolean, prop: string): void {\n if (this.input !== undefined) {\n this.input[prop] = newValue;\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n this.hasDisplayedError = false;\n }\n }\n }\n\n /**\n * Add a tooltip message next to the input\n */\n @Prop() tooltip: string;\n\n /**\n * Add a help text under the input, usually expected data format and example\n */\n @Prop() helpText: string;\n\n /**\n * Define input valid state\n */\n @Prop({ mutable: true }) valid: boolean;\n\n /**\n * Define input invalid state\n */\n @Prop({ mutable: true }) invalid: boolean;\n\n /**\n * Define input minimum date\n * format: yyyy-mm-dd\n */\n @Prop() min: string;\n\n /**\n * Define input maximum date\n * format: yyyy-mm-dd\n */\n @Prop() max: string;\n @Watch('min')\n @Watch('max')\n validateMinMax(newValue: string): void {\n if (newValue?.length === 0 || (newValue?.length > 0 && !(typeof newValue === 'string' && dateRegExp.test(newValue)))) {\n throw new Error(\"<mg-input-date> props 'min/max' doesn't match pattern: yyyy-mm-dd\");\n }\n }\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-input--date']);\n\n /**\n * Error message to display\n */\n @State() errorMessage: string;\n\n /**\n * Emited event when value change\n */\n @Event({ eventName: 'value-change' }) valueChange: EventEmitter<HTMLMgInputDateElement['value']>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<HTMLMgInputDateElement['valid']>;\n\n /**\n * Display input error if it exists.\n */\n @Method()\n async displayError(): Promise<void> {\n this.checkValidity();\n this.setErrorMessage();\n this.hasDisplayedError = this.invalid;\n }\n\n /**\n * Set an error and display a custom error message.\n * This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.\n * It must be paired with an error message to display for the given context.\n * When used to set validity to `false`, you should use this method again to reset the validity to `true`.\n * @param valid - value indicating the validity\n * @param errorMessage - the error message to display\n */\n @Method()\n async setError(valid: MgInputDate['valid'], errorMessage: string): Promise<void> {\n if (typeof valid !== 'boolean') {\n throw new Error('<mg-input-date> method \"setError()\" param \"valid\" must be a boolean');\n } else if (!isValidString(errorMessage)) {\n throw new Error('<mg-input-date> method \"setError()\" param \"errorMessage\" must be a string');\n } else {\n this.setValidity(valid);\n this.setErrorMessage(valid ? undefined : errorMessage);\n this.hasDisplayedError = this.invalid;\n }\n }\n\n /**\n * Method to set validity values\n * @param newValue - valid new value\n */\n private setValidity(newValue: MgInputDate['valid']) {\n const oldValidValue = this.valid;\n this.valid = newValue;\n this.invalid = !this.valid;\n // We need to send valid event even if it is the same value\n if (this.handlerInProgress === undefined || (this.handlerInProgress === Handler.BLUR && this.valid !== oldValidValue)) this.inputValid.emit(this.valid);\n }\n\n /**\n * Handle input event\n */\n private handleInput = (): void => {\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n }\n this.value = this.input.value;\n };\n\n /**\n * Handle blur event\n */\n private handleBlur = (): void => {\n this.handlerInProgress = Handler.BLUR;\n this.displayError().finally(() => {\n // reset guard\n this.handlerInProgress = undefined;\n });\n };\n\n /**\n * Check if input is valid\n */\n private checkValidity = (): void => {\n this.setValidity(this.readonly || this.disabled || (this.input?.checkValidity !== undefined ? this.input.checkValidity() : true));\n };\n\n /**\n * get input error code\n * @returns error code\n */\n private getInputError = (): null | InputError => {\n let inputError = null;\n\n // required\n if (this.input.validity.valueMissing) {\n inputError = InputError.REQUIRED;\n }\n // min & max\n else if ((this.input.validity.rangeUnderflow || this.input.validity.rangeOverflow) && this.min?.length > 0 && this.max?.length > 0) {\n inputError = InputError.MINMAX;\n }\n // min\n else if (this.input.validity.rangeUnderflow) {\n inputError = InputError.MIN;\n }\n //max\n else if (this.input.validity.rangeOverflow) {\n inputError = InputError.MAX;\n }\n\n return inputError;\n };\n\n /**\n * Check input errors\n * @param errorMessage - errorMessage override\n */\n private setErrorMessage = (errorMessage?: string): void => {\n // Set error message\n this.errorMessage = undefined;\n if (!this.valid) {\n const inputError = this.getInputError();\n if (errorMessage !== undefined) {\n this.errorMessage = errorMessage;\n }\n // required\n else if (inputError === InputError.REQUIRED) {\n this.errorMessage = this.messages.errors[inputError];\n }\n // min, max & minMax\n else if ([InputError.MIN, InputError.MAX, InputError.MINMAX].includes(inputError)) {\n this.errorMessage = this.messages.errors.date[inputError].replace('{min}', localeDate(this.min, this.locale)).replace('{max}', localeDate(this.max, this.locale));\n }\n // wrong date format\n // element.validity.badInput is default error message\n else {\n this.errorMessage = this.messages.errors.date.badInput.replace('{min}', this.min?.length > 0 ? localeDate(this.min, this.locale) : localeDate('1900-01-01', this.locale));\n }\n }\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n * @returns timeout\n */\n componentWillLoad(): ReturnType<typeof setTimeout> {\n // Get locales\n const locales = initLocales(this.element);\n this.locale = locales.locale;\n this.messages = locales.messages;\n // Validate\n this.validateValue(this.value);\n this.validateMinMax(this.min);\n this.validateMinMax(this.max);\n // Check validity when component is ready\n // return a promise to process action only in the FIRST render().\n // https://stenciljs.com/docs/component-lifecycle#componentwillload\n return setTimeout(() => {\n this.checkValidity();\n }, 0);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <MgInput\n identifier={this.identifier}\n classCollection={this.classCollection}\n ariaDescribedbyIDs={[]}\n label={this.label}\n labelOnTop={this.labelOnTop}\n labelHide={this.labelHide}\n required={this.required}\n readonly={this.readonly}\n mgWidth={undefined}\n disabled={this.disabled}\n value={this.value}\n readonlyValue={localeDate(this.value, this.locale)}\n tooltip={this.tooltip}\n helpText={this.helpText}\n errorMessage={this.errorMessage}\n isFieldset={false}\n >\n <input\n type=\"date\"\n class=\"mg-c-input__box\"\n min={this.min}\n max={this.max}\n value={this.value}\n id={this.identifier}\n name={this.name}\n disabled={this.disabled}\n required={this.required}\n aria-invalid={(this.invalid === true).toString()}\n onInput={this.handleInput}\n onBlur={this.handleBlur}\n ref={(el: HTMLInputElement) => {\n if (el !== null) this.input = el;\n }}\n />\n </MgInput>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mg-input-date.js","sourceRoot":"","sources":["../../../../../src/components/molecules/inputs/mg-input-date/mg-input-date.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;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,EAAE,IAAI,CAAC,GAAG,EACb,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,EAAE,EAAE,IAAI,CAAC,UAAU,EACnB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ,kBACT,CAAC,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,QAAQ,EAAE,EAChD,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,MAAM,EAAE,IAAI,CAAC,UAAU,EACvB,GAAG,EAAE,CAAC,EAAoB,EAAE,EAAE;oBAC5B,IAAI,EAAE,KAAK,IAAI;wBAAE,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;gBACnC,CAAC,GACD,CACM,CACX,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Prop, State, Watch, Method } from '@stencil/core';\nimport { MgInput } from '../MgInput';\nimport { InputError } from './mg-input-date.conf';\nimport { ClassList, isValidString, localeDate, dateRegExp, dateToString, getLocaleDatePattern } from '@mgdis/stencil-helpers';\nimport { initLocales } from '../../../../locales';\nimport { Handler } from '../MgInput.conf';\n\n@Component({\n tag: 'mg-input-date',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-input-date.css',\n shadow: true,\n})\nexport class MgInputDate {\n /************\n * Internal *\n ************/\n\n // HTML selector\n private input: HTMLInputElement;\n\n // Locales\n private messages;\n private locale: string;\n private systemLocale: string;\n\n // hasDisplayedError (triggered by blur event)\n private hasDisplayedError = false;\n private handlerInProgress: Handler;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgInputDateElement;\n\n /**\n * Component value\n */\n @Prop({ mutable: true, reflect: true }) value: string;\n @Watch('value')\n validateValue(newValue: MgInputDate['value']): void {\n // When the input is not fully completed or has been cleared, the value becomes an empty string.\n if (newValue === '') newValue = null;\n if (newValue !== undefined && newValue !== null && (typeof newValue !== 'string' || !dateRegExp.test(newValue))) {\n throw new Error(\"<mg-input-date> props 'value' doesn't match pattern: yyyy-mm-dd\");\n } else {\n this.valueChange.emit(newValue);\n }\n }\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n */\n @Prop() identifier!: string;\n\n /**\n * Input name\n * If not set the value equals the identifier\n */\n @Prop() name: string = this.identifier;\n\n /**\n * Input label\n */\n @Prop() label!: string;\n\n /**\n * Define if label is displayed on top\n */\n @Prop() labelOnTop: boolean;\n\n /**\n * Define if label is visible\n */\n @Prop() labelHide = false;\n\n /**\n * Define if input is required\n */\n @Prop() required = false;\n\n /**\n * Define if input is readonly\n */\n @Prop() readonly = false;\n\n /**\n * Define if input is disabled\n */\n @Prop() disabled = false;\n @Watch('required')\n @Watch('readonly')\n @Watch('disabled')\n handleValidityChange(newValue: boolean, _oldValue: boolean, prop: string): void {\n if (this.input !== undefined) {\n this.input[prop] = newValue;\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n this.hasDisplayedError = false;\n }\n }\n }\n\n /**\n * Add a tooltip message next to the input\n */\n @Prop() tooltip: string;\n\n /**\n * Add a help text under the input, usually expected data format and example\n * Available string variables:\n * - `{pattern}`: render innerHTML pattern based on system\n * - `{date}`: render innerText date with a pattern base format.\n * - `{defaultHelpText}`: render default `helpText` usefull to concat helpText local with your custom text.\n * ex: `Input use {pattern} pattern` as `helpText` prop value will be render as `Input use mm/dd/yyyy pattern`\n */\n @Prop() helpText: string;\n\n /**\n * Define input valid state\n */\n @Prop({ mutable: true }) valid: boolean;\n\n /**\n * Define input invalid state\n */\n @Prop({ mutable: true }) invalid: boolean;\n\n /**\n * Define input minimum date\n * format: yyyy-mm-dd\n */\n @Prop() min: string;\n\n /**\n * Define input maximum date\n * format: yyyy-mm-dd\n */\n @Prop() max: string;\n @Watch('min')\n @Watch('max')\n validateMinMax(newValue: string): void {\n if (newValue?.length === 0 || (newValue?.length > 0 && !(typeof newValue === 'string' && dateRegExp.test(newValue)))) {\n throw new Error(\"<mg-input-date> props 'min/max' doesn't match pattern: yyyy-mm-dd\");\n }\n }\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-input--date']);\n\n /**\n * Error message to display\n */\n @State() errorMessage: string;\n\n /**\n * Emited event when value change\n */\n @Event({ eventName: 'value-change' }) valueChange: EventEmitter<HTMLMgInputDateElement['value']>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<HTMLMgInputDateElement['valid']>;\n\n /**\n * Display input error if it exists.\n */\n @Method()\n async displayError(): Promise<void> {\n this.checkValidity();\n this.setErrorMessage();\n this.hasDisplayedError = this.invalid;\n }\n\n /**\n * Set an error and display a custom error message.\n * This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.\n * It must be paired with an error message to display for the given context.\n * When used to set validity to `false`, you should use this method again to reset the validity to `true`.\n * @param valid - value indicating the validity\n * @param errorMessage - the error message to display\n */\n @Method()\n async setError(valid: MgInputDate['valid'], errorMessage: string): Promise<void> {\n if (typeof valid !== 'boolean') {\n throw new Error('<mg-input-date> method \"setError()\" param \"valid\" must be a boolean');\n } else if (!isValidString(errorMessage)) {\n throw new Error('<mg-input-date> method \"setError()\" param \"errorMessage\" must be a string');\n } else {\n this.setValidity(valid);\n this.setErrorMessage(valid ? undefined : errorMessage);\n this.hasDisplayedError = this.invalid;\n }\n }\n\n /**\n * Format help text to display\n * @param helpText - help text format\n * @returns formated pattern help text. Ex: Format attendu : jj/mm/aaaa (ex : 20/12/2020)\n */\n private formatHelpText = (helpText: string): string => {\n const defaultHelpTextVariable = '{defaultHelpText}';\n let text = isValidString(helpText) ? helpText : this.messages.input.date.helpText;\n if (text.includes(defaultHelpTextVariable)) text = text.replace(defaultHelpTextVariable, this.formatHelpText(this.messages.input.date.helpText));\n\n return text.replace('{pattern}', this.renderPattern()).replace('{date}', localeDate(dateToString(new Date('2023-12-24')), this.systemLocale));\n };\n\n /**\n * Method to set validity values\n * @param newValue - valid new value\n */\n private setValidity(newValue: MgInputDate['valid']) {\n const oldValidValue = this.valid;\n this.valid = newValue;\n this.invalid = !this.valid;\n // We need to send valid event even if it is the same value\n if (this.handlerInProgress === undefined || (this.handlerInProgress === Handler.BLUR && this.valid !== oldValidValue)) this.inputValid.emit(this.valid);\n }\n\n /**\n * Handle input event\n */\n private handleInput = (): void => {\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n }\n this.value = this.input.value;\n };\n\n /**\n * Handle blur event\n */\n private handleBlur = (): void => {\n this.handlerInProgress = Handler.BLUR;\n this.displayError().finally(() => {\n // reset guard\n this.handlerInProgress = undefined;\n });\n };\n\n /**\n * Check if input is valid\n */\n private checkValidity = (): void => {\n this.setValidity(this.readonly || this.disabled || (this.input?.checkValidity !== undefined ? this.input.checkValidity() : true));\n };\n\n /**\n * get input error code\n * @returns error code\n */\n private getInputError = (): null | InputError => {\n let inputError = null;\n\n // required\n if (this.input.validity.valueMissing) {\n inputError = InputError.REQUIRED;\n }\n // min & max\n else if ((this.input.validity.rangeUnderflow || this.input.validity.rangeOverflow) && this.min?.length > 0 && this.max?.length > 0) {\n inputError = InputError.MINMAX;\n }\n // min\n else if (this.input.validity.rangeUnderflow) {\n inputError = InputError.MIN;\n }\n //max\n else if (this.input.validity.rangeOverflow) {\n inputError = InputError.MAX;\n }\n\n return inputError;\n };\n\n /**\n * Check input errors\n * @param errorMessage - errorMessage override\n */\n private setErrorMessage = (errorMessage?: string): void => {\n // Set error message\n this.errorMessage = undefined;\n if (!this.valid) {\n const inputError = this.getInputError();\n if (errorMessage !== undefined) {\n this.errorMessage = errorMessage;\n }\n // required\n else if (inputError === InputError.REQUIRED) {\n this.errorMessage = this.messages.errors[inputError];\n }\n // min, max & minMax\n else if ([InputError.MIN, InputError.MAX, InputError.MINMAX].includes(inputError)) {\n this.errorMessage = this.messages.errors.date[inputError]\n .replace('{min}', localeDate(this.min, this.systemLocale))\n .replace('{max}', localeDate(this.max, this.systemLocale));\n }\n // wrong date format\n // element.validity.badInput is default error message\n else {\n this.errorMessage = this.messages.errors.date.badInput\n .replace('{min}', this.min?.length > 0 ? localeDate(this.min, this.systemLocale) : localeDate('1900-01-01', this.systemLocale))\n .replace('{pattern}', this.renderPattern());\n }\n }\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n * @returns timeout\n */\n componentWillLoad(): ReturnType<typeof setTimeout> {\n // Get locales\n const locales = initLocales(this.element);\n this.locale = locales.locale;\n this.messages = locales.messages;\n\n // as a native input use the OS locale to define the date pattern\n // we need to get this locale to define the displayed pattern\n this.systemLocale = Intl.DateTimeFormat().resolvedOptions().locale;\n\n // Validate\n this.validateValue(this.value);\n this.validateMinMax(this.min);\n this.validateMinMax(this.max);\n // Check validity when component is ready\n // return a promise to process action only in the FIRST render().\n // https://stenciljs.com/docs/component-lifecycle#componentwillload\n return setTimeout(() => {\n this.checkValidity();\n }, 0);\n }\n\n /**\n * Render pattern\n * @returns translated html pattern\n */\n private renderPattern = (): string => {\n let patternLocal = getLocaleDatePattern(this.systemLocale);\n for (const key in this.messages.input.date.pattern) {\n patternLocal = patternLocal.replace(key, this.messages.input.date.pattern[key]);\n }\n\n return `<span aria-hidden=\"true\">${patternLocal}</span><span class=\"mg-u-visually-hidden\">${[...patternLocal].join(' ')}</span>`;\n };\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <MgInput\n identifier={this.identifier}\n classCollection={this.classCollection}\n ariaDescribedbyIDs={[]}\n label={this.label}\n labelOnTop={this.labelOnTop}\n labelHide={this.labelHide}\n required={this.required}\n readonly={this.readonly}\n mgWidth={undefined}\n disabled={this.disabled}\n value={this.value}\n readonlyValue={localeDate(this.value, this.locale)}\n tooltip={this.tooltip}\n helpText={this.formatHelpText(this.helpText)}\n errorMessage={this.errorMessage}\n isFieldset={false}\n >\n <input\n type=\"date\"\n class=\"mg-c-input__box\"\n min={this.min}\n max={this.max}\n value={this.value}\n id={this.identifier}\n name={this.name}\n disabled={this.disabled}\n required={this.required}\n aria-invalid={(this.invalid === true).toString()}\n onInput={this.handleInput}\n onBlur={this.handleBlur}\n ref={(el: HTMLInputElement) => {\n if (el !== null) this.input = el;\n }}\n />\n </MgInput>\n );\n }\n}\n"]}
|
|
@@ -2,9 +2,8 @@ import { h } from "@stencil/core";
|
|
|
2
2
|
import { MgInput } from "../MgInput";
|
|
3
3
|
import { Handler } from "../MgInput.conf";
|
|
4
4
|
import { types, InputError } from "./mg-input-numeric.conf";
|
|
5
|
-
import { ClassList, isValidString } from "
|
|
5
|
+
import { ClassList, isValidString, localeCurrency, localeNumber } from "@mgdis/stencil-helpers";
|
|
6
6
|
import { initLocales } from "../../../../locales/";
|
|
7
|
-
import { localeCurrency, localeNumber } from "../../../../utils/locale.utils";
|
|
8
7
|
export class MgInputNumeric {
|
|
9
8
|
constructor() {
|
|
10
9
|
// hasDisplayedError (triggered by blur event)
|
package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mg-input-numeric.js","sourceRoot":"","sources":["../../../../../src/components/molecules/inputs/mg-input-numeric/m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ourcesContent":["import { Component, Element, Event, h, Prop, EventEmitter, State, Watch, Method } from '@stencil/core';\nimport { MgInput } from '../MgInput';\nimport { Handler, Width } from '../MgInput.conf';\nimport { types, InputError } from './mg-input-numeric.conf';\nimport { ClassList, isValidString } from '../../../../utils/components.utils';\nimport { initLocales } from '../../../../locales/';\nimport { localeCurrency, localeNumber } from '../../../../utils/locale.utils';\n\n@Component({\n tag: 'mg-input-numeric',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-input-numeric.css',\n shadow: true,\n})\nexport class MgInputNumeric {\n /************\n * Internal *\n ************/\n\n // Manage different values\n private storedValue: string;\n private numericValue: number;\n private readonlyValue: string;\n\n // HTML selector\n private input: HTMLInputElement;\n\n // Locales\n private locale: string;\n private messages;\n\n // hasDisplayedError (triggered by blur event)\n private hasDisplayedError = false;\n private handlerInProgress: Handler;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgInputNumericElement;\n\n /**\n * Component value\n */\n @Prop({ mutable: true, reflect: true }) value: string;\n @Watch('value')\n validateValue(newValue: MgInputNumeric['value']): void {\n // has input value is always render as string we get a stringified value or a '' for nullish value, so we test string type\n if (typeof newValue === 'string') {\n // Split number and decimal\n const [integer, decimal = ''] = newValue.replace('-', '').split(/[.,]/);\n // Regex\n const regex = this.type === 'integer' ? /^-?\\d+$/ : /^-?\\d+(?:[.,]\\d*)?$/;\n // Filter input\n if (this.isValidValue(newValue, regex, integer, decimal)) {\n this.storedValue = newValue;\n } else {\n newValue = this.handleInvalidValue();\n }\n // Set value and input value\n this.updateValues(newValue);\n }\n }\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n */\n @Prop() identifier!: string;\n\n /**\n * Input name\n * If not set the value equals the identifier\n */\n @Prop() name: string = this.identifier;\n\n /**\n * Input label\n */\n @Prop() label!: string;\n\n /**\n * Define if label is displayed on top\n */\n @Prop() labelOnTop: boolean;\n\n /**\n * Define if label is visible\n */\n @Prop() labelHide = false;\n\n /**\n * Input placeholder.\n * It should be a word or short phrase that demonstrates the expected type of data, not a replacement for labels or help text.\n */\n @Prop() placeholder: string;\n\n /**\n * Define if input is required\n */\n @Prop() required = false;\n\n /**\n * Define if input is readonly\n */\n @Prop() readonly = false;\n\n /**\n * Define if input is disabled\n */\n @Prop() disabled = false;\n @Watch('required')\n @Watch('readonly')\n @Watch('disabled')\n handleValidityChange(newValue: boolean, _oldValue: boolean, prop: string): void {\n if (this.input !== undefined) {\n this.input[prop] = newValue;\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n this.hasDisplayedError = false;\n }\n }\n }\n\n /**\n * Define input width\n */\n @Prop() mgWidth: Width;\n\n /**\n * Add a tooltip message next to the input\n */\n @Prop() tooltip: string;\n\n /**\n * Add a help text under the input, usually expected data format and example\n */\n @Prop() helpText: string;\n\n /**\n * Define numeric type\n */\n @Prop() type: string = types[0];\n @Watch('type')\n validateType(newValue: MgInputNumeric['type']): void {\n if (!types.includes(newValue)) {\n throw new Error(`<mg-input-numeric> prop \"type\" must be one of: ${types.join(', ')}`);\n }\n }\n\n /**\n * Define currency\n */\n @Prop() currency = 'USD';\n\n /**\n * Maximum value\n */\n @Prop() max: number;\n\n /**\n * Minimum value\n */\n @Prop() min: number;\n\n /**\n * Override integer length\n * integer is the number before the decimal point\n */\n @Prop() integerLength = 13;\n @Watch('integerLength')\n validateIntegerLength(newValue: MgInputNumeric['integerLength']): void {\n if (newValue < 1) {\n throw new Error(`<mg-input-numeric> prop \"integer-length\" must be a positive number.`);\n }\n }\n\n /**\n * Override decimal length\n * decimal is the number after the decimal point\n */\n @Prop() decimalLength = 2;\n @Watch('decimalLength')\n validateDecimalLength(newValue: MgInputNumeric['decimalLength']): void {\n if (newValue < 1) {\n throw new Error(`<mg-input-numeric> prop \"decimal-length\" must be a positive number, consider using prop \"type\" to \"integer\" instead.`);\n }\n }\n\n /**\n * Define input pattern to validate\n */\n @Prop({ mutable: true }) valid: boolean;\n\n /**\n * Define input pattern error message\n */\n @Prop({ mutable: true }) invalid: boolean;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-input--numeric']);\n\n /**\n * Error message to display\n */\n @State() errorMessage: string;\n\n /**\n * Define if input has focus\n */\n @State() hasFocus: boolean;\n\n /**\n * Emited event when value change\n */\n @Event({ eventName: 'value-change' }) valueChange: EventEmitter<number>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<HTMLMgInputNumericElement['valid']>;\n\n /**\n * Display input error if it exists.\n */\n @Method()\n async displayError(): Promise<void> {\n this.checkValidity();\n this.setErrorMessage();\n this.hasDisplayedError = this.invalid;\n }\n\n /**\n * Set an error and display a custom error message.\n * This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.\n * It must be paired with an error message to display for the given context.\n * When used to set validity to `false`, you should use this method again to reset the validity to `true`.\n * @param valid - value indicating the validity\n * @param errorMessage - the error message to display\n */\n @Method()\n async setError(valid: MgInputNumeric['valid'], errorMessage: string): Promise<void> {\n if (typeof valid !== 'boolean') {\n throw new Error('<mg-input-numeric> method \"setError()\" param \"valid\" must be a boolean');\n } else if (!isValidString(errorMessage)) {\n throw new Error('<mg-input-numeric> method \"setError()\" param \"errorMessage\" must be a string');\n } else {\n this.setValidity(valid);\n this.setErrorMessage(valid ? undefined : errorMessage);\n this.hasDisplayedError = this.invalid;\n }\n }\n\n /**\n * Method to set validity values\n * @param newValue - valid new value\n */\n private setValidity(newValue: MgInputNumeric['valid']) {\n const oldValidValue = this.valid;\n this.valid = newValue;\n this.invalid = !this.valid;\n // We need to send valid event even if it is the same value\n if (this.handlerInProgress === undefined || (this.handlerInProgress === Handler.BLUR && this.valid !== oldValidValue)) this.inputValid.emit(this.valid);\n }\n\n /**\n * Checks if the given value is valid according to the defined rules.\n * @param value - The input value to validate.\n * @param regex - The regular expression for validation.\n * @param integer - The integer part of the value.\n * @param decimal - The decimal part of the value.\n * @returns Returns true if the value is valid, otherwise false.\n */\n private isValidValue(value: string, regex: RegExp, integer: string, decimal: string): boolean {\n return (\n ['', '-'].includes(value) || (regex.exec(value) !== null && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength))\n );\n }\n\n /**\n * Handles invalid input values and returns a corrected value.\n * @returns The corrected value.\n */\n private handleInvalidValue(): string | null {\n return this.storedValue ?? null;\n }\n\n /**\n * Updates the component values based on the validated input value.\n * @param newValue - The validated input value.\n */\n private updateValues(newValue: string | null): void {\n this.value = newValue;\n if (this.input !== undefined) this.input.value = this.value;\n\n this.numericValue = !['', null].includes(this.value) ? parseFloat(this.value.replace(',', '.')) : null;\n this.valueChange.emit(this.numericValue);\n\n this.readonlyValue = this.numericValue !== null ? this.formatValue(this.numericValue) : '';\n }\n\n /**\n * Displayed value in input\n * Change on focus/blur\n * @returns display value\n */\n private displayValue(): MgInputNumeric['value'] | MgInputNumeric['readonlyValue'] {\n return this.hasFocus ? this.value : this.readonlyValue;\n }\n\n /**\n * Handle input event\n */\n private handleInput = (): void => {\n // Check validity\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n }\n this.value = this.input.value;\n };\n\n /**\n * Handle focus event\n */\n private handleFocus = (): void => {\n this.hasFocus = true;\n };\n\n /**\n * Handle blur event\n */\n private handleBlur = (): void => {\n if (this.value === '-') this.value = '';\n // Display Error\n this.handlerInProgress = Handler.BLUR;\n this.displayError().finally(() => {\n // reset guard\n this.handlerInProgress = undefined;\n this.hasFocus = false;\n });\n };\n\n /**\n * Check if input is valid\n */\n private checkValidity = (): void => {\n this.setValidity(this.readonly || this.disabled || this.getInputError() === null);\n };\n\n /**\n * Set input error message\n * @param errorMessage - errorMessage override\n */\n private setErrorMessage = (errorMessage?: string): void => {\n // Set error message\n this.errorMessage = undefined;\n if (!this.valid) {\n const inputError = this.getInputError();\n if (errorMessage !== undefined) {\n this.errorMessage = errorMessage;\n } else if (inputError === InputError.REQUIRED) {\n this.errorMessage = this.messages.errors[inputError];\n } else {\n this.errorMessage = this.messages.errors.numeric[inputError].replace('{min}', `${this.formatValue(this.min)}`).replace('{max}', `${this.formatValue(this.max)}`);\n }\n }\n };\n\n /**\n * Get input error code\n * @returns error code\n */\n private getInputError = (): null | InputError => {\n let inputError = null;\n const hasNotEmptyValues = (toControl: unknown[]) => !toControl.some(value => [null, undefined].includes(value));\n\n if (!hasNotEmptyValues([this.input])) return inputError;\n\n // required\n if (!this.input.checkValidity() && this.input.validity.valueMissing) {\n inputError = InputError.REQUIRED;\n }\n // Min & Max\n else if (hasNotEmptyValues([this.min, this.numericValue]) && this.numericValue < this.min && this.max === undefined) {\n // Only a min value is set\n inputError = InputError.MIN;\n } else if (hasNotEmptyValues([this.max, this.numericValue]) && this.numericValue > this.max && this.min === undefined) {\n // Only a max value is set\n inputError = InputError.MAX;\n } else if (hasNotEmptyValues([this.min, this.max, this.numericValue]) && (this.numericValue < this.min || this.numericValue > this.max)) {\n // both min and max values are set\n inputError = InputError.MINMAX;\n }\n return inputError;\n };\n\n /**\n * Format value based on type\n * @param value - value to format\n * @returns formated local value\n */\n private formatValue = (value: number): string => (this.type === 'currency' ? localeCurrency(value, this.locale, this.currency) : localeNumber(value, this.locale));\n\n /**\n * Validate append slot\n */\n private validateAppendSlot = (): void => {\n const slotAppendInput: HTMLSlotElement = this.element.querySelector('[slot=\"append-input\"]');\n if (slotAppendInput !== null) {\n this.classCollection.add(slotAppendInput.nodeName === 'MG-BUTTON' ? 'mg-c-input--is-input-group-append' : 'mg-c-input--is-append-input-slot-content');\n }\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n * @returns timeout\n */\n componentWillLoad(): ReturnType<typeof setTimeout> {\n // Get locales\n const locales = initLocales(this.element);\n this.locale = locales.locale;\n this.messages = locales.messages;\n // Validate component config\n this.validateType(this.type);\n this.validateIntegerLength(this.integerLength);\n this.validateDecimalLength(this.decimalLength);\n // validate value\n this.validateValue(this.value);\n this.validateAppendSlot();\n // Check validity when component is ready\n // return a promise to process action only in the FIRST render().\n // https://stenciljs.com/docs/component-lifecycle#componentwillload\n return setTimeout(() => {\n this.checkValidity();\n }, 0);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <MgInput\n identifier={this.identifier}\n classCollection={this.classCollection}\n ariaDescribedbyIDs={[]}\n label={this.label}\n labelOnTop={this.labelOnTop}\n labelHide={this.labelHide}\n required={this.required}\n readonly={this.readonly}\n mgWidth={this.mgWidth}\n disabled={this.disabled}\n value={this.value}\n readonlyValue={this.readonlyValue}\n tooltip={this.tooltip}\n helpText={this.helpText}\n errorMessage={this.errorMessage}\n isFieldset={false}\n >\n <input\n type=\"text\"\n class=\"mg-c-input__box\"\n value={this.displayValue()}\n id={this.identifier}\n name={this.name}\n placeholder={this.placeholder}\n title={this.placeholder}\n disabled={this.disabled}\n required={this.required}\n aria-invalid={(this.invalid === true).toString()}\n onInput={this.handleInput}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n ref={(el: HTMLInputElement) => {\n if (el !== null) this.input = el;\n }}\n />\n <slot name=\"append-input\"></slot>\n </MgInput>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mg-input-numeric.js","sourceRoot":"","sources":["../../../../../src/components/molecules/inputs/mg-input-numeric/mg-input-numeric.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAgB,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,OAAO,EAAS,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AA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C,QAAQ,EACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ,kBACT,CAAC,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,QAAQ,EAAE,EAChD,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,MAAM,EAAE,IAAI,CAAC,UAAU,EACvB,GAAG,EAAE,CAAC,EAAoB,EAAE,EAAE;oBAC5B,IAAI,EAAE,KAAK,IAAI;wBAAE,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;gBACnC,CAAC,GACD;YACF,YAAM,IAAI,EAAC,cAAc,GAAQ,CACzB,CACX,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, h, Prop, EventEmitter, State, Watch, Method } from '@stencil/core';\nimport { MgInput } from '../MgInput';\nimport { Handler, Width } from '../MgInput.conf';\nimport { types, InputError } from './mg-input-numeric.conf';\nimport { ClassList, isValidString, localeCurrency, localeNumber } from '@mgdis/stencil-helpers';\nimport { initLocales } from '../../../../locales/';\n\n@Component({\n tag: 'mg-input-numeric',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-input-numeric.css',\n shadow: true,\n})\nexport class MgInputNumeric {\n /************\n * Internal *\n ************/\n\n // Manage different values\n private storedValue: string;\n private numericValue: number;\n private readonlyValue: string;\n\n // HTML selector\n private input: HTMLInputElement;\n\n // Locales\n private locale: string;\n private messages;\n\n // hasDisplayedError (triggered by blur event)\n private hasDisplayedError = false;\n private handlerInProgress: Handler;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgInputNumericElement;\n\n /**\n * Component value\n */\n @Prop({ mutable: true, reflect: true }) value: string;\n @Watch('value')\n validateValue(newValue: MgInputNumeric['value']): void {\n // has input value is always render as string we get a stringified value or a '' for nullish value, so we test string type\n if (typeof newValue === 'string') {\n // Split number and decimal\n const [integer, decimal = ''] = newValue.replace('-', '').split(/[.,]/);\n // Regex\n const regex = this.type === 'integer' ? /^-?\\d+$/ : /^-?\\d+(?:[.,]\\d*)?$/;\n // Filter input\n if (this.isValidValue(newValue, regex, integer, decimal)) {\n this.storedValue = newValue;\n } else {\n newValue = this.handleInvalidValue();\n }\n // Set value and input value\n this.updateValues(newValue);\n }\n }\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n */\n @Prop() identifier!: string;\n\n /**\n * Input name\n * If not set the value equals the identifier\n */\n @Prop() name: string = this.identifier;\n\n /**\n * Input label\n */\n @Prop() label!: string;\n\n /**\n * Define if label is displayed on top\n */\n @Prop() labelOnTop: boolean;\n\n /**\n * Define if label is visible\n */\n @Prop() labelHide = false;\n\n /**\n * Input placeholder.\n * It should be a word or short phrase that demonstrates the expected type of data, not a replacement for labels or help text.\n */\n @Prop() placeholder: string;\n\n /**\n * Define if input is required\n */\n @Prop() required = false;\n\n /**\n * Define if input is readonly\n */\n @Prop() readonly = false;\n\n /**\n * Define if input is disabled\n */\n @Prop() disabled = false;\n @Watch('required')\n @Watch('readonly')\n @Watch('disabled')\n handleValidityChange(newValue: boolean, _oldValue: boolean, prop: string): void {\n if (this.input !== undefined) {\n this.input[prop] = newValue;\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n this.hasDisplayedError = false;\n }\n }\n }\n\n /**\n * Define input width\n */\n @Prop() mgWidth: Width;\n\n /**\n * Add a tooltip message next to the input\n */\n @Prop() tooltip: string;\n\n /**\n * Add a help text under the input, usually expected data format and example\n */\n @Prop() helpText: string;\n\n /**\n * Define numeric type\n */\n @Prop() type: string = types[0];\n @Watch('type')\n validateType(newValue: MgInputNumeric['type']): void {\n if (!types.includes(newValue)) {\n throw new Error(`<mg-input-numeric> prop \"type\" must be one of: ${types.join(', ')}`);\n }\n }\n\n /**\n * Define currency\n */\n @Prop() currency = 'USD';\n\n /**\n * Maximum value\n */\n @Prop() max: number;\n\n /**\n * Minimum value\n */\n @Prop() min: number;\n\n /**\n * Override integer length\n * integer is the number before the decimal point\n */\n @Prop() integerLength = 13;\n @Watch('integerLength')\n validateIntegerLength(newValue: MgInputNumeric['integerLength']): void {\n if (newValue < 1) {\n throw new Error(`<mg-input-numeric> prop \"integer-length\" must be a positive number.`);\n }\n }\n\n /**\n * Override decimal length\n * decimal is the number after the decimal point\n */\n @Prop() decimalLength = 2;\n @Watch('decimalLength')\n validateDecimalLength(newValue: MgInputNumeric['decimalLength']): void {\n if (newValue < 1) {\n throw new Error(`<mg-input-numeric> prop \"decimal-length\" must be a positive number, consider using prop \"type\" to \"integer\" instead.`);\n }\n }\n\n /**\n * Define input pattern to validate\n */\n @Prop({ mutable: true }) valid: boolean;\n\n /**\n * Define input pattern error message\n */\n @Prop({ mutable: true }) invalid: boolean;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-input--numeric']);\n\n /**\n * Error message to display\n */\n @State() errorMessage: string;\n\n /**\n * Define if input has focus\n */\n @State() hasFocus: boolean;\n\n /**\n * Emited event when value change\n */\n @Event({ eventName: 'value-change' }) valueChange: EventEmitter<number>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<HTMLMgInputNumericElement['valid']>;\n\n /**\n * Display input error if it exists.\n */\n @Method()\n async displayError(): Promise<void> {\n this.checkValidity();\n this.setErrorMessage();\n this.hasDisplayedError = this.invalid;\n }\n\n /**\n * Set an error and display a custom error message.\n * This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.\n * It must be paired with an error message to display for the given context.\n * When used to set validity to `false`, you should use this method again to reset the validity to `true`.\n * @param valid - value indicating the validity\n * @param errorMessage - the error message to display\n */\n @Method()\n async setError(valid: MgInputNumeric['valid'], errorMessage: string): Promise<void> {\n if (typeof valid !== 'boolean') {\n throw new Error('<mg-input-numeric> method \"setError()\" param \"valid\" must be a boolean');\n } else if (!isValidString(errorMessage)) {\n throw new Error('<mg-input-numeric> method \"setError()\" param \"errorMessage\" must be a string');\n } else {\n this.setValidity(valid);\n this.setErrorMessage(valid ? undefined : errorMessage);\n this.hasDisplayedError = this.invalid;\n }\n }\n\n /**\n * Method to set validity values\n * @param newValue - valid new value\n */\n private setValidity(newValue: MgInputNumeric['valid']) {\n const oldValidValue = this.valid;\n this.valid = newValue;\n this.invalid = !this.valid;\n // We need to send valid event even if it is the same value\n if (this.handlerInProgress === undefined || (this.handlerInProgress === Handler.BLUR && this.valid !== oldValidValue)) this.inputValid.emit(this.valid);\n }\n\n /**\n * Checks if the given value is valid according to the defined rules.\n * @param value - The input value to validate.\n * @param regex - The regular expression for validation.\n * @param integer - The integer part of the value.\n * @param decimal - The decimal part of the value.\n * @returns Returns true if the value is valid, otherwise false.\n */\n private isValidValue(value: string, regex: RegExp, integer: string, decimal: string): boolean {\n return (\n ['', '-'].includes(value) || (regex.exec(value) !== null && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength))\n );\n }\n\n /**\n * Handles invalid input values and returns a corrected value.\n * @returns The corrected value.\n */\n private handleInvalidValue(): string | null {\n return this.storedValue ?? null;\n }\n\n /**\n * Updates the component values based on the validated input value.\n * @param newValue - The validated input value.\n */\n private updateValues(newValue: string | null): void {\n this.value = newValue;\n if (this.input !== undefined) this.input.value = this.value;\n\n this.numericValue = !['', null].includes(this.value) ? parseFloat(this.value.replace(',', '.')) : null;\n this.valueChange.emit(this.numericValue);\n\n this.readonlyValue = this.numericValue !== null ? this.formatValue(this.numericValue) : '';\n }\n\n /**\n * Displayed value in input\n * Change on focus/blur\n * @returns display value\n */\n private displayValue(): MgInputNumeric['value'] | MgInputNumeric['readonlyValue'] {\n return this.hasFocus ? this.value : this.readonlyValue;\n }\n\n /**\n * Handle input event\n */\n private handleInput = (): void => {\n // Check validity\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n }\n this.value = this.input.value;\n };\n\n /**\n * Handle focus event\n */\n private handleFocus = (): void => {\n this.hasFocus = true;\n };\n\n /**\n * Handle blur event\n */\n private handleBlur = (): void => {\n if (this.value === '-') this.value = '';\n // Display Error\n this.handlerInProgress = Handler.BLUR;\n this.displayError().finally(() => {\n // reset guard\n this.handlerInProgress = undefined;\n this.hasFocus = false;\n });\n };\n\n /**\n * Check if input is valid\n */\n private checkValidity = (): void => {\n this.setValidity(this.readonly || this.disabled || this.getInputError() === null);\n };\n\n /**\n * Set input error message\n * @param errorMessage - errorMessage override\n */\n private setErrorMessage = (errorMessage?: string): void => {\n // Set error message\n this.errorMessage = undefined;\n if (!this.valid) {\n const inputError = this.getInputError();\n if (errorMessage !== undefined) {\n this.errorMessage = errorMessage;\n } else if (inputError === InputError.REQUIRED) {\n this.errorMessage = this.messages.errors[inputError];\n } else {\n this.errorMessage = this.messages.errors.numeric[inputError].replace('{min}', `${this.formatValue(this.min)}`).replace('{max}', `${this.formatValue(this.max)}`);\n }\n }\n };\n\n /**\n * Get input error code\n * @returns error code\n */\n private getInputError = (): null | InputError => {\n let inputError = null;\n const hasNotEmptyValues = (toControl: unknown[]) => !toControl.some(value => [null, undefined].includes(value));\n\n if (!hasNotEmptyValues([this.input])) return inputError;\n\n // required\n if (!this.input.checkValidity() && this.input.validity.valueMissing) {\n inputError = InputError.REQUIRED;\n }\n // Min & Max\n else if (hasNotEmptyValues([this.min, this.numericValue]) && this.numericValue < this.min && this.max === undefined) {\n // Only a min value is set\n inputError = InputError.MIN;\n } else if (hasNotEmptyValues([this.max, this.numericValue]) && this.numericValue > this.max && this.min === undefined) {\n // Only a max value is set\n inputError = InputError.MAX;\n } else if (hasNotEmptyValues([this.min, this.max, this.numericValue]) && (this.numericValue < this.min || this.numericValue > this.max)) {\n // both min and max values are set\n inputError = InputError.MINMAX;\n }\n return inputError;\n };\n\n /**\n * Format value based on type\n * @param value - value to format\n * @returns formated local value\n */\n private formatValue = (value: number): string => (this.type === 'currency' ? localeCurrency(value, this.locale, this.currency) : localeNumber(value, this.locale));\n\n /**\n * Validate append slot\n */\n private validateAppendSlot = (): void => {\n const slotAppendInput: HTMLSlotElement = this.element.querySelector('[slot=\"append-input\"]');\n if (slotAppendInput !== null) {\n this.classCollection.add(slotAppendInput.nodeName === 'MG-BUTTON' ? 'mg-c-input--is-input-group-append' : 'mg-c-input--is-append-input-slot-content');\n }\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n * @returns timeout\n */\n componentWillLoad(): ReturnType<typeof setTimeout> {\n // Get locales\n const locales = initLocales(this.element);\n this.locale = locales.locale;\n this.messages = locales.messages;\n // Validate component config\n this.validateType(this.type);\n this.validateIntegerLength(this.integerLength);\n this.validateDecimalLength(this.decimalLength);\n // validate value\n this.validateValue(this.value);\n this.validateAppendSlot();\n // Check validity when component is ready\n // return a promise to process action only in the FIRST render().\n // https://stenciljs.com/docs/component-lifecycle#componentwillload\n return setTimeout(() => {\n this.checkValidity();\n }, 0);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <MgInput\n identifier={this.identifier}\n classCollection={this.classCollection}\n ariaDescribedbyIDs={[]}\n label={this.label}\n labelOnTop={this.labelOnTop}\n labelHide={this.labelHide}\n required={this.required}\n readonly={this.readonly}\n mgWidth={this.mgWidth}\n disabled={this.disabled}\n value={this.value}\n readonlyValue={this.readonlyValue}\n tooltip={this.tooltip}\n helpText={this.helpText}\n errorMessage={this.errorMessage}\n isFieldset={false}\n >\n <input\n type=\"text\"\n class=\"mg-c-input__box\"\n value={this.displayValue()}\n id={this.identifier}\n name={this.name}\n placeholder={this.placeholder}\n title={this.placeholder}\n disabled={this.disabled}\n required={this.required}\n aria-invalid={(this.invalid === true).toString()}\n onInput={this.handleInput}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n ref={(el: HTMLInputElement) => {\n if (el !== null) this.input = el;\n }}\n />\n <slot name=\"append-input\"></slot>\n </MgInput>\n );\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { h } from "@stencil/core";
|
|
2
2
|
import { MgInput } from "../MgInput";
|
|
3
3
|
import { Handler } from "../MgInput.conf";
|
|
4
|
-
import { ClassList, isValidString } from "
|
|
4
|
+
import { ClassList, isValidString } from "@mgdis/stencil-helpers";
|
|
5
5
|
import { initLocales } from "../../../../locales";
|
|
6
6
|
export class MgInputPassword {
|
|
7
7
|
constructor() {
|
package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mg-input-password.js","sourceRoot":"","sources":["../../../../../src/components/molecules/inputs/mg-input-password/mg-input-password.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAgB,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,OAAO,EAAS,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,aAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, h, Prop, EventEmitter, State, Method, Watch } from '@stencil/core';\nimport { MgInput } from '../MgInput';\nimport { Handler, Width } from '../MgInput.conf';\nimport { ClassList, isValidString } from '../../../../utils/components.utils';\nimport { initLocales } from '../../../../locales';\n\n@Component({\n tag: 'mg-input-password',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-input-password.css',\n shadow: true,\n})\nexport class MgInputPassword {\n /************\n * Internal *\n ************/\n\n // HTML selector\n private input: HTMLInputElement;\n\n // Locales\n private messages;\n\n // hasDisplayedError (triggered by blur event)\n private hasDisplayedError = false;\n private handlerInProgress: Handler;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgInputPasswordElement;\n\n /**\n * Component value\n */\n @Prop({ mutable: true, reflect: true }) value: string;\n @Watch('value')\n handleValue(newValue: string): void {\n this.valueChange.emit(newValue);\n }\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n */\n @Prop() identifier!: string;\n\n /**\n * Input name\n * If not set the value equals the identifier\n */\n @Prop() name: string = this.identifier;\n\n /**\n * Input label\n */\n @Prop() label!: string;\n\n /**\n * Define if label is displayed on top\n */\n @Prop() labelOnTop: boolean;\n\n /**\n * Define if label is visible\n */\n @Prop() labelHide = false;\n\n /**\n * Input placeholder.\n * It should be a word or short phrase that demonstrates the expected type of data, not a replacement for labels or help text.\n */\n @Prop() placeholder: string;\n\n /**\n * Define if input is required\n */\n @Prop() required = false;\n\n /**\n * Define if input is readonly\n */\n @Prop() readonly = false;\n\n /**\n * Define if input is disabled\n */\n @Prop() disabled = false;\n @Watch('required')\n @Watch('readonly')\n @Watch('disabled')\n handleValidityChange(newValue: boolean, _oldValue: boolean, prop: string): void {\n if (this.input !== undefined) {\n this.input[prop] = newValue;\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n this.hasDisplayedError = false;\n }\n }\n }\n\n /**\n * Define input width\n */\n @Prop() mgWidth: Width = 'full';\n\n /**\n * Add a tooltip message next to the input\n */\n @Prop() tooltip: string;\n\n /**\n * Add a help text under the input, usually expected data format and example\n */\n @Prop() helpText: string;\n\n /**\n * Define input valid state\n */\n @Prop({ mutable: true }) valid: boolean;\n\n /**\n * Define input invalid state\n */\n @Prop({ mutable: true }) invalid: boolean;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-input--password']);\n\n /**\n * Error message to display\n */\n @State() errorMessage: string;\n\n /**\n * Emited event when value change\n */\n @Event({ eventName: 'value-change' }) valueChange: EventEmitter<HTMLMgInputPasswordElement['value']>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<HTMLMgInputPasswordElement['valid']>;\n\n /**\n * Display input error if it exists.\n */\n @Method()\n async displayError(): Promise<void> {\n this.checkValidity();\n this.setErrorMessage();\n this.hasDisplayedError = this.invalid;\n }\n\n /**\n * Set an error and display a custom error message.\n * This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.\n * It must be paired with an error message to display for the given context.\n * When used to set validity to `false`, you should use this method again to reset the validity to `true`.\n * @param valid - value indicating the validity\n * @param errorMessage - the error message to display\n */\n @Method()\n async setError(valid: MgInputPassword['valid'], errorMessage: string): Promise<void> {\n if (typeof valid !== 'boolean') {\n throw new Error('<mg-input-password> method \"setError()\" param \"valid\" must be a boolean');\n } else if (!isValidString(errorMessage)) {\n throw new Error('<mg-input-password> method \"setError()\" param \"errorMessage\" must be a string');\n } else {\n this.setValidity(valid);\n this.setErrorMessage(valid ? undefined : errorMessage);\n this.hasDisplayedError = this.invalid;\n }\n }\n\n /**\n * Method to set validity values\n * @param newValue - valid new value\n */\n private setValidity(newValue: MgInputPassword['valid']) {\n const oldValidValue = this.valid;\n this.valid = newValue;\n this.invalid = !this.valid;\n // We need to send valid event even if it is the same value\n if (this.handlerInProgress === undefined || (this.handlerInProgress === Handler.BLUR && this.valid !== oldValidValue)) this.inputValid.emit(this.valid);\n }\n\n /**\n * Handle input event\n */\n private handleInput = (): void => {\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n }\n this.value = this.input.value;\n };\n\n /**\n * Handle blur event\n */\n private handleBlur = (): void => {\n this.handlerInProgress = Handler.BLUR;\n this.displayError().finally(() => {\n // reset guard\n this.handlerInProgress = undefined;\n });\n };\n\n /**\n * Check if input is valid\n */\n private checkValidity = (): void => {\n this.setValidity(this.readonly || this.disabled || (this.input?.checkValidity !== undefined ? this.input.checkValidity() : true));\n };\n\n /**\n * Set input error message\n * @param errorMessage - errorMessage override\n */\n private setErrorMessage = (errorMessage?: string): void => {\n // Set error message\n this.errorMessage = undefined;\n if (!this.valid) {\n if (errorMessage !== undefined) {\n this.errorMessage = errorMessage;\n }\n // required\n else if (this.input.validity.valueMissing) {\n this.errorMessage = this.messages.errors.required;\n }\n }\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n * @returns timeout\n */\n componentWillLoad(): ReturnType<typeof setTimeout> {\n // Get locales\n this.messages = initLocales(this.element).messages;\n // Check validity when component is ready\n // return a promise to process action only in the FIRST render().\n // https://stenciljs.com/docs/component-lifecycle#componentwillload\n return setTimeout(() => {\n this.checkValidity();\n }, 0);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <MgInput\n identifier={this.identifier}\n classCollection={this.classCollection}\n ariaDescribedbyIDs={[]}\n label={this.label}\n labelOnTop={this.labelOnTop}\n labelHide={this.labelHide}\n required={this.required}\n readonly={this.readonly}\n mgWidth={this.mgWidth}\n disabled={this.disabled}\n value={this.value}\n readonlyValue={this.value !== undefined ? '•'.repeat(this.value.length) : undefined}\n tooltip={this.tooltip}\n helpText={this.helpText}\n errorMessage={this.errorMessage}\n isFieldset={false}\n >\n <input\n type=\"password\"\n class=\"mg-c-input__box\"\n value={this.value}\n id={this.identifier}\n name={this.name}\n placeholder={this.placeholder}\n title={this.placeholder}\n disabled={this.disabled}\n required={this.required}\n aria-invalid={(this.invalid === true).toString()}\n onInput={this.handleInput}\n onBlur={this.handleBlur}\n ref={(el: HTMLInputElement) => {\n if (el !== null) this.input = el;\n }}\n />\n </MgInput>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mg-input-password.js","sourceRoot":"","sources":["../../../../../src/components/molecules/inputs/mg-input-password/mg-input-password.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAgB,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,OAAO,EAAS,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAOlD,MAAM,OAAO,eAAe;;QAW1B,8CAA8C;QACtC,sBAAiB,GAAG,KAAK,CAAC;QAyKlC;;WAEG;QACK,gBAAW,GAAG,GAAS,EAAE;YAC/B,IAAI,CAAC,aAAa,EAAE,CAAC;YACrB,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;gBAC3B,IAAI,CAAC,eAAe,EAAE,CAAC;YACzB,CAAC;YACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAA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;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, h, Prop, EventEmitter, State, Method, Watch } from '@stencil/core';\nimport { MgInput } from '../MgInput';\nimport { Handler, Width } from '../MgInput.conf';\nimport { ClassList, isValidString } from '@mgdis/stencil-helpers';\nimport { initLocales } from '../../../../locales';\n\n@Component({\n tag: 'mg-input-password',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-input-password.css',\n shadow: true,\n})\nexport class MgInputPassword {\n /************\n * Internal *\n ************/\n\n // HTML selector\n private input: HTMLInputElement;\n\n // Locales\n private messages;\n\n // hasDisplayedError (triggered by blur event)\n private hasDisplayedError = false;\n private handlerInProgress: Handler;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgInputPasswordElement;\n\n /**\n * Component value\n */\n @Prop({ mutable: true, reflect: true }) value: string;\n @Watch('value')\n handleValue(newValue: string): void {\n this.valueChange.emit(newValue);\n }\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n */\n @Prop() identifier!: string;\n\n /**\n * Input name\n * If not set the value equals the identifier\n */\n @Prop() name: string = this.identifier;\n\n /**\n * Input label\n */\n @Prop() label!: string;\n\n /**\n * Define if label is displayed on top\n */\n @Prop() labelOnTop: boolean;\n\n /**\n * Define if label is visible\n */\n @Prop() labelHide = false;\n\n /**\n * Input placeholder.\n * It should be a word or short phrase that demonstrates the expected type of data, not a replacement for labels or help text.\n */\n @Prop() placeholder: string;\n\n /**\n * Define if input is required\n */\n @Prop() required = false;\n\n /**\n * Define if input is readonly\n */\n @Prop() readonly = false;\n\n /**\n * Define if input is disabled\n */\n @Prop() disabled = false;\n @Watch('required')\n @Watch('readonly')\n @Watch('disabled')\n handleValidityChange(newValue: boolean, _oldValue: boolean, prop: string): void {\n if (this.input !== undefined) {\n this.input[prop] = newValue;\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n this.hasDisplayedError = false;\n }\n }\n }\n\n /**\n * Define input width\n */\n @Prop() mgWidth: Width = 'full';\n\n /**\n * Add a tooltip message next to the input\n */\n @Prop() tooltip: string;\n\n /**\n * Add a help text under the input, usually expected data format and example\n */\n @Prop() helpText: string;\n\n /**\n * Define input valid state\n */\n @Prop({ mutable: true }) valid: boolean;\n\n /**\n * Define input invalid state\n */\n @Prop({ mutable: true }) invalid: boolean;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-input--password']);\n\n /**\n * Error message to display\n */\n @State() errorMessage: string;\n\n /**\n * Emited event when value change\n */\n @Event({ eventName: 'value-change' }) valueChange: EventEmitter<HTMLMgInputPasswordElement['value']>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<HTMLMgInputPasswordElement['valid']>;\n\n /**\n * Display input error if it exists.\n */\n @Method()\n async displayError(): Promise<void> {\n this.checkValidity();\n this.setErrorMessage();\n this.hasDisplayedError = this.invalid;\n }\n\n /**\n * Set an error and display a custom error message.\n * This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.\n * It must be paired with an error message to display for the given context.\n * When used to set validity to `false`, you should use this method again to reset the validity to `true`.\n * @param valid - value indicating the validity\n * @param errorMessage - the error message to display\n */\n @Method()\n async setError(valid: MgInputPassword['valid'], errorMessage: string): Promise<void> {\n if (typeof valid !== 'boolean') {\n throw new Error('<mg-input-password> method \"setError()\" param \"valid\" must be a boolean');\n } else if (!isValidString(errorMessage)) {\n throw new Error('<mg-input-password> method \"setError()\" param \"errorMessage\" must be a string');\n } else {\n this.setValidity(valid);\n this.setErrorMessage(valid ? undefined : errorMessage);\n this.hasDisplayedError = this.invalid;\n }\n }\n\n /**\n * Method to set validity values\n * @param newValue - valid new value\n */\n private setValidity(newValue: MgInputPassword['valid']) {\n const oldValidValue = this.valid;\n this.valid = newValue;\n this.invalid = !this.valid;\n // We need to send valid event even if it is the same value\n if (this.handlerInProgress === undefined || (this.handlerInProgress === Handler.BLUR && this.valid !== oldValidValue)) this.inputValid.emit(this.valid);\n }\n\n /**\n * Handle input event\n */\n private handleInput = (): void => {\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n }\n this.value = this.input.value;\n };\n\n /**\n * Handle blur event\n */\n private handleBlur = (): void => {\n this.handlerInProgress = Handler.BLUR;\n this.displayError().finally(() => {\n // reset guard\n this.handlerInProgress = undefined;\n });\n };\n\n /**\n * Check if input is valid\n */\n private checkValidity = (): void => {\n this.setValidity(this.readonly || this.disabled || (this.input?.checkValidity !== undefined ? this.input.checkValidity() : true));\n };\n\n /**\n * Set input error message\n * @param errorMessage - errorMessage override\n */\n private setErrorMessage = (errorMessage?: string): void => {\n // Set error message\n this.errorMessage = undefined;\n if (!this.valid) {\n if (errorMessage !== undefined) {\n this.errorMessage = errorMessage;\n }\n // required\n else if (this.input.validity.valueMissing) {\n this.errorMessage = this.messages.errors.required;\n }\n }\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n * @returns timeout\n */\n componentWillLoad(): ReturnType<typeof setTimeout> {\n // Get locales\n this.messages = initLocales(this.element).messages;\n // Check validity when component is ready\n // return a promise to process action only in the FIRST render().\n // https://stenciljs.com/docs/component-lifecycle#componentwillload\n return setTimeout(() => {\n this.checkValidity();\n }, 0);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <MgInput\n identifier={this.identifier}\n classCollection={this.classCollection}\n ariaDescribedbyIDs={[]}\n label={this.label}\n labelOnTop={this.labelOnTop}\n labelHide={this.labelHide}\n required={this.required}\n readonly={this.readonly}\n mgWidth={this.mgWidth}\n disabled={this.disabled}\n value={this.value}\n readonlyValue={this.value !== undefined ? '•'.repeat(this.value.length) : undefined}\n tooltip={this.tooltip}\n helpText={this.helpText}\n errorMessage={this.errorMessage}\n isFieldset={false}\n >\n <input\n type=\"password\"\n class=\"mg-c-input__box\"\n value={this.value}\n id={this.identifier}\n name={this.name}\n placeholder={this.placeholder}\n title={this.placeholder}\n disabled={this.disabled}\n required={this.required}\n aria-invalid={(this.invalid === true).toString()}\n onInput={this.handleInput}\n onBlur={this.handleBlur}\n ref={(el: HTMLInputElement) => {\n if (el !== null) this.input = el;\n }}\n />\n </MgInput>\n );\n }\n}\n"]}
|