@mgdis/mg-components 5.19.2 → 5.19.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{components.utils-dc9c8a53.js → components.utils-69435877.js} +2 -2
- package/dist/cjs/components.utils-69435877.js.map +1 -0
- package/dist/cjs/{index-c042e24b.js → index-60dd0c56.js} +143 -58
- package/dist/cjs/index-60dd0c56.js.map +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mg-action-more_34.cjs.entry.js +306 -238
- package/dist/cjs/mg-action-more_34.cjs.entry.js.map +1 -1
- package/dist/cjs/mg-components.cjs.js +3 -3
- package/dist/cjs/mg-components.cjs.js.map +1 -1
- package/dist/cjs/mg-item-more.cjs.entry.js +2 -2
- package/dist/cjs/mg-item-more.cjs.entry.js.map +1 -1
- package/dist/collection/assets/icons/index.js +190 -182
- package/dist/collection/collection-manifest.json +3 -3
- package/dist/collection/components/atoms/mg-button/mg-button.js +15 -0
- package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -1
- package/dist/collection/components/atoms/mg-button/test/mg-button.e2e.js +1 -1
- package/dist/collection/components/atoms/mg-button/test/mg-button.e2e.js.map +1 -1
- package/dist/collection/components/atoms/mg-button/test/mg-button.spec.js +54 -4
- package/dist/collection/components/atoms/mg-button/test/mg-button.spec.js.map +1 -1
- package/dist/collection/components/atoms/mg-card/test/mg-card.e2e.js +2 -2
- package/dist/collection/components/atoms/mg-card/test/mg-card.e2e.js.map +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +1 -1
- package/dist/collection/components/atoms/mg-tooltip/test/mg-tooltip.spec.js +1 -1
- package/dist/collection/components/atoms/mg-tooltip/test/mg-tooltip.spec.js.map +1 -1
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +8 -0
- package/dist/collection/components/molecules/inputs/MgInput.conf.js.map +1 -1
- package/dist/collection/components/molecules/inputs/MgInput.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js +2 -2
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +13 -12
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.spec.js +4 -10
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.spec.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +9 -2
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/test/mg-input-date.spec.js +4 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/test/mg-input-date.spec.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +11 -4
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-numeric/test/mg-input-numeric.spec.js +4 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/test/mg-input-numeric.spec.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +9 -2
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/test/mg-input-password.spec.js +4 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/test/mg-input-password.spec.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +7 -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-radio/test/mg-input-radio.spec.js +4 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/test/mg-input-radio.spec.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +9 -2
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-select/test/mg-input-select.spec.js +4 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/test/mg-input-select.spec.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.conf.js +0 -4
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.conf.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +9 -2
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.spec.js +2 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.spec.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +9 -2
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-textarea/test/mg-input-textarea.spec.js +2 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/test/mg-input-textarea.spec.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.e2e.playwright.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.e2e.playwright.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/menu/mg-menu-item/test/mg-menu-item.e2e.playwright.js +2 -2
- package/dist/collection/components/molecules/menu/mg-menu-item/test/mg-menu-item.e2e.playwright.js.map +1 -1
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.conf.js.map +1 -1
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +2 -2
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js.map +1 -1
- package/dist/collection/components/molecules/mg-action-more/test/mg-action-more.e2e.playwright.js +8 -0
- package/dist/collection/components/molecules/mg-action-more/test/mg-action-more.e2e.playwright.js.map +1 -1
- package/dist/collection/components/molecules/mg-action-more/test/mg-action-more.spec.js +8 -0
- package/dist/collection/components/molecules/mg-action-more/test/mg-action-more.spec.js.map +1 -1
- package/dist/collection/components/molecules/mg-form/mg-form.js +1 -9
- package/dist/collection/components/molecules/mg-form/mg-form.js.map +1 -1
- package/dist/collection/components/molecules/mg-form/test/mg-form.spec.js +44 -29
- package/dist/collection/components/molecules/mg-form/test/mg-form.spec.js.map +1 -1
- package/dist/collection/components/molecules/mg-modal/test/mg-modal.e2e.playwright.js +1 -1
- package/dist/collection/components/molecules/mg-modal/test/mg-modal.e2e.playwright.js.map +1 -1
- package/dist/collection/components/molecules/mg-panel/test/mg-panel.e2e.playwright.js +1 -1
- package/dist/collection/components/molecules/mg-panel/test/mg-panel.e2e.playwright.js.map +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +1 -1
- package/dist/collection/utils/behaviors.utils.js.map +1 -1
- package/dist/collection/utils/components.utils.js +1 -1
- package/dist/collection/utils/components.utils.js.map +1 -1
- package/dist/collection/utils/components.utils.spec.js +5 -0
- package/dist/collection/utils/components.utils.spec.js.map +1 -1
- package/dist/components/MgInput.js +9 -1
- package/dist/components/MgInput.js.map +1 -1
- package/dist/components/components.utils.js +1 -1
- package/dist/components/components.utils.js.map +1 -1
- package/dist/components/mg-action-more.js +1 -1
- package/dist/components/mg-action-more.js.map +1 -1
- package/dist/components/mg-button2.js +15 -0
- package/dist/components/mg-button2.js.map +1 -1
- package/dist/components/mg-form.js +1 -9
- package/dist/components/mg-form.js.map +1 -1
- package/dist/components/mg-icon2.js +198 -182
- package/dist/components/mg-icon2.js.map +1 -1
- package/dist/components/mg-input-checkbox-paginated2.js +2 -2
- package/dist/components/mg-input-checkbox-paginated2.js.map +1 -1
- package/dist/components/mg-input-checkbox.js +13 -12
- package/dist/components/mg-input-checkbox.js.map +1 -1
- package/dist/components/mg-input-date.js +9 -3
- package/dist/components/mg-input-date.js.map +1 -1
- package/dist/components/mg-input-numeric.js +11 -5
- package/dist/components/mg-input-numeric.js.map +1 -1
- package/dist/components/mg-input-password.js +9 -3
- package/dist/components/mg-input-password.js.map +1 -1
- package/dist/components/mg-input-radio.js +8 -3
- package/dist/components/mg-input-radio.js.map +1 -1
- package/dist/components/mg-input-select2.js +9 -3
- package/dist/components/mg-input-select2.js.map +1 -1
- package/dist/components/mg-input-text2.js +9 -3
- package/dist/components/mg-input-text2.js.map +1 -1
- package/dist/components/mg-input-textarea.js +9 -3
- package/dist/components/mg-input-textarea.js.map +1 -1
- package/dist/components/mg-item-more.js.map +1 -1
- package/dist/components/mg-menu-item2.js +2 -2
- package/dist/components/mg-menu-item2.js.map +1 -1
- package/dist/components/mg-message.js +1 -1
- package/dist/components/mg-message.js.map +1 -1
- package/dist/components/mg-popover-content2.js +1 -1
- package/dist/components/mg-popover-content2.js.map +1 -1
- package/dist/components/popper.js +6 -12
- package/dist/components/popper.js.map +1 -1
- package/dist/esm/{components.utils-0f76010d.js → components.utils-6cf27db1.js} +2 -2
- package/dist/esm/components.utils-6cf27db1.js.map +1 -0
- package/dist/esm/{index-ce01e63b.js → index-0f833068.js} +143 -58
- package/dist/esm/index-0f833068.js.map +1 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mg-action-more_34.entry.js +306 -238
- package/dist/esm/mg-action-more_34.entry.js.map +1 -1
- package/dist/esm/mg-components.js +4 -4
- package/dist/esm/mg-components.js.map +1 -1
- package/dist/esm/mg-item-more.entry.js +2 -2
- package/dist/esm/mg-item-more.entry.js.map +1 -1
- package/dist/mg-components/mg-components.css +1 -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-10ed4425.entry.js +2 -0
- package/dist/mg-components/p-10ed4425.entry.js.map +1 -0
- package/dist/mg-components/{p-c9e2c669.js → p-36a51c5e.js} +2 -2
- package/dist/mg-components/p-36a51c5e.js.map +1 -0
- package/dist/mg-components/{p-01ebc95a.entry.js → p-91feda5a.entry.js} +2 -2
- package/dist/mg-components/p-91feda5a.entry.js.map +1 -0
- package/dist/mg-components/p-9b12021b.js +3 -0
- package/dist/mg-components/p-9b12021b.js.map +1 -0
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +4 -0
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +7 -0
- package/dist/types/components/molecules/inputs/MgInput.d.ts +2 -1
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +1 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +1 -0
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +1 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +1 -0
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +1 -0
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.conf.d.ts +1 -6
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +1 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +1 -0
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +1 -1
- package/dist/types/components/molecules/mg-action-more/mg-action-more.conf.d.ts +1 -0
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +0 -1
- package/dist/types/components.d.ts +2 -2
- package/package.json +35 -35
- package/dist/cjs/components.utils-dc9c8a53.js.map +0 -1
- package/dist/cjs/index-c042e24b.js.map +0 -1
- package/dist/esm/components.utils-0f76010d.js.map +0 -1
- package/dist/esm/index-ce01e63b.js.map +0 -1
- package/dist/mg-components/p-01ebc95a.entry.js.map +0 -1
- package/dist/mg-components/p-1aa89acf.js +0 -3
- package/dist/mg-components/p-1aa89acf.js.map +0 -1
- package/dist/mg-components/p-71a5a848.entry.js +0 -2
- package/dist/mg-components/p-71a5a848.entry.js.map +0 -1
- package/dist/mg-components/p-c9e2c669.js.map +0 -1
|
@@ -42,9 +42,9 @@ h("ul", { class: {
|
|
|
42
42
|
}, role: "list", "aria-describedby": props.displaySearchInput ? 'search-results' : undefined, "aria-label": props.displaySearchInput ? props.messages.searchResults : undefined, "aria-live": props.displaySearchInput ? 'polite' : undefined, id: props.id }, props.checkboxes
|
|
43
43
|
.filter(item => !props.readonly || item.value)
|
|
44
44
|
.map(input => {
|
|
45
|
-
var _a;
|
|
45
|
+
var _a, _b;
|
|
46
46
|
return (h("li", { key: input._id, class: { 'mg-c-input__input-group': true, 'mg-c-input__input-group--disabled': props.disabled || input.disabled } },
|
|
47
|
-
h("input", { type: "checkbox", id: input._id, name: props.name, value: input.value
|
|
47
|
+
h("input", { type: "checkbox", id: input._id, name: props.name, value: (_a = input.value) === null || _a === void 0 ? void 0 : _a.toString(), checked: Boolean(input.value), required: input.required, "aria-invalid": ((_b = props.invalid) === null || _b === void 0 ? void 0 : _b.toString()) || 'false', disabled: props.readonly || props.disabled || input.disabled, indeterminate: input.value === null, onInput: input._handleInput, onBlur: input._handleBlur, onKeyDown: input._handleKeydown }),
|
|
48
48
|
h("label", { htmlFor: input._id }, input.title)));
|
|
49
49
|
})));
|
|
50
50
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"mg-input-checkbox-paginated2.js","mappings":";;;;;;;;;AAsBA;;;MAGa,aAAa,GAAG,CAAC,UAAU,EAAE,OAAO,EAAW;AAO5D;;;IAGY;AAAZ,WAAY,WAAW;EACrB,oCAAqB,CAAA;EACrB,4CAA6B,CAAA;AAC/B,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB;AAED;;;AAGA,IAAY,gBAGX;AAHD,WAAY,gBAAgB;EAC1B,qCAAiB,CAAA;EACjB,iCAAa,CAAA;AACf,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB;;AC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AAE,gBAAgB,EAAE,KAAK,EAAC,kDAAkD,IACzG,EAAC,mBAAmB,IAClB,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,EAAE,sBAAsB,EAAE,oBAAoB,CAAC,EAC7F,iBAAiB,EAAE,IAAI,EACvB,IAAI,EAAE,OAAO,EACb,kBAAkB,EAAE,IAAI,EACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,EAAE,EAAE,SAAS,IAAI,CAAC,WAAW,EAAE,EAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,OAAO,EAAE,IAAI,CAAC,OAAO,GACA,CACnB,CACD,EACP;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.ts","src/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.tsx","src/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.tsx"],"sourcesContent":["/**\n * interface CheckboxValue\n * use to match returned value\n */\nexport interface CheckboxValue {\n title: string;\n value: boolean | null;\n disabled?: boolean;\n required?: boolean;\n}\n\n/**\n * interface CheckboxItem\n * use to match checkbox attributes\n */\nexport interface CheckboxItem extends CheckboxValue {\n _id: string;\n _handleInput: (event: InputEvent & { target: HTMLInputElement }) => void;\n _handleBlur: () => void;\n _handleKeydown: (event: KeyboardEvent & { target: HTMLElement }) => void;\n}\n\n/**\n * List of all availables checkbox type\n */\nexport const checkboxTypes = ['checkbox', 'multi'] as const;\n\n/**\n * ChecboxType from checkbox types\n */\nexport type CheckboxType = (typeof checkboxTypes)[number];\n\n/**\n * mg-input-checkbox-paginated section kind\n */\nexport enum SectionKind {\n SELECTED = 'selected',\n NOT_SELECTED = 'not-selected',\n}\n\n/**\n * mg-input-checkbox-paginated section title kind\n */\nexport enum SectionTitleKind {\n BUTTON = 'button',\n TEXT = 'text',\n}\n\n/**\n * Base mg-input-checkbox interface\n */\nexport interface IMgInputCheckboxBase {\n readonly: boolean;\n disabled: boolean;\n name: string;\n invalid: boolean;\n}\n\n/**\n * mg-input-checkbox-list interface\n */\nexport interface MgInputCheckboxListProps extends IMgInputCheckboxBase {\n inputVerticalList: boolean;\n type: CheckboxType;\n displaySearchInput: boolean;\n messages: Record<string, unknown>;\n checkboxes: CheckboxItem[];\n id: string;\n}\n","import { FunctionalComponent, h, VNode } from '@stencil/core';\nimport { MgInputCheckboxListProps } from './mg-input-checkbox.conf';\n\n/**\n * Get checkboxes list template\n * @param props - MgInputCheckboxList Interface Props\n * @returns input template\n */\nexport const MgInputCheckboxList: FunctionalComponent<MgInputCheckboxListProps> = (props: MgInputCheckboxListProps): VNode[] => (\n // eslint-disable-next-line jsx-a11y/no-redundant-roles\n <ul\n class={{\n 'mg-c-input__input-group-container': true,\n 'mg-c-input__input-group-container--vertical': props.inputVerticalList || (props.type === 'multi' && !props.readonly),\n 'mg-c-input__input-checkbox-multi-inputs': props.type === 'multi' && !props.readonly,\n }}\n role=\"list\"\n aria-describedby={props.displaySearchInput ? 'search-results' : undefined}\n aria-label={props.displaySearchInput ? props.messages.searchResults : undefined}\n aria-live={props.displaySearchInput ? 'polite' : undefined}\n id={props.id}\n >\n {props.checkboxes\n .filter(item => !props.readonly || item.value)\n .map(input => (\n <li key={input._id} class={{ 'mg-c-input__input-group': true, 'mg-c-input__input-group--disabled': props.disabled || input.disabled }}>\n <input\n type=\"checkbox\"\n id={input._id}\n name={props.name}\n value={input.value && input.value.toString()}\n checked={Boolean(input.value)}\n required={input.required}\n aria-invalid={props.invalid?.toString() || 'false'}\n disabled={props.readonly || props.disabled || input.disabled}\n indeterminate={input.value === null}\n onInput={input._handleInput}\n onBlur={input._handleBlur}\n onKeyDown={input._handleKeydown}\n />\n <label htmlFor={input._id}>{input.title}</label>\n </li>\n ))}\n </ul>\n);\n","import { Component, h, Prop, State, Event, EventEmitter, Watch, Host } from '@stencil/core';\nimport { CheckboxItem, IMgInputCheckboxBase, SectionKind, SectionTitleKind } from '../mg-input-checkbox.conf';\nimport { MgInputCheckboxList } from '../MgInputCheckboxList';\n\n/**\n * Internal component use to manage sections instances\n */\n@Component({\n tag: 'mg-input-checkbox-paginated',\n shadow: false,\n scoped: true,\n})\nexport class MgInputCheckboxPaginated implements IMgInputCheckboxBase {\n /*************\n * Constantes *\n *************/\n private readonly offset = 10;\n\n /*************\n * Decorators *\n *************/\n\n /**\n * Define if mg-input-checkbox-list is readonly\n */\n @Prop() readonly: boolean;\n\n /**\n * Define if mg-input-checkbox-list is disabled\n */\n @Prop() disabled: boolean;\n\n /**\n * Define mg-input-checkbox input name\n */\n @Prop() name: string;\n\n /**\n * Define mg-input-checkbox input invalid\n */\n @Prop() invalid: boolean;\n\n /**\n * Define checkboxes to paginate\n */\n @Prop() checkboxes: CheckboxItem[] = [];\n @Watch('checkboxes')\n validateCheckboxes(newValue: MgInputCheckboxPaginated['checkboxes'], oldValue: MgInputCheckboxPaginated['checkboxes']): void {\n // after each array.length update we reset pagination\n // when items fill on page, we set current page to 1\n if (this.getPageCount(newValue) === 1) this.currentPage = 1;\n // when old items page numbers match the current page AND new items page number is lower than current page, we set the new last page\n else if (this.getPageCount(oldValue) === this.currentPage && this.getPageCount(newValue) < this.currentPage) this.currentPage = this.getPageCount(newValue);\n }\n\n /**\n * Define section kind\n */\n @Prop() sectionKind: SectionKind;\n @Watch('sectionKind')\n validateSectionKind(newValue: MgInputCheckboxPaginated['sectionKind']): void {\n if (newValue === SectionKind.SELECTED) this.titleKind = SectionTitleKind.BUTTON;\n else this.titleKind = SectionTitleKind.TEXT;\n }\n\n /**\n * Define component message\n */\n @Prop() messages: Record<string, string>;\n\n /**\n * Emit 'mass-action' event\n * used to informe that select-all/unselect-all button listner is triggered\n */\n @Event({ eventName: 'mass-action' }) massAction: EventEmitter<MgInputCheckboxPaginated['sectionKind']>;\n\n /**\n * Define section title\n */\n @State() titleKind: SectionTitleKind;\n\n /**\n * Current page\n */\n @State() currentPage = 1;\n\n /**\n * Is checked items values expanded\n */\n @State() expanded = true;\n\n /***********\n * Methods *\n ***********/\n\n /**\n * Mass action handler\n */\n private massActionHandler = (): void => {\n this.massAction.emit(this.sectionKind);\n };\n\n /**\n * Toggle items button handler\n */\n private handleToggleClick = (): void => {\n this.expanded = !this.expanded;\n };\n\n /**\n * Method to get a array range\n * @param from - array start index\n * @param to - array end index\n * @returns array's range\n */\n private getArrayRange = <ItemType,>(array: ItemType[], from: number, to: number): ItemType[] => array.slice(from, to);\n\n /**\n * Get from and to index\n * @returns [from,to] index\n */\n private getFromToIndexes(): number[] {\n const isFirstPage = this.currentPage === 1;\n const checkboxItemsFromIndex = isFirstPage ? 0 : (this.currentPage - 1) * this.offset;\n const checkboxItemsToIndex = isFirstPage ? this.offset : this.currentPage * this.offset;\n return [checkboxItemsFromIndex, checkboxItemsToIndex];\n }\n\n /**\n * Method to get page count from items\n * @param items - items to count\n * @returns page count from items\n */\n private getPageCount = (item: unknown[]): number => Math.ceil(item.length / this.offset);\n\n /**\n * Handle mg-pagination current page change event\n * @param event - pagination current page change event\n */\n private handleCurrentPageChange = (event: CustomEvent): void => {\n this.currentPage = Number(event.detail);\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n */\n componentWillLoad(): void {\n this.validateSectionKind(this.sectionKind);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n const [checkboxItemsFromIndex, checkboxItemsToIndex] = this.getFromToIndexes();\n const itemsContainerId = `items-${this.sectionKind}-container`;\n\n const getText = (checkboxes: CheckboxItem[]): HTMLElement => <em>{`${this.messages[checkboxes.length > 1 ? 'titlePlurial' : 'title']} (${checkboxes.length})`}</em>;\n\n return (\n <Host hidden={this.checkboxes.length < 1}>\n <div class=\"mg-c-input__input-checkbox-multi-section-header\">\n {this.titleKind === SectionTitleKind.BUTTON ? (\n <mg-button variant=\"flat\" onClick={this.handleToggleClick} aria-controls={itemsContainerId} aria-expanded={this.expanded.toString()}>\n <mg-icon icon={this.expanded ? 'chevron-up' : 'chevron-down'} size=\"small\"></mg-icon>\n <span class=\"mg-c-input__input-checkbox-multi-text\">{getText(this.checkboxes)}</span>\n </mg-button>\n ) : (\n <p class=\"mg-c-input__input-checkbox-multi-title\">{getText(this.checkboxes)}</p>\n )}\n {((this.sectionKind === SectionKind.SELECTED && this.expanded) || this.sectionKind === SectionKind.NOT_SELECTED) && (\n <mg-button variant=\"link\" onClick={this.massActionHandler}>\n {this.messages.action}\n </mg-button>\n )}\n {this.expanded && this.getPageCount(this.checkboxes) > 1 && (\n <mg-pagination\n key=\"search-pagination\"\n totalPages={this.getPageCount(this.checkboxes)}\n currentPage={this.currentPage > 1 ? this.currentPage : 1}\n onCurrent-page-change={this.handleCurrentPageChange}\n hideNavigationLabels={true}\n hidePageCount={true}\n identifier={`input-checkbox-pagination-${this.sectionKind}`}\n ></mg-pagination>\n )}\n </div>\n <div hidden={!this.expanded} id={itemsContainerId} class=\"mg-c-input__input-checkbox-multi-section-content\">\n <MgInputCheckboxList\n checkboxes={this.getArrayRange(this.checkboxes, checkboxItemsFromIndex, checkboxItemsToIndex)}\n inputVerticalList={true}\n type={'multi'}\n displaySearchInput={true}\n messages={this.messages}\n id={`items-${this.sectionKind}`}\n readonly={this.readonly}\n disabled={this.disabled}\n name={this.name}\n invalid={this.invalid}\n ></MgInputCheckboxList>\n </div>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"mg-input-checkbox-paginated2.js","mappings":";;;;;;;;;AAsBA;;;MAGa,aAAa,GAAG,CAAC,UAAU,EAAE,OAAO,EAAW;AAO5D;;;IAGY;AAAZ,WAAY,WAAW;EACrB,oCAAqB,CAAA;EACrB,4CAA6B,CAAA;AAC/B,CAAC,EAHW,WAAW,KAAX,W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nB,UAAU,EAAE,6BAA6B,IAAI,CAAC,WAAW,EAAE,GAC5C,CAClB,CACG,EACN,WAAK,MAAM,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAC,kDAAkD,IACzG,EAAC,mBAAmB,IAClB,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,EAAE,sBAAsB,EAAE,oBAAoB,CAAC,EAC7F,iBAAiB,EAAE,IAAI,EACvB,IAAI,EAAE,OAAO,EACb,kBAAkB,EAAE,IAAI,EACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,EAAE,EAAE,SAAS,IAAI,CAAC,WAAW,EAAE,EAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,OAAO,EAAE,IAAI,CAAC,OAAO,GACA,CACnB,CACD,EACP;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.ts","src/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.tsx","src/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.tsx"],"sourcesContent":["/**\n * interface CheckboxValue\n * use to match returned value\n */\nexport interface CheckboxValue {\n title: string;\n value: boolean | null;\n disabled?: boolean;\n required?: boolean;\n}\n\n/**\n * interface CheckboxItem\n * use to match checkbox attributes\n */\nexport interface CheckboxItem extends CheckboxValue {\n _id: string;\n _handleInput: (event: InputEvent & { target: HTMLInputElement }) => void;\n _handleBlur: () => void;\n _handleKeydown: (event: KeyboardEvent & { target: HTMLElement }) => void;\n}\n\n/**\n * List of all availables checkbox type\n */\nexport const checkboxTypes = ['checkbox', 'multi'] as const;\n\n/**\n * ChecboxType from checkbox types\n */\nexport type CheckboxType = (typeof checkboxTypes)[number];\n\n/**\n * mg-input-checkbox-paginated section kind\n */\nexport enum SectionKind {\n SELECTED = 'selected',\n NOT_SELECTED = 'not-selected',\n}\n\n/**\n * mg-input-checkbox-paginated section title kind\n */\nexport enum SectionTitleKind {\n BUTTON = 'button',\n TEXT = 'text',\n}\n\n/**\n * Base mg-input-checkbox interface\n */\nexport interface IMgInputCheckboxBase {\n readonly: boolean;\n disabled: boolean;\n name: string;\n invalid: boolean;\n}\n\n/**\n * mg-input-checkbox-list interface\n */\nexport interface MgInputCheckboxListProps extends IMgInputCheckboxBase {\n inputVerticalList: boolean;\n type: CheckboxType;\n displaySearchInput: boolean;\n messages: Record<string, unknown>;\n checkboxes: CheckboxItem[];\n id: string;\n}\n","import { FunctionalComponent, h, VNode } from '@stencil/core';\nimport { MgInputCheckboxListProps } from './mg-input-checkbox.conf';\n\n/**\n * Get checkboxes list template\n * @param props - MgInputCheckboxList Interface Props\n * @returns input template\n */\nexport const MgInputCheckboxList: FunctionalComponent<MgInputCheckboxListProps> = (props: MgInputCheckboxListProps): VNode[] => (\n // eslint-disable-next-line jsx-a11y/no-redundant-roles\n <ul\n class={{\n 'mg-c-input__input-group-container': true,\n 'mg-c-input__input-group-container--vertical': props.inputVerticalList || (props.type === 'multi' && !props.readonly),\n 'mg-c-input__input-checkbox-multi-inputs': props.type === 'multi' && !props.readonly,\n }}\n role=\"list\"\n aria-describedby={props.displaySearchInput ? 'search-results' : undefined}\n aria-label={props.displaySearchInput ? props.messages.searchResults : undefined}\n aria-live={props.displaySearchInput ? 'polite' : undefined}\n id={props.id}\n >\n {props.checkboxes\n .filter(item => !props.readonly || item.value)\n .map(input => (\n <li key={input._id} class={{ 'mg-c-input__input-group': true, 'mg-c-input__input-group--disabled': props.disabled || input.disabled }}>\n <input\n type=\"checkbox\"\n id={input._id}\n name={props.name}\n value={input.value?.toString()}\n checked={Boolean(input.value)}\n required={input.required}\n aria-invalid={props.invalid?.toString() || 'false'}\n disabled={props.readonly || props.disabled || input.disabled}\n indeterminate={input.value === null}\n onInput={input._handleInput}\n onBlur={input._handleBlur}\n onKeyDown={input._handleKeydown}\n />\n <label htmlFor={input._id}>{input.title}</label>\n </li>\n ))}\n </ul>\n);\n","import { Component, h, Prop, State, Event, EventEmitter, Watch, Host } from '@stencil/core';\nimport { CheckboxItem, IMgInputCheckboxBase, SectionKind, SectionTitleKind } from '../mg-input-checkbox.conf';\nimport { MgInputCheckboxList } from '../MgInputCheckboxList';\n\n/**\n * Internal component use to manage sections instances\n */\n@Component({\n tag: 'mg-input-checkbox-paginated',\n shadow: false,\n scoped: true,\n})\nexport class MgInputCheckboxPaginated implements IMgInputCheckboxBase {\n /*************\n * Constantes *\n *************/\n private readonly offset = 10;\n\n /*************\n * Decorators *\n *************/\n\n /**\n * Define if mg-input-checkbox-list is readonly\n */\n @Prop() readonly: boolean;\n\n /**\n * Define if mg-input-checkbox-list is disabled\n */\n @Prop() disabled: boolean;\n\n /**\n * Define mg-input-checkbox input name\n */\n @Prop() name: string;\n\n /**\n * Define mg-input-checkbox input invalid\n */\n @Prop() invalid: boolean;\n\n /**\n * Define checkboxes to paginate\n */\n @Prop() checkboxes: CheckboxItem[] = [];\n @Watch('checkboxes')\n validateCheckboxes(newValue: MgInputCheckboxPaginated['checkboxes'], oldValue: MgInputCheckboxPaginated['checkboxes']): void {\n // after each array.length update we reset pagination\n // when items fill on page, we set current page to 1\n if (this.getPageCount(newValue) === 1) this.currentPage = 1;\n // when old items page numbers match the current page AND new items page number is lower than current page, we set the new last page\n else if (this.getPageCount(oldValue) === this.currentPage && this.getPageCount(newValue) < this.currentPage) this.currentPage = this.getPageCount(newValue);\n }\n\n /**\n * Define section kind\n */\n @Prop() sectionKind: SectionKind;\n @Watch('sectionKind')\n validateSectionKind(newValue: MgInputCheckboxPaginated['sectionKind']): void {\n if (newValue === SectionKind.SELECTED) this.titleKind = SectionTitleKind.BUTTON;\n else this.titleKind = SectionTitleKind.TEXT;\n }\n\n /**\n * Define component message\n */\n @Prop() messages: Record<string, string>;\n\n /**\n * Emit 'mass-action' event\n * used to informe that select-all/unselect-all button listner is triggered\n */\n @Event({ eventName: 'mass-action' }) massAction: EventEmitter<MgInputCheckboxPaginated['sectionKind']>;\n\n /**\n * Define section title\n */\n @State() titleKind: SectionTitleKind;\n\n /**\n * Current page\n */\n @State() currentPage = 1;\n\n /**\n * Is checked items values expanded\n */\n @State() expanded = true;\n\n /***********\n * Methods *\n ***********/\n\n /**\n * Mass action handler\n */\n private massActionHandler = (): void => {\n this.massAction.emit(this.sectionKind);\n };\n\n /**\n * Toggle items button handler\n */\n private handleToggleClick = (): void => {\n this.expanded = !this.expanded;\n };\n\n /**\n * Method to get a array range\n * @param from - array start index\n * @param to - array end index\n * @returns array's range\n */\n private getArrayRange = <ItemType,>(array: ItemType[], from: number, to: number): ItemType[] => array.slice(from, to);\n\n /**\n * Get from and to index\n * @returns [from,to] index\n */\n private getFromToIndexes(): number[] {\n const isFirstPage = this.currentPage === 1;\n const checkboxItemsFromIndex = isFirstPage ? 0 : (this.currentPage - 1) * this.offset;\n const checkboxItemsToIndex = isFirstPage ? this.offset : this.currentPage * this.offset;\n return [checkboxItemsFromIndex, checkboxItemsToIndex];\n }\n\n /**\n * Method to get page count from items\n * @param items - items to count\n * @returns page count from items\n */\n private getPageCount = (item: unknown[]): number => Math.ceil(item.length / this.offset);\n\n /**\n * Handle mg-pagination current page change event\n * @param event - pagination current page change event\n */\n private handleCurrentPageChange = (event: CustomEvent): void => {\n this.currentPage = Number(event.detail);\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n */\n componentWillLoad(): void {\n this.validateSectionKind(this.sectionKind);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n const [checkboxItemsFromIndex, checkboxItemsToIndex] = this.getFromToIndexes();\n const itemsContainerId = `items-${this.sectionKind}-container`;\n\n const getText = (checkboxes: CheckboxItem[]): HTMLElement => <em>{`${this.messages[checkboxes.length > 1 ? 'titlePlurial' : 'title']} (${checkboxes.length})`}</em>;\n\n return (\n <Host hidden={this.checkboxes.length < 1}>\n <div class=\"mg-c-input__input-checkbox-multi-section-header\">\n {this.titleKind === SectionTitleKind.BUTTON ? (\n <mg-button variant=\"flat\" onClick={this.handleToggleClick} aria-controls={itemsContainerId} aria-expanded={this.expanded.toString()}>\n <mg-icon icon={this.expanded ? 'chevron-up' : 'chevron-down'} size=\"small\"></mg-icon>\n <span class=\"mg-c-input__input-checkbox-multi-text\">{getText(this.checkboxes)}</span>\n </mg-button>\n ) : (\n <p class=\"mg-c-input__input-checkbox-multi-title\">{getText(this.checkboxes)}</p>\n )}\n {((this.sectionKind === SectionKind.SELECTED && this.expanded) || this.sectionKind === SectionKind.NOT_SELECTED) && (\n <mg-button variant=\"link\" onClick={this.massActionHandler}>\n {this.messages.action}\n </mg-button>\n )}\n {this.expanded && this.getPageCount(this.checkboxes) > 1 && (\n <mg-pagination\n key=\"search-pagination\"\n totalPages={this.getPageCount(this.checkboxes)}\n currentPage={this.currentPage > 1 ? this.currentPage : 1}\n onCurrent-page-change={this.handleCurrentPageChange}\n hideNavigationLabels={true}\n hidePageCount={true}\n identifier={`input-checkbox-pagination-${this.sectionKind}`}\n ></mg-pagination>\n )}\n </div>\n <div hidden={!this.expanded} id={itemsContainerId} class=\"mg-c-input__input-checkbox-multi-section-content\">\n <MgInputCheckboxList\n checkboxes={this.getArrayRange(this.checkboxes, checkboxItemsFromIndex, checkboxItemsToIndex)}\n inputVerticalList={true}\n type={'multi'}\n displaySearchInput={true}\n messages={this.messages}\n id={`items-${this.sectionKind}`}\n readonly={this.readonly}\n disabled={this.disabled}\n name={this.name}\n invalid={this.invalid}\n ></MgInputCheckboxList>\n </div>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
-
import { M as MgInput } from './MgInput.js';
|
|
2
|
+
import { H as Handler, M as MgInput } from './MgInput.js';
|
|
3
3
|
import { b as cleanString, C as ClassList, i as isValidString } from './components.utils.js';
|
|
4
4
|
import { i as initLocales } from './index2.js';
|
|
5
5
|
import { c as checkboxTypes, S as SectionKind, M as MgInputCheckboxList, d as defineCustomElement$a } from './mg-input-checkbox-paginated2.js';
|
|
@@ -16,7 +16,7 @@ import { d as defineCustomElement$4 } from './mg-popover-content2.js';
|
|
|
16
16
|
import { d as defineCustomElement$3 } from './mg-tooltip2.js';
|
|
17
17
|
import { d as defineCustomElement$2 } from './mg-tooltip-content2.js';
|
|
18
18
|
|
|
19
|
-
const mgInputCheckboxCss = ":host{display:block}.mg-c-input__input mg-icon,.mg-c-input__error mg-icon{display:flex}.mg-c-input{display:flex;max-width:100%;min-height:var(--default-size);align-items:flex-start;margin-bottom:var(--mg-inputs-margin-bottom, 0)}.mg-c-input mg-input-title{width:var(--mg-inputs-title-width, auto);flex-shrink:var(--mg-inputs-shrink, 1);margin-top:calc((var(--default-size) - var(--font-size)*var(--line-height))/2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-c-input__error{display:inline-block;padding:.3rem .8rem;border-radius:.3rem;margin-top:.2rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-c-input__input-container{min-height:var(--default-size)}.mg-c-input__input-container>strong{display:inline-block;min-height:var(--font-size);margin-top:calc((var(--default-size) - var(--font-size)*var(--line-height))/2)}.mg-c-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-c-input__input-container .mg-c-input__help-text,.mg-c-input__input-container .mg-c-input__error{font-size:1.2rem;text-align:start}.mg-c-input.mg-c-input--label-on-top{flex-direction:column}.mg-c-input.mg-c-input--label-on-top .mg-c-input__input-container{width:100%}.mg-c-input__title{display:flex;align-items:baseline;margin-bottom:.3rem}.mg-c-input__title mg-input-title{width:auto;flex-shrink:1;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-c-input__title mg-tooltip{margin-top:0}.mg-c-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-c-input__input{display:flex}.mg-c-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size))/2)}.mg-c-input__input.mg-c-input__input--has-error .mg-c-input__box{border-color:hsl(var(--color-danger))}.mg-c-input__input+.mg-c-input__help-text,.mg-c-input__input+.mg-c-input__error{margin-top:.5rem}.mg-c-input__input .mg-c-input__box:disabled,.mg-c-input__input-group--disabled label,.mg-c-input.mg-c-input--toggle-disabled .mg-c-input__input .mg-c-input__button-toggle,.mg-c-input.mg-c-input--checkbox-multi-disabled .mg-c-input__input strong{opacity:var(--mg-disabled-opacity)}.mg-c-input__input-group-container{display:flex;flex-wrap:wrap;padding:0;margin:0;margin-top:calc((var(--default-size) - var(--font-size)*var(--line-height))/2);
|
|
19
|
+
const mgInputCheckboxCss = ":host{display:block}.mg-c-input__input mg-icon,.mg-c-input__error mg-icon{display:flex}.mg-c-input{display:flex;max-width:100%;min-height:var(--default-size);align-items:flex-start;margin-bottom:var(--mg-inputs-margin-bottom, 0)}.mg-c-input mg-input-title{width:var(--mg-inputs-title-width, auto);flex-shrink:var(--mg-inputs-shrink, 1);margin-top:calc((var(--default-size) - var(--font-size)*var(--line-height))/2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-c-input__error{display:inline-block;padding:.3rem .8rem;border-radius:.3rem;margin-top:.2rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-c-input__input-container{min-height:var(--default-size)}.mg-c-input__input-container>strong{display:inline-block;min-height:var(--font-size);margin-top:calc((var(--default-size) - var(--font-size)*var(--line-height))/2)}.mg-c-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-c-input__input-container .mg-c-input__help-text,.mg-c-input__input-container .mg-c-input__error{font-size:1.2rem;text-align:start}.mg-c-input.mg-c-input--label-on-top{flex-direction:column}.mg-c-input.mg-c-input--label-on-top .mg-c-input__input-container{width:100%}.mg-c-input__title{display:flex;align-items:baseline;margin-bottom:.3rem}.mg-c-input__title mg-input-title{width:auto;flex-shrink:1;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-c-input__title mg-tooltip{margin-top:0}.mg-c-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-c-input__input{display:flex}.mg-c-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size))/2)}.mg-c-input__input.mg-c-input__input--has-error .mg-c-input__box{border-color:hsl(var(--color-danger))}.mg-c-input__input+.mg-c-input__help-text,.mg-c-input__input+.mg-c-input__error{margin-top:.5rem}.mg-c-input__input .mg-c-input__box:disabled,.mg-c-input__input-group--disabled label,.mg-c-input.mg-c-input--toggle-disabled .mg-c-input__input .mg-c-input__button-toggle,.mg-c-input.mg-c-input--checkbox-multi-disabled .mg-c-input__input strong{opacity:var(--mg-disabled-opacity)}.mg-c-input__input-group-container{display:flex;flex-wrap:wrap;padding:0;margin:0;margin-top:calc((var(--default-size) - var(--font-size)*var(--line-height))/2);gap:1rem 2.3rem;list-style:none}.mg-c-input__input-group-container--vertical{flex-direction:column}fieldset.mg-c-input{padding:0;border:0;margin-right:0;margin-left:0}fieldset.mg-c-input input[type=radio],fieldset.mg-c-input input[type=checkbox]{width:var(--mg-input-check-size);height:var(--mg-input-check-size);flex-shrink:0;margin:calc((var(--font-size)*var(--line-height) - var(--mg-input-check-size))/2) .6rem 0 0}fieldset.mg-c-input.mg-c-input--label-on-top .mg-c-input__input-group-container{margin-top:.7rem}.mg-c-input__input-container mg-tooltip{margin-left:3rem}.mg-c-input__input-group{display:flex;align-items:start}.mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip:rect(0.1rem, 0.1rem, 0.1rem, 0.1rem) !important;clip-path:inset(50%) !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){*{animation:none !important;transition:none !important}}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi{display:flex;flex-wrap:wrap;gap:calc(var(--mg-inputs-spacer)*1.2)}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi--with-values.mg-c-input__input-checkbox-multi{gap:.4rem}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-values-container{display:flex;flex-flow:row wrap;gap:calc(0.4rem*1);padding:0;margin:0;list-style:none}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-value{display:inline-flex;min-width:var(--default-size);min-height:var(--default-size);box-sizing:border-box;align-items:center;justify-content:center;padding:calc((var(--default-size) - .2rem - var(--font-size)*var(--line-height))/2) 1.1rem;border-radius:.3rem;background-color:hsl(var(--mg-color-dark-5-hsl));font-size:var(--font-size)}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-no-result{text-align:center}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-text,.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-title{display:inline;margin:0;color:hsl(var(--mg-color-dark-40-hsl))}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-title{margin:0 1.1rem}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-sections{display:flex;flex-flow:column wrap;gap:calc(0.4rem*1)}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-sections-container{display:flex;flex-flow:column nowrap;gap:calc(0.4rem*0);max-height:80vh;padding-right:1rem;overflow-y:auto}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-section-header{display:flex;flex-flow:row wrap;gap:calc(0.4rem*2);min-height:var(--default-size);align-items:center}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-inputs{padding:.4rem calc(0.4rem*2) .4rem calc(0.4rem/2);margin:0}.mg-c-input.mg-c-input--checkbox-multi:not(.mg-c-input--label-on-top) mg-tooltip{margin-left:var(--mg-inputs-spacer)}.mg-c-input.mg-c-input--checkbox-multi mg-popover{--mg-popover-min-width:7rem;--mg-card-padding:calc(0.4rem * 2)}.mg-c-input.mg-c-input--checkbox-multi mg-popover-content [slot=content]{display:flex;flex-flow:column wrap;gap:calc(0.4rem*2)}.mg-c-input.mg-c-input--checkbox-multi mg-popover-content [slot=content] .mg-c-input__input-group{margin-left:calc(0.4rem*2)}.mg-c-input.mg-c-input--checkbox-multi mg-input-text{--mg-inputs-margin-bottom:0}";
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* type CheckboxItem validation function
|
|
@@ -75,9 +75,13 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCheckbox
|
|
|
75
75
|
* Handle blur event
|
|
76
76
|
*/
|
|
77
77
|
this.handleBlur = () => {
|
|
78
|
+
// set guard
|
|
79
|
+
this.handlerInProgress = Handler.BLUR;
|
|
78
80
|
// Check validity
|
|
79
81
|
this.checkValidity();
|
|
80
82
|
this.setErrorMessage();
|
|
83
|
+
// reset guard
|
|
84
|
+
this.handlerInProgress = undefined;
|
|
81
85
|
};
|
|
82
86
|
/**
|
|
83
87
|
* Handle input search value-change event
|
|
@@ -230,10 +234,6 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCheckbox
|
|
|
230
234
|
this.classCollection.delete(className);
|
|
231
235
|
}
|
|
232
236
|
}
|
|
233
|
-
validateDisplaySelectedValues(newValue) {
|
|
234
|
-
if (newValue !== undefined && this.type !== 'multi')
|
|
235
|
-
throw new Error('<mg-input-checkbox> prop "displaySelectedValues" can only be used with prop type "multi".');
|
|
236
|
-
}
|
|
237
237
|
handleValidityChange(newValue, _oldValue, prop) {
|
|
238
238
|
if (prop !== 'readonly')
|
|
239
239
|
this.updateCheckboxItems(prop, newValue);
|
|
@@ -297,10 +297,12 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCheckbox
|
|
|
297
297
|
* @param newValue - valid new value
|
|
298
298
|
*/
|
|
299
299
|
setValidity(newValue) {
|
|
300
|
+
const oldValidValue = this.valid;
|
|
300
301
|
this.valid = newValue;
|
|
301
302
|
this.invalid = !this.valid;
|
|
302
303
|
// We need to send valid event even if it is the same value
|
|
303
|
-
this.
|
|
304
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === Handler.BLUR && this.valid !== oldValidValue))
|
|
305
|
+
this.inputValid.emit(this.valid);
|
|
304
306
|
}
|
|
305
307
|
/**
|
|
306
308
|
* Update ckecboxes item
|
|
@@ -329,7 +331,7 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCheckbox
|
|
|
329
331
|
this.validateType(this.type);
|
|
330
332
|
this.validateValue(this.value);
|
|
331
333
|
this.validateDisabled(this.disabled);
|
|
332
|
-
this.
|
|
334
|
+
this.legendId = `${this.identifier}-title`;
|
|
333
335
|
// Check validity when component is ready
|
|
334
336
|
// return a promise to process action only in the FIRST render().
|
|
335
337
|
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
@@ -338,10 +340,11 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCheckbox
|
|
|
338
340
|
}, 0);
|
|
339
341
|
}
|
|
340
342
|
/**
|
|
341
|
-
* add listeners
|
|
343
|
+
* add listeners and DOM attributed
|
|
342
344
|
*/
|
|
343
345
|
componentDidLoad() {
|
|
344
346
|
var _a, _b;
|
|
347
|
+
this.element.shadowRoot.querySelector('legend').setAttribute('id', this.legendId);
|
|
345
348
|
this.searchInput = (_a = this.element.shadowRoot.querySelector('mg-input-text')) === null || _a === void 0 ? void 0 : _a.shadowRoot.querySelector('input');
|
|
346
349
|
(_b = this.searchInput) === null || _b === void 0 ? void 0 : _b.addEventListener('keydown', this.handleKeydown);
|
|
347
350
|
}
|
|
@@ -391,7 +394,7 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCheckbox
|
|
|
391
394
|
return (h("div", { class: { 'mg-c-input__input-container': true, 'mg-c-input__input-checkbox-multi': true, 'mg-c-input__input-checkbox-multi--with-values': this.displaySelectedValues } }, this.renderCheckboxMultiDisplaySelectedValues(selectedValuesNb), h("mg-popover", { arrowHide: true, identifier: this.getMgPopoverIdentifier(), "onDisplay-change": this.handleMgPopoverDisplayChange, ref: (el) => {
|
|
392
395
|
if (el)
|
|
393
396
|
this.mgPopover = el;
|
|
394
|
-
} }, h("mg-button", { variant: "secondary" }, h("mg-icon", { icon: "list" }), this.renderButtonText(selectedValuesNb)), h("div", { slot: "content" }, this.displaySearchInput && [
|
|
397
|
+
} }, h("mg-button", { variant: "secondary", "aria-describedby": this.legendId }, h("mg-icon", { icon: "list" }), this.renderButtonText(selectedValuesNb)), h("div", { slot: "content" }, this.displaySearchInput && [
|
|
395
398
|
h("mg-input-text", { key: "input-search", identifier: `${this.identifier}-input-search`, icon: "magnifying-glass", type: "search", placeholder: this.messages.input.checkbox.label, label: this.messages.input.checkbox.label, mgWidth: "full", value: this.searchValue, labelHide: true, displayCharacterLeft: false, name: "q", "onValue-change": this.handleSearchChange, "aria-controls": "search-results items-list" }),
|
|
396
399
|
h("p", { key: "search-results", role: "status", class: "mg-u-visually-hidden", id: "search-results" }, `${checkboxes.length} ${this.messages.input.checkbox[checkboxes.length > 0 ? 'results' : 'result']}`),
|
|
397
400
|
], this.displaySearchInput ? (h("div", { class: "mg-c-input__input-checkbox-multi-sections-container" }, this.renderCheckboxBySection(checkboxes))) : (h(MgInputCheckboxList, { checkboxes: checkboxes, inputVerticalList: true, type: this.type, readonly: this.readonly, displaySearchInput: this.displaySearchInput, messages: this.messages.input.checkbox, id: "checkboxes-list", disabled: this.disabled, name: this.name, invalid: this.invalid })), this.displaySearchInput && checkboxes.length === 0 && h("p", { class: "mg-c-input__input-checkbox-multi-no-result" }, this.messages.input.checkbox.noResult)))));
|
|
@@ -408,7 +411,6 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCheckbox
|
|
|
408
411
|
static get watchers() { return {
|
|
409
412
|
"value": ["validateValue"],
|
|
410
413
|
"type": ["validateType"],
|
|
411
|
-
"displaySelectedValues": ["validateDisplaySelectedValues"],
|
|
412
414
|
"required": ["handleValidityChange"],
|
|
413
415
|
"readonly": ["handleValidityChange"],
|
|
414
416
|
"disabled": ["handleValidityChange", "validateDisabled"],
|
|
@@ -444,7 +446,6 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCheckbox
|
|
|
444
446
|
}, undefined, {
|
|
445
447
|
"value": ["validateValue"],
|
|
446
448
|
"type": ["validateType"],
|
|
447
|
-
"displaySelectedValues": ["validateDisplaySelectedValues"],
|
|
448
449
|
"required": ["handleValidityChange"],
|
|
449
450
|
"readonly": ["handleValidityChange"],
|
|
450
451
|
"disabled": ["handleValidityChange", "validateDisabled"],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"mg-input-checkbox.js","mappings":";;;;;;;;;;;;;;;;;;AAAA,MAAM,kBAAkB,GAAG,84LAA84L;;ACQz6L;;;;;AAKA,MAAM,eAAe,GAAG,CAAC,KAAc,KACrC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;EACpB,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,KAAK,IAAI,CAAC,KAAK,KAAK,IAAI,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;MAO7JA,iBAAe;;;;;;;;IAalB,sBAAiB,GAAG,KAAK,CA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,EAAE,IAAI,CAAC,QAAQ,EACvB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,OAAO,EAAE,IAAI,CAAC,OAAO,GACA,KAEvB,IAAI,CAAC,mBAAmB,EAAE,CAC3B,CACO,EACV;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["MgInputCheckbox"],"sources":["../styles/dist/components/mg-input-checkbox.css?tag=mg-input-checkbox&encapsulation=shadow","src/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.tsx"],"sourcesContent":[":host{display:block}.mg-c-input__input mg-icon,.mg-c-input__error mg-icon{display:flex}.mg-c-input{display:flex;max-width:100%;min-height:var(--default-size);align-items:flex-start;margin-bottom:var(--mg-inputs-margin-bottom, 0)}.mg-c-input mg-input-title{width:var(--mg-inputs-title-width, auto);flex-shrink:var(--mg-inputs-shrink, 1);margin-top:calc((var(--default-size) - var(--font-size)*var(--line-height))/2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-c-input__error{display:inline-block;padding:.3rem .8rem;border-radius:.3rem;margin-top:.2rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-c-input__input-container{min-height:var(--default-size)}.mg-c-input__input-container>strong{display:inline-block;min-height:var(--font-size);margin-top:calc((var(--default-size) - var(--font-size)*var(--line-height))/2)}.mg-c-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-c-input__input-container .mg-c-input__help-text,.mg-c-input__input-container .mg-c-input__error{font-size:1.2rem;text-align:start}.mg-c-input.mg-c-input--label-on-top{flex-direction:column}.mg-c-input.mg-c-input--label-on-top .mg-c-input__input-container{width:100%}.mg-c-input__title{display:flex;align-items:baseline;margin-bottom:.3rem}.mg-c-input__title mg-input-title{width:auto;flex-shrink:1;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-c-input__title mg-tooltip{margin-top:0}.mg-c-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-c-input__input{display:flex}.mg-c-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size))/2)}.mg-c-input__input.mg-c-input__input--has-error .mg-c-input__box{border-color:hsl(var(--color-danger))}.mg-c-input__input+.mg-c-input__help-text,.mg-c-input__input+.mg-c-input__error{margin-top:.5rem}.mg-c-input__input .mg-c-input__box:disabled,.mg-c-input__input-group--disabled label,.mg-c-input.mg-c-input--toggle-disabled .mg-c-input__input .mg-c-input__button-toggle,.mg-c-input.mg-c-input--checkbox-multi-disabled .mg-c-input__input strong{opacity:var(--mg-disabled-opacity)}.mg-c-input__input-group-container{display:flex;flex-wrap:wrap;padding:0;margin:0;margin-top:calc((var(--default-size) - var(--font-size)*var(--line-height))/2);column-gap:2.3rem;list-style:none;row-gap:1rem}.mg-c-input__input-group-container--vertical{flex-direction:column}fieldset.mg-c-input{padding:0;border:0;margin-right:0;margin-left:0}fieldset.mg-c-input input[type=radio],fieldset.mg-c-input input[type=checkbox]{width:var(--mg-input-check-size);height:var(--mg-input-check-size);flex-shrink:0;margin:calc((var(--font-size)*var(--line-height) - var(--mg-input-check-size))/2) .6rem 0 0}fieldset.mg-c-input.mg-c-input--label-on-top .mg-c-input__input-group-container{margin-top:.7rem}.mg-c-input__input-container mg-tooltip{margin-left:3rem}.mg-c-input__input-group{display:flex;align-items:start}.mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip:rect(0.1rem, 0.1rem, 0.1rem, 0.1rem) !important;clip-path:inset(50%) !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media(prefers-reduced-motion){*{animation:none !important;transition:none !important}}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi{display:flex;flex-wrap:wrap;gap:calc(var(--mg-inputs-spacer)*1.2)}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi--with-values.mg-c-input__input-checkbox-multi{gap:.4rem}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-values-container{display:flex;flex-flow:row wrap;gap:calc(0.4rem * 1);padding:0;margin:0;list-style:none}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-value{display:inline-flex;min-width:var(--default-size);min-height:var(--default-size);box-sizing:border-box;align-items:center;justify-content:center;padding:calc((var(--default-size) - .2rem - var(--font-size)*var(--line-height))/2) 1.1rem;border-radius:.3rem;background-color:hsl(var(--mg-color-dark-5-hsl));font-size:var(--font-size)}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-no-result{text-align:center}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-text,.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-title{display:inline;margin:0;color:hsl(var(--mg-color-dark-40-hsl))}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-title{margin:0 1.1rem}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-sections{display:flex;flex-flow:column wrap;gap:calc(0.4rem * 1)}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-sections-container{display:flex;flex-flow:column nowrap;gap:calc(0.4rem * 0);max-height:80vh;padding-right:1rem;overflow-y:auto}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-section-header{display:flex;flex-flow:row wrap;gap:calc(0.4rem * 2);min-height:var(--default-size);align-items:center}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-inputs{padding:.4rem calc(0.4rem * 2) .4rem calc(0.4rem / 2);margin:0}.mg-c-input.mg-c-input--checkbox-multi:not(.mg-c-input--label-on-top) mg-tooltip{margin-left:var(--mg-inputs-spacer)}.mg-c-input.mg-c-input--checkbox-multi mg-popover{--mg-popover-min-width: 7rem;--mg-card-padding: calc(0.4rem * 2)}.mg-c-input.mg-c-input--checkbox-multi mg-popover-content [slot=content]{display:flex;flex-flow:column wrap;gap:calc(0.4rem * 2)}.mg-c-input.mg-c-input--checkbox-multi mg-popover-content [slot=content] .mg-c-input__input-group{margin-left:calc(0.4rem * 2)}.mg-c-input.mg-c-input--checkbox-multi mg-input-text{--mg-inputs-margin-bottom: 0}/*# sourceMappingURL=mg-input-checkbox.css.map */\n","/* 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 } from './mg-input-checkbox.conf';\nimport { MgInputCheckboxList } from './MgInputCheckboxList';\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\n private mode: 'custom' | 'auto' = 'custom';\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 /**************\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 */\n @Prop() displaySelectedValues: boolean;\n @Watch('displaySelectedValues')\n validateDisplaySelectedValues(newValue: MgInputCheckbox['displaySelectedValues']): void {\n if (newValue !== undefined && this.type !== 'multi') throw new Error('<mg-input-checkbox> prop \"displaySelectedValues\" can only be used with prop type \"multi\".');\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 }\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 }\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 * Emitted event when value change\n */\n @Event({ eventName: 'value-change' }) valueChange: EventEmitter<MgInputCheckbox['value']>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<MgInputCheckbox['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 this.valid = newValue;\n this.invalid = !this.valid;\n // We need to send valid event even if it is the same value\n 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 trak \"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 // Check validity\n this.checkValidity();\n this.setErrorMessage();\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 // reset search value\n if (!event.detail) {\n this.searchValue = '';\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 this.updateCheckboxItems('value', event.detail !== 'selected');\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 * get invalid element\n * @returns element\n */\n private getInvalidElement = (): HTMLInputElement => {\n const items: HTMLInputElement[] = Array.from(this.element.shadowRoot.querySelectorAll('input[type=\"checkbox\"]'));\n return items.find(input => input !== null && !input.disabled && !input.checkValidity());\n };\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.getInvalidElement() === undefined && this.validateRequired()));\n };\n\n /**\n * Render button text\n * @param selectedValuesNb - nb of selected values\n * @returns translated message\n */\n private renderButtonText = (selectedValuesNb: number): string => {\n let messageKey = 'editButton';\n if (this.disabled) messageKey = 'showButton';\n else if (selectedValuesNb < 1) messageKey = 'selectButton';\n\n return this.messages.input.checkbox[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 * 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.validateDisplaySelectedValues(this.displaySelectedValues);\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\n */\n componentDidLoad(): void {\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 checkbox multi display values\n * @param selectedValuesNb - selected values length\n * @returns display selected values\n */\n private renderCheckboxMultiDisplaySelectedValues(selectedValuesNb: number): HTMLElement {\n if (this.displaySelectedValues) {\n return (\n selectedValuesNb > 0 && (\n <ul role=\"list\" class=\"mg-c-input__input-checkbox-multi-values-container\">\n {this.checkboxItems\n .filter(({ value }) => value)\n .map(({ title }) => (\n <li class=\"mg-c-input__input-checkbox-multi-value\" key={title}>\n {title}\n </li>\n ))}\n </ul>\n )\n );\n } else {\n return <strong>{this.messages.input.checkbox[selectedValuesNb > 1 ? 'selectedValues' : 'selectedValue'].replace('{nb}', selectedValuesNb)}</strong>;\n }\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}></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.checkboxItems.filter(({ value }) => value).length;\n const checkboxes = this.getDisplayItems();\n\n return (\n <div class={{ 'mg-c-input__input-container': true, 'mg-c-input__input-checkbox-multi': true, 'mg-c-input__input-checkbox-multi--with-values': this.displaySelectedValues }}>\n {this.renderCheckboxMultiDisplaySelectedValues(selectedValuesNb)}\n <mg-popover\n arrowHide={true}\n identifier={this.getMgPopoverIdentifier()}\n onDisplay-change={this.handleMgPopoverDisplayChange}\n ref={(el: HTMLMgPopoverElement) => {\n if (el) this.mgPopover = el;\n }}\n >\n <mg-button variant=\"secondary\">\n <mg-icon icon=\"list\"></mg-icon>\n {this.renderButtonText(selectedValuesNb)}\n </mg-button>\n <div slot=\"content\">\n {this.displaySearchInput && [\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 ]}\n {this.displaySearchInput ? (\n <div class=\"mg-c-input__input-checkbox-multi-sections-container\">{this.renderCheckboxBySection(checkboxes)}</div>\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 </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"],"version":3}
|
|
1
|
+
{"file":"mg-input-checkbox.js","mappings":";;;;;;;;;;;;;;;;;;AAAA,MAAM,kBAAkB,GAAG,+2LAA+2L;;ACS14L;;;;;AAKA,MAAM,eAAe,GAAG,CAAC,KAAc,KACrC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;EACpB,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,KAAK,IAAI,CAAC,KAAK,KAAK,IAAI,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,IAAI,IAAI,CAAC,KAAK,KAAK,SAA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I,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,QAAQ,IACxC,EAAC,mBAAmB,IAClB,UAAU,EAAE,IAAI,CAAC,aAAa,EAC9B,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EACzC,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,kBAAkB,EAAE,IAAI,CAAC,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,KAEvB,IAAI,CAAC,mBAAmB,EAAE,CAC3B,CACO,EACV;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["MgInputCheckbox"],"sources":["../styles/dist/components/mg-input-checkbox.css?tag=mg-input-checkbox&encapsulation=shadow","src/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.tsx"],"sourcesContent":[":host{display:block}.mg-c-input__input mg-icon,.mg-c-input__error mg-icon{display:flex}.mg-c-input{display:flex;max-width:100%;min-height:var(--default-size);align-items:flex-start;margin-bottom:var(--mg-inputs-margin-bottom, 0)}.mg-c-input mg-input-title{width:var(--mg-inputs-title-width, auto);flex-shrink:var(--mg-inputs-shrink, 1);margin-top:calc((var(--default-size) - var(--font-size)*var(--line-height))/2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-c-input__error{display:inline-block;padding:.3rem .8rem;border-radius:.3rem;margin-top:.2rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-c-input__input-container{min-height:var(--default-size)}.mg-c-input__input-container>strong{display:inline-block;min-height:var(--font-size);margin-top:calc((var(--default-size) - var(--font-size)*var(--line-height))/2)}.mg-c-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-c-input__input-container .mg-c-input__help-text,.mg-c-input__input-container .mg-c-input__error{font-size:1.2rem;text-align:start}.mg-c-input.mg-c-input--label-on-top{flex-direction:column}.mg-c-input.mg-c-input--label-on-top .mg-c-input__input-container{width:100%}.mg-c-input__title{display:flex;align-items:baseline;margin-bottom:.3rem}.mg-c-input__title mg-input-title{width:auto;flex-shrink:1;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-c-input__title mg-tooltip{margin-top:0}.mg-c-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-c-input__input{display:flex}.mg-c-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size))/2)}.mg-c-input__input.mg-c-input__input--has-error .mg-c-input__box{border-color:hsl(var(--color-danger))}.mg-c-input__input+.mg-c-input__help-text,.mg-c-input__input+.mg-c-input__error{margin-top:.5rem}.mg-c-input__input .mg-c-input__box:disabled,.mg-c-input__input-group--disabled label,.mg-c-input.mg-c-input--toggle-disabled .mg-c-input__input .mg-c-input__button-toggle,.mg-c-input.mg-c-input--checkbox-multi-disabled .mg-c-input__input strong{opacity:var(--mg-disabled-opacity)}.mg-c-input__input-group-container{display:flex;flex-wrap:wrap;padding:0;margin:0;margin-top:calc((var(--default-size) - var(--font-size)*var(--line-height))/2);gap:1rem 2.3rem;list-style:none}.mg-c-input__input-group-container--vertical{flex-direction:column}fieldset.mg-c-input{padding:0;border:0;margin-right:0;margin-left:0}fieldset.mg-c-input input[type=radio],fieldset.mg-c-input input[type=checkbox]{width:var(--mg-input-check-size);height:var(--mg-input-check-size);flex-shrink:0;margin:calc((var(--font-size)*var(--line-height) - var(--mg-input-check-size))/2) .6rem 0 0}fieldset.mg-c-input.mg-c-input--label-on-top .mg-c-input__input-group-container{margin-top:.7rem}.mg-c-input__input-container mg-tooltip{margin-left:3rem}.mg-c-input__input-group{display:flex;align-items:start}.mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip:rect(0.1rem, 0.1rem, 0.1rem, 0.1rem) !important;clip-path:inset(50%) !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media(prefers-reduced-motion){*{animation:none !important;transition:none !important}}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi{display:flex;flex-wrap:wrap;gap:calc(var(--mg-inputs-spacer)*1.2)}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi--with-values.mg-c-input__input-checkbox-multi{gap:.4rem}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-values-container{display:flex;flex-flow:row wrap;gap:calc(0.4rem*1);padding:0;margin:0;list-style:none}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-value{display:inline-flex;min-width:var(--default-size);min-height:var(--default-size);box-sizing:border-box;align-items:center;justify-content:center;padding:calc((var(--default-size) - .2rem - var(--font-size)*var(--line-height))/2) 1.1rem;border-radius:.3rem;background-color:hsl(var(--mg-color-dark-5-hsl));font-size:var(--font-size)}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-no-result{text-align:center}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-text,.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-title{display:inline;margin:0;color:hsl(var(--mg-color-dark-40-hsl))}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-title{margin:0 1.1rem}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-sections{display:flex;flex-flow:column wrap;gap:calc(0.4rem*1)}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-sections-container{display:flex;flex-flow:column nowrap;gap:calc(0.4rem*0);max-height:80vh;padding-right:1rem;overflow-y:auto}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-section-header{display:flex;flex-flow:row wrap;gap:calc(0.4rem*2);min-height:var(--default-size);align-items:center}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-inputs{padding:.4rem calc(0.4rem*2) .4rem calc(0.4rem/2);margin:0}.mg-c-input.mg-c-input--checkbox-multi:not(.mg-c-input--label-on-top) mg-tooltip{margin-left:var(--mg-inputs-spacer)}.mg-c-input.mg-c-input--checkbox-multi mg-popover{--mg-popover-min-width: 7rem;--mg-card-padding: calc(0.4rem * 2)}.mg-c-input.mg-c-input--checkbox-multi mg-popover-content [slot=content]{display:flex;flex-flow:column wrap;gap:calc(0.4rem*2)}.mg-c-input.mg-c-input--checkbox-multi mg-popover-content [slot=content] .mg-c-input__input-group{margin-left:calc(0.4rem*2)}.mg-c-input.mg-c-input--checkbox-multi mg-input-text{--mg-inputs-margin-bottom: 0}/*# sourceMappingURL=mg-input-checkbox.css.map */\n","/* 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 } 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 /**************\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 }\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 }\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 * Emitted event when value change\n */\n @Event({ eventName: 'value-change' }) valueChange: EventEmitter<MgInputCheckbox['value']>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<MgInputCheckbox['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 trak \"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 // reset search value\n if (!event.detail) {\n this.searchValue = '';\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 this.updateCheckboxItems('value', event.detail !== 'selected');\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 * get invalid element\n * @returns element\n */\n private getInvalidElement = (): HTMLInputElement => {\n const items: HTMLInputElement[] = Array.from(this.element.shadowRoot.querySelectorAll('input[type=\"checkbox\"]'));\n return items.find(input => input !== null && !input.disabled && !input.checkValidity());\n };\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.getInvalidElement() === undefined && this.validateRequired()));\n };\n\n /**\n * Render button text\n * @param selectedValuesNb - nb of selected values\n * @returns translated message\n */\n private renderButtonText = (selectedValuesNb: number): string => {\n let messageKey = 'editButton';\n if (this.disabled) messageKey = 'showButton';\n else if (selectedValuesNb < 1) messageKey = 'selectButton';\n\n return this.messages.input.checkbox[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 * 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 checkbox multi display values\n * @param selectedValuesNb - selected values length\n * @returns display selected values\n */\n private renderCheckboxMultiDisplaySelectedValues(selectedValuesNb: number): HTMLElement {\n if (this.displaySelectedValues) {\n return (\n selectedValuesNb > 0 && (\n <ul role=\"list\" class=\"mg-c-input__input-checkbox-multi-values-container\">\n {this.checkboxItems\n .filter(({ value }) => value)\n .map(({ title }) => (\n <li class=\"mg-c-input__input-checkbox-multi-value\" key={title}>\n {title}\n </li>\n ))}\n </ul>\n )\n );\n } else {\n return <strong>{this.messages.input.checkbox[selectedValuesNb > 1 ? 'selectedValues' : 'selectedValue'].replace('{nb}', selectedValuesNb)}</strong>;\n }\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}></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.checkboxItems.filter(({ value }) => value).length;\n const checkboxes = this.getDisplayItems();\n\n return (\n <div class={{ 'mg-c-input__input-container': true, 'mg-c-input__input-checkbox-multi': true, 'mg-c-input__input-checkbox-multi--with-values': this.displaySelectedValues }}>\n {this.renderCheckboxMultiDisplaySelectedValues(selectedValuesNb)}\n <mg-popover\n arrowHide={true}\n identifier={this.getMgPopoverIdentifier()}\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.renderButtonText(selectedValuesNb)}\n </mg-button>\n <div slot=\"content\">\n {this.displaySearchInput && [\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 ]}\n {this.displaySearchInput ? (\n <div class=\"mg-c-input__input-checkbox-multi-sections-container\">{this.renderCheckboxBySection(checkboxes)}</div>\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 </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"],"version":3}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
-
import { M as MgInput } from './MgInput.js';
|
|
2
|
+
import { H as Handler, M as MgInput } from './MgInput.js';
|
|
3
3
|
import { C as ClassList, i as isValidString } from './components.utils.js';
|
|
4
4
|
import { l as localeDate, d as dateRegExp, i as initLocales } from './index2.js';
|
|
5
5
|
import { d as defineCustomElement$5 } from './mg-icon2.js';
|
|
@@ -40,7 +40,11 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class MgInputDate extends
|
|
|
40
40
|
* Handle blur event
|
|
41
41
|
*/
|
|
42
42
|
this.handleBlur = () => {
|
|
43
|
-
this.
|
|
43
|
+
this.handlerInProgress = Handler.BLUR;
|
|
44
|
+
this.displayError().finally(() => {
|
|
45
|
+
// reset guard
|
|
46
|
+
this.handlerInProgress = undefined;
|
|
47
|
+
});
|
|
44
48
|
};
|
|
45
49
|
/**
|
|
46
50
|
* Check if input is valid
|
|
@@ -180,10 +184,12 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class MgInputDate extends
|
|
|
180
184
|
* @param newValue - valid new value
|
|
181
185
|
*/
|
|
182
186
|
setValidity(newValue) {
|
|
187
|
+
const oldValidValue = this.valid;
|
|
183
188
|
this.valid = newValue;
|
|
184
189
|
this.invalid = !this.valid;
|
|
185
190
|
// We need to send valid event even if it is the same value
|
|
186
|
-
this.
|
|
191
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === Handler.BLUR && this.valid !== oldValidValue))
|
|
192
|
+
this.inputValid.emit(this.valid);
|
|
187
193
|
}
|
|
188
194
|
/*************
|
|
189
195
|
* Lifecycle *
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"mg-input-date.js","mappings":";;;;;;;;;AAAA,IAAY,UAKX;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,QAAQ,EAAE,EAChD,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,MAAM,EAAE,IAAI,CAAC,UAAU,EACvB,GAAG,EAAE,CAAC,EAAoB;QACxB,IAAI,EAAE,KAAK,IAAI;UAAE,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;OAClC,GACD,CACM,EACV;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["MgInputDate"],"sources":["src/components/molecules/inputs/mg-input-date/mg-input-date.conf.ts","../styles/dist/components/mg-input-date.css?tag=mg-input-date&encapsulation=shadow","src/components/molecules/inputs/mg-input-date/mg-input-date.tsx"],"sourcesContent":["export enum InputError {\n MIN = 'min',\n MAX = 'max',\n MINMAX = 'minMax',\n REQUIRED = 'required',\n}\n",":host{display:block}.mg-c-input__input mg-icon,.mg-c-input__error mg-icon{display:flex}.mg-c-input{display:flex;max-width:100%;min-height:var(--default-size);align-items:flex-start;margin-bottom:var(--mg-inputs-margin-bottom, 0)}.mg-c-input mg-input-title{width:var(--mg-inputs-title-width, auto);flex-shrink:var(--mg-inputs-shrink, 1);margin-top:calc((var(--default-size) - var(--font-size)*var(--line-height))/2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-c-input__error{display:inline-block;padding:.3rem .8rem;border-radius:.3rem;margin-top:.2rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-c-input__input-container{min-height:var(--default-size)}.mg-c-input__input-container>strong{display:inline-block;min-height:var(--font-size);margin-top:calc((var(--default-size) - var(--font-size)*var(--line-height))/2)}.mg-c-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-c-input__input-container .mg-c-input__help-text,.mg-c-input__input-container .mg-c-input__error{font-size:1.2rem;text-align:start}.mg-c-input.mg-c-input--label-on-top{flex-direction:column}.mg-c-input.mg-c-input--label-on-top .mg-c-input__input-container{width:100%}.mg-c-input__title{display:flex;align-items:baseline;margin-bottom:.3rem}.mg-c-input__title mg-input-title{width:auto;flex-shrink:1;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-c-input__title mg-tooltip{margin-top:0}.mg-c-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-c-input__input{display:flex}.mg-c-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size))/2)}.mg-c-input__input.mg-c-input__input--has-error .mg-c-input__box{border-color:hsl(var(--color-danger))}.mg-c-input__input+.mg-c-input__help-text,.mg-c-input__input+.mg-c-input__error{margin-top:.5rem}.mg-c-input__input .mg-c-input__box:disabled,.mg-c-input__input-group--disabled label,.mg-c-input.mg-c-input--toggle-disabled .mg-c-input__input .mg-c-input__button-toggle,.mg-c-input.mg-c-input--checkbox-multi-disabled .mg-c-input__input strong{opacity:var(--mg-disabled-opacity)}.mg-c-input__box{height:var(--default-size);box-sizing:border-box;padding:calc((var(--default-size) - var(--font-size)*var(--line-height))/2) var(--mg-inputs-spacer);border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));color:hsl(var(--color-dark));font-family:inherit;font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 .6rem hsl(var(--mg-inputs-color-shadow-focus-hsl)/50%)}.mg-c-input__box:disabled{opacity:.3}.mg-c-input.mg-c-input--label-on-top .mg-c-input__box{width:auto;max-width:100%}.mg-c-input.mg-c-input--is-input-group-append{--mg-button-border-radius-top-left: 0;--mg-button-border-radius-bottom-left: 0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:-0.1rem;border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--is-input-group-append.mg-c-input--readonly slot[name=append-input]{display:none}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right: 0;--mg-button-border-radius-bottom-right: 0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width: 0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right: var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right: var(--mg-inputs-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size))/2)}.mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip:rect(0.1rem, 0.1rem, 0.1rem, 0.1rem) !important;clip-path:inset(50%) !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media(prefers-reduced-motion){*{animation:none !important;transition:none !important}}/*# sourceMappingURL=mg-input-date.css.map */\n","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';\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\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<string>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<boolean>;\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 this.valid = newValue;\n this.invalid = !this.valid;\n // We need to send valid event even if it is the same value\n 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.displayError();\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"],"version":3}
|
|
1
|
+
{"file":"mg-input-date.js","mappings":";;;;;;;;;AAAA,IAAY,UAKX;AALD,WAAY,UAAU;EACpB,yBAAW,CAAA;EACX,yBAAW,CAAA;EACX,+BAAiB,CAAA;EACjB,mCAAqB,CAAA;AACvB,CAAC,EALW,UAAU,KAAV,UAAU;;ACAtB,MAAM,cAAc,GAAG,wkJAAwkJ;;MCallJA,aAAW;;;;;;;;IAad,sBAAiB,GAAG,KAAK,CAAC;;;;IA0L1B,gBAAW,GAAG;MACpB,IAAI,CAAC,aAAa,EAAE,CAAC;MACrB,IAAI,IAAI,CAAC,iBAAiB,EAAE;QAC1B,IAAI,CAAC,eAAe,EAAE,CAAC;OACxB;MACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;KAC/B,CAAC;;;;IAKM,eAAU,GAAG;MACnB,IAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;MACtC,IAAI,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC;;QAE1B,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;OACpC,C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;;;","names":["MgInputDate"],"sources":["src/components/molecules/inputs/mg-input-date/mg-input-date.conf.ts","../styles/dist/components/mg-input-date.css?tag=mg-input-date&encapsulation=shadow","src/components/molecules/inputs/mg-input-date/mg-input-date.tsx"],"sourcesContent":["export enum InputError {\n MIN = 'min',\n MAX = 'max',\n MINMAX = 'minMax',\n REQUIRED = 'required',\n}\n",":host{display:block}.mg-c-input__input mg-icon,.mg-c-input__error mg-icon{display:flex}.mg-c-input{display:flex;max-width:100%;min-height:var(--default-size);align-items:flex-start;margin-bottom:var(--mg-inputs-margin-bottom, 0)}.mg-c-input mg-input-title{width:var(--mg-inputs-title-width, auto);flex-shrink:var(--mg-inputs-shrink, 1);margin-top:calc((var(--default-size) - var(--font-size)*var(--line-height))/2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-c-input__error{display:inline-block;padding:.3rem .8rem;border-radius:.3rem;margin-top:.2rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-c-input__input-container{min-height:var(--default-size)}.mg-c-input__input-container>strong{display:inline-block;min-height:var(--font-size);margin-top:calc((var(--default-size) - var(--font-size)*var(--line-height))/2)}.mg-c-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-c-input__input-container .mg-c-input__help-text,.mg-c-input__input-container .mg-c-input__error{font-size:1.2rem;text-align:start}.mg-c-input.mg-c-input--label-on-top{flex-direction:column}.mg-c-input.mg-c-input--label-on-top .mg-c-input__input-container{width:100%}.mg-c-input__title{display:flex;align-items:baseline;margin-bottom:.3rem}.mg-c-input__title mg-input-title{width:auto;flex-shrink:1;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-c-input__title mg-tooltip{margin-top:0}.mg-c-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-c-input__input{display:flex}.mg-c-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size))/2)}.mg-c-input__input.mg-c-input__input--has-error .mg-c-input__box{border-color:hsl(var(--color-danger))}.mg-c-input__input+.mg-c-input__help-text,.mg-c-input__input+.mg-c-input__error{margin-top:.5rem}.mg-c-input__input .mg-c-input__box:disabled,.mg-c-input__input-group--disabled label,.mg-c-input.mg-c-input--toggle-disabled .mg-c-input__input .mg-c-input__button-toggle,.mg-c-input.mg-c-input--checkbox-multi-disabled .mg-c-input__input strong{opacity:var(--mg-disabled-opacity)}.mg-c-input__box{height:var(--default-size);box-sizing:border-box;padding:calc((var(--default-size) - var(--font-size)*var(--line-height))/2) var(--mg-inputs-spacer);border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));color:hsl(var(--color-dark));font-family:inherit;font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 .6rem hsl(var(--mg-inputs-color-shadow-focus-hsl)/50%)}.mg-c-input__box:disabled{opacity:.3}.mg-c-input.mg-c-input--label-on-top .mg-c-input__box{width:auto;max-width:100%}.mg-c-input.mg-c-input--is-input-group-append{--mg-button-border-radius-top-left: 0;--mg-button-border-radius-bottom-left: 0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:-0.1rem;border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--is-input-group-append.mg-c-input--readonly slot[name=append-input]{display:none}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right: 0;--mg-button-border-radius-bottom-right: 0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width: 0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right: var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right: var(--mg-inputs-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size))/2)}.mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip:rect(0.1rem, 0.1rem, 0.1rem, 0.1rem) !important;clip-path:inset(50%) !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media(prefers-reduced-motion){*{animation:none !important;transition:none !important}}/*# sourceMappingURL=mg-input-date.css.map */\n","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<string>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<boolean>;\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"],"version":3}
|