@mgdis/mg-components 6.1.0 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-e4a8bf81.js → index-52d5f3d4.js} +16 -6
- package/dist/cjs/index-52d5f3d4.js.map +1 -0
- package/dist/{esm/index-d8f69946.js → cjs/index-cc11af95.js} +6 -116
- package/dist/cjs/index-cc11af95.js.map +1 -0
- package/dist/cjs/index.es-ac7c22e3.js +152 -0
- package/dist/cjs/index.es-ac7c22e3.js.map +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mg-action-more_36.cjs.entry.js +324 -216
- package/dist/cjs/mg-action-more_36.cjs.entry.js.map +1 -1
- package/dist/cjs/mg-alert.cjs.entry.js +7 -6
- package/dist/cjs/mg-alert.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-loader.cjs.entry.js +5 -4
- package/dist/cjs/mg-loader.cjs.entry.js.map +1 -1
- package/dist/cjs/mg-progress.cjs.entry.js +82 -0
- package/dist/cjs/mg-progress.cjs.entry.js.map +1 -0
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/components/atoms/mg-button/mg-button.js +8 -2
- package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js +1 -1
- 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.conf.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +33 -26
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +30 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +85 -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-password/mg-input-password.js +29 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +30 -3
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +29 -3
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +29 -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-textarea/mg-input-textarea.js +29 -1
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +30 -3
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js.map +1 -1
- package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js +3 -4
- package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js.map +1 -1
- package/dist/collection/components/molecules/mg-form/mg-form.conf.js.map +1 -1
- package/dist/collection/components/molecules/mg-form/mg-form.js +32 -2
- package/dist/collection/components/molecules/mg-form/mg-form.js.map +1 -1
- package/dist/collection/components/molecules/mg-progress/mg-progress.conf.js +5 -0
- package/dist/collection/components/molecules/mg-progress/mg-progress.conf.js.map +1 -0
- package/dist/collection/components/molecules/mg-progress/mg-progress.js +187 -0
- package/dist/collection/components/molecules/mg-progress/mg-progress.js.map +1 -0
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +1 -1
- package/dist/collection/types/index.js.map +1 -1
- package/dist/components/index.es.js +26 -13
- package/dist/components/index.es.js.map +1 -1
- package/dist/components/index2.js +2 -2
- package/dist/components/mg-action-more.js +2 -2
- package/dist/components/mg-button2.js +10 -4
- package/dist/components/mg-button2.js.map +1 -1
- package/dist/components/mg-form.js +19 -5
- package/dist/components/mg-form.js.map +1 -1
- package/dist/components/mg-input-checkbox-paginated2.js +1 -1
- package/dist/components/mg-input-checkbox-paginated2.js.map +1 -1
- package/dist/components/mg-input-checkbox.js +20 -29
- package/dist/components/mg-input-checkbox.js.map +1 -1
- package/dist/components/mg-input-date.js +18 -5
- package/dist/components/mg-input-date.js.map +1 -1
- package/dist/components/mg-input-numeric.js +29 -7
- package/dist/components/mg-input-numeric.js.map +1 -1
- package/dist/components/mg-input-password.js +14 -2
- package/dist/components/mg-input-password.js.map +1 -1
- package/dist/components/mg-input-radio.js +15 -2
- package/dist/components/mg-input-radio.js.map +1 -1
- package/dist/components/mg-input-select2.js +14 -2
- package/dist/components/mg-input-select2.js.map +1 -1
- package/dist/components/mg-input-text2.js +14 -2
- package/dist/components/mg-input-text2.js.map +1 -1
- package/dist/components/mg-input-textarea.js +14 -2
- package/dist/components/mg-input-textarea.js.map +1 -1
- package/dist/components/mg-input-toggle.js +15 -2
- package/dist/components/mg-input-toggle.js.map +1 -1
- package/dist/components/mg-input2.js.map +1 -1
- package/dist/components/mg-item-more2.js +5 -6
- package/dist/components/mg-item-more2.js.map +1 -1
- package/dist/components/mg-menu-item2.js +3 -3
- package/dist/components/mg-modal.js +2 -2
- package/dist/components/mg-pagination2.js +2 -2
- package/dist/components/mg-panel.js +2 -2
- package/dist/components/mg-popover2.js +2 -2
- package/dist/components/mg-progress.d.ts +11 -0
- package/dist/components/mg-progress.js +109 -0
- package/dist/components/mg-progress.js.map +1 -0
- package/dist/components/mg-skip-links.js +1 -1
- package/dist/components/mg-tabs.js +4 -4
- package/dist/components/mg-tooltip2.js +3 -3
- package/dist/esm/{index-e26aede5.js → index-81752ffe.js} +16 -6
- package/dist/esm/index-81752ffe.js.map +1 -0
- package/dist/{cjs/index-0fe2670c.js → esm/index-f3d3fb70.js} +4 -135
- package/dist/esm/index-f3d3fb70.js.map +1 -0
- package/dist/esm/index.es-940821a9.js +130 -0
- package/dist/esm/index.es-940821a9.js.map +1 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mg-action-more_36.entry.js +175 -67
- package/dist/esm/mg-action-more_36.entry.js.map +1 -1
- package/dist/esm/mg-alert.entry.js +3 -2
- package/dist/esm/mg-alert.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-loader.entry.js +3 -2
- package/dist/esm/mg-loader.entry.js.map +1 -1
- package/dist/esm/mg-progress.entry.js +78 -0
- package/dist/esm/mg-progress.entry.js.map +1 -0
- 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-2298352f.js +3 -0
- package/dist/mg-components/p-2298352f.js.map +1 -0
- package/dist/mg-components/p-31e6c1a7.entry.js +2 -0
- package/dist/mg-components/{p-9beb09e5.entry.js.map → p-31e6c1a7.entry.js.map} +1 -1
- package/dist/mg-components/p-67c9be27.entry.js +2 -0
- package/dist/mg-components/p-67c9be27.entry.js.map +1 -0
- package/dist/mg-components/p-95895169.entry.js +2 -0
- package/dist/mg-components/{p-5c77f5dd.entry.js.map → p-95895169.entry.js.map} +1 -1
- package/dist/mg-components/p-a49e2b74.js +2 -0
- package/dist/mg-components/p-a49e2b74.js.map +1 -0
- package/dist/mg-components/p-abddacc2.entry.js +2 -0
- package/dist/mg-components/p-abddacc2.entry.js.map +1 -0
- package/dist/mg-components/p-ee51ec5e.js +2 -0
- package/dist/mg-components/p-ee51ec5e.js.map +1 -0
- package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +13 -11
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +0 -2
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +4 -9
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +4 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +12 -0
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +4 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +4 -0
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +4 -0
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +4 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +4 -0
- package/dist/types/components/molecules/mg-form/mg-form.conf.d.ts +2 -1
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +4 -0
- package/dist/types/components/molecules/mg-progress/mg-progress.conf.d.ts +9 -0
- package/dist/types/components/molecules/mg-progress/mg-progress.d.ts +47 -0
- package/dist/types/components.d.ts +111 -0
- package/dist/types/stencil-public-runtime.d.ts +2 -0
- package/dist/types/types/index.d.ts +4 -0
- package/ide/intellij/web-types.json +183 -15
- package/ide/vscode/css-custom-data.json +16 -0
- package/ide/vscode/html-custom-data.json +150 -11
- package/package.json +25 -25
- package/dist/cjs/index-0fe2670c.js.map +0 -1
- package/dist/cjs/index-e4a8bf81.js.map +0 -1
- package/dist/esm/index-d8f69946.js.map +0 -1
- package/dist/esm/index-e26aede5.js.map +0 -1
- package/dist/mg-components/p-1fbb6ee7.js +0 -3
- package/dist/mg-components/p-1fbb6ee7.js.map +0 -1
- package/dist/mg-components/p-5c77f5dd.entry.js +0 -2
- package/dist/mg-components/p-9beb09e5.entry.js +0 -2
- package/dist/mg-components/p-c9934e81.js +0 -2
- package/dist/mg-components/p-c9934e81.js.map +0 -1
- package/dist/mg-components/p-d7dde2ac.entry.js +0 -2
- package/dist/mg-components/p-d7dde2ac.entry.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mg-input-toggle.js","sourceRoot":"","sources":["../../../../../src/components/molecules/inputs/mg-input-toggle/mg-input-toggle.tsx"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,uDAAuD;AACvD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAgB,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAE/F,OAAO,EAAE,aAAa,EAAE,aAAa,EAAwB,MAAM,2BAA2B,CAAC;AAE/F;;;;GAIG;AACH,MAAM,QAAQ,GAAG,CAAC,MAAe,EAAyB,EAAE,CAC1D,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAQ,MAAsB,CAAC,KAAK,KAAK,QAAQ,IAAK,MAAsB,CAAC,KAAK,KAAK,SAAS,CAAC;AAEjI;;;GAGG;AAMH,MAAM,OAAO,aAAa;;QACxB;;sBAEc;QAEd,UAAU;QACO,kBAAa,GAAG,8BAA8B,CAAC;QAC/C,eAAU,GAAG,2BAA2B,CAAC;QACzC,cAAS,GAAG,yBAAyB,CAAC;QA8LvD;;;WAGG;QACK,oBAAe,GAAG,CAAC,YAAqB,EAAQ,EAAE;YACxD,oBAAoB;YACpB,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;YAC9B,mCAAmC;YACnC,IAAI,CAAC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,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,EACxC,OAAO,EAAE,IAAI,CAAC,aAAa;YAE3B,2BAAkB,MAAM,EAAC,KAAK,EAAC,mCAAmC;gBAChE,YAAM,IAAI,EAAC,QAAQ,GAAQ,CACtB;YACP,2BAAkB,MAAM,EAAC,KAAK,EAAC,mCAAmC;gBAChE,YAAM,IAAI,EAAC,QAAQ,GAAQ,CACtB,CACA,CACV,CACQ,CACZ,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Component, Event, h, Prop, EventEmitter, State, Watch, Element, Method } from '@stencil/core';\nimport { ClassList, allItemsAreString, isValidString, toString } from '@mgdis/stencil-helpers';\nimport { ToggleValue } from './mg-input-toggle.conf';\nimport { classDisabled, classReadonly, type TooltipPosition } from '../mg-input/mg-input.conf';\n\n/**\n * type Option validation function\n * @param option - radio option\n * @returns toggle option type is valid\n */\nconst isOption = (option: unknown): option is ToggleValue =>\n typeof option === 'object' && typeof (option as ToggleValue).title === 'string' && (option as ToggleValue).value !== undefined;\n\n/**\n * @slot item-1 - Left option toggle content\n * @slot item-2 - Right option toggle content\n */\n@Component({\n tag: 'mg-input-toggle',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-input-toggle.css',\n shadow: true,\n})\nexport class MgInputToggle {\n /************\n * Internal *\n ************/\n\n // Classes\n private readonly classIsActive = 'mg-c-input--toggle-is-active';\n private readonly classOnOff = 'mg-c-input--toggle-on-off';\n private readonly classIcon = 'mg-c-input--toggle-icon';\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgInputToggleElement;\n\n /**\n * Component value\n */\n @Prop({ mutable: true }) value: any;\n @Watch('value')\n handleValue(newValue: any): void {\n // Swich to the right option\n this.setChecked();\n // Emit value-change event\n this.valueChange.emit(newValue);\n }\n\n /**\n * Items are the possible options to select\n */\n @Prop() items!: string[] | ToggleValue[];\n @Watch('items')\n validateItems(newValue: MgInputToggle['items']): void {\n if (typeof newValue === 'object' && this.items.length !== 2) {\n throw new Error(`<mg-input-toggle> prop \"items\" require 2 items. Passed value: ${toString(newValue)}.`);\n }\n // String array\n else if (allItemsAreString(newValue)) {\n this.options = newValue.map(item => ({ title: item, value: item }));\n }\n // Object array\n else if (Array.isArray(newValue) && newValue.every(isOption)) {\n this.options = newValue;\n } else {\n throw new Error(`<mg-input-toggle> prop \"items\" is required and all items must be the same type: ToggleValue. Passed value: ${toString(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 toggle have on/off style\n */\n @Prop() isOnOff = false;\n @Watch('isOnOff')\n watchIsOnOff(newValue: MgInputToggle['isOnOff']): void {\n if (newValue) this.classCollection.add(this.classOnOff);\n else this.classCollection.delete(this.classOnOff);\n }\n\n /**\n * Define if toggle display icon\n */\n @Prop() isIcon = false;\n @Watch('isIcon')\n watchIsIcon(newValue: MgInputToggle['isIcon']): void {\n if (newValue) this.classCollection.add(this.classIcon);\n else this.classCollection.delete(this.classIcon);\n }\n\n /**\n * Define if input is readonly\n */\n @Prop() readonly = false;\n @Watch('readonly')\n watchReadonly(newValue: MgInputToggle['readonly']): void {\n if (newValue) this.classCollection.add(classReadonly);\n else this.classCollection.delete(classReadonly);\n }\n\n /**\n * Define if input is disabled\n */\n @Prop() disabled = false;\n @Watch('disabled')\n watchDisabled(newValue: MgInputToggle['disabled']): void {\n if (newValue) this.classCollection.add(classDisabled);\n else this.classCollection.delete(classDisabled);\n }\n\n /**\n * Add a tooltip message next to the input\n */\n @Prop() tooltip?: string;\n\n /**\n * Define tooltip position\n */\n @Prop() tooltipPosition: TooltipPosition = 'input';\n\n /**\n * Add a help text under the input, usually expected data format and example\n */\n @Prop() helpText?: string;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-input--toggle']);\n\n /**\n * Formated items for display\n */\n @State() options: ToggleValue[];\n\n /**\n * Error message to display\n */\n @State() errorMessage: string;\n\n /**\n * Define input valid state\n */\n @State() valid: boolean;\n\n /**\n * Checked internal value\n */\n @State() checked = false;\n @Watch('checked')\n handleChecked(newValue: MgInputToggle['checked']): void {\n // style\n if (newValue) this.classCollection.add(this.classIsActive);\n else this.classCollection.delete(this.classIsActive);\n\n // update value\n this.value = this.getCheckedItem(newValue).value;\n }\n\n /**\n * Emited event when value change\n */\n @Event({ eventName: 'value-change' }) valueChange: EventEmitter<HTMLMgInputToggleElement['value']>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<boolean>;\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: boolean, errorMessage: string): Promise<void> {\n if (typeof valid !== 'boolean') {\n throw new Error('<mg-input-toggle> method \"setError()\" param \"valid\" must be a boolean.');\n } else if (!isValidString(errorMessage)) {\n throw new Error('<mg-input-toggle> method \"setError()\" param \"errorMessage\" must be a string.');\n } else {\n this.valid = valid;\n this.inputValid.emit(valid);\n this.setErrorMessage(valid ? undefined : errorMessage);\n }\n }\n\n /**\n * Set input error message\n * @param errorMessage - errorMessage override\n */\n private setErrorMessage = (errorMessage?: string): void => {\n // Set error message\n this.errorMessage = undefined;\n // Does have a custom error message\n if (!this.valid && errorMessage !== undefined) {\n this.errorMessage = errorMessage;\n }\n };\n\n /**\n * Change checked value\n */\n private toggleChecked = (): void => {\n this.checked = !this.checked;\n };\n\n /**\n * Slots validation\n */\n private validateSlots = (): void => {\n const slots = Array.from(this.element.children);\n if (slots.length !== 2) {\n throw new Error('<mg-input-toggle> 2 slots are required.');\n } else if (!this.isIcon) {\n // Due to text-overflow set to ellipsis\n // we need to ensure that slot element have title to display value on mouse over\n slots.forEach(slot => slot.setAttribute('title', slot.textContent));\n }\n };\n\n /**\n * Get checked item\n * @param checked - checked item\n * @returns toggle value\n */\n private getCheckedItem = (checked: MgInputToggle['checked']): ToggleValue => {\n if (this.options?.length === 2) {\n return this.options[checked ? 1 : 0];\n } else {\n return null;\n }\n };\n /**\n * set checked state\n */\n private setChecked(): void {\n const optionTrueValueIndex = this.options.map(option => option.value).findIndex(value => value === true);\n\n if ([0, 1].includes(optionTrueValueIndex)) {\n // has \"value\" props type is not a boolean, it is bind/render as an attributes/props\n // true props will be represent by \"true\" string so we convert it has boolean\n // true attribute will be represent by \"\" string so we convert it has boolean\n // https://stenciljs.com/docs/properties\n if (['', 'true'].includes(this.value as string) && this.options.find(option => option.value) !== undefined) {\n this.value = true;\n }\n\n // when options are boolean values and ordered as [true,false] instead [false,true]\n // we need to reversed the checked value logic\n const selectedValue = this.value === this.options[optionTrueValueIndex].value;\n this.checked = optionTrueValueIndex === 0 ? !selectedValue : selectedValue;\n } else {\n this.checked = this.value === this.options[1].value;\n }\n }\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n */\n componentWillLoad(): void {\n // Check items format\n this.validateItems(this.items);\n // Check slots\n this.validateSlots();\n // init checked value\n this.setChecked();\n // apply handler\n this.watchIsIcon(this.isIcon);\n this.watchIsOnOff(this.isOnOff);\n this.watchReadonly(this.readonly);\n this.watchDisabled(this.disabled);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n const checkedItem = this.getCheckedItem(this.checked);\n return (\n <mg-input\n label={this.label}\n helpText={this.helpText}\n identifier={this.identifier}\n class={this.classCollection.join()}\n ariaDescribedbyIDs={[]}\n labelOnTop={this.labelOnTop}\n labelHide={this.labelHide}\n required={undefined}\n tooltip={this.tooltip}\n tooltipPosition={this.tooltipPosition}\n errorMessage={this.errorMessage}\n >\n {this.readonly ? (\n checkedItem && <b class=\"mg-c-input__readonly-value\">{checkedItem.title}</b>\n ) : (\n <button\n type=\"button\"\n role=\"switch\"\n aria-checked={this.checked.toString()}\n aria-readonly={this.disabled || this.readonly}\n id={this.identifier}\n class=\"mg-c-input__button-toggle\"\n disabled={this.disabled || this.readonly}\n onClick={this.toggleChecked}\n >\n <span aria-hidden=\"true\" class=\"mg-c-input__toggle-item-container\">\n <slot name=\"item-1\"></slot>\n </span>\n <span aria-hidden=\"true\" class=\"mg-c-input__toggle-item-container\">\n <slot name=\"item-2\"></slot>\n </span>\n </button>\n )}\n </mg-input>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mg-input-toggle.js","sourceRoot":"","sources":["../../../../../src/components/molecules/inputs/mg-input-toggle/mg-input-toggle.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAgB,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CA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,IAAI,EAAC,QAAQ,GAAQ,CACtB,CACA,CACV,CACQ,CACZ,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Event, h, Prop, EventEmitter, State, Watch, Element, Method } from '@stencil/core';\nimport { ClassList, allItemsAreString, isValidString, toString } from '@mgdis/stencil-helpers';\nimport { ToggleValue } from './mg-input-toggle.conf';\nimport { classDisabled, classReadonly, type TooltipPosition } from '../mg-input/mg-input.conf';\n\n/**\n * type Option validation function\n * @param option - radio option\n * @returns toggle option type is valid\n */\nconst isOption = (option: unknown): option is ToggleValue =>\n typeof option === 'object' && typeof (option as ToggleValue).title === 'string' && (option as ToggleValue).value !== undefined;\n\n/**\n * @slot item-1 - Left option toggle content\n * @slot item-2 - Right option toggle content\n */\n@Component({\n tag: 'mg-input-toggle',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-input-toggle.css',\n shadow: true,\n})\nexport class MgInputToggle {\n /************\n * Internal *\n ************/\n\n // Classes\n private readonly classIsActive = 'mg-c-input--toggle-is-active';\n private readonly classOnOff = 'mg-c-input--toggle-on-off';\n private readonly classIcon = 'mg-c-input--toggle-icon';\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgInputToggleElement;\n\n /**\n * Component value\n */\n @Prop({ mutable: true }) value: any; // eslint-disable-line @typescript-eslint/no-explicit-any\n @Watch('value')\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n handleValue(newValue: any): void {\n // Swich to the right option\n this.setChecked();\n // Emit value-change event\n this.valueChange.emit(newValue);\n }\n\n /**\n * Items are the possible options to select\n */\n @Prop() items!: string[] | ToggleValue[];\n @Watch('items')\n validateItems(newValue: MgInputToggle['items']): void {\n if (typeof newValue === 'object' && this.items.length !== 2) {\n throw new Error(`<mg-input-toggle> prop \"items\" require 2 items. Passed value: ${toString(newValue)}.`);\n }\n // String array\n else if (allItemsAreString(newValue)) {\n this.options = newValue.map(item => ({ title: item, value: item }));\n }\n // Object array\n else if (Array.isArray(newValue) && newValue.every(isOption)) {\n this.options = newValue;\n } else {\n throw new Error(`<mg-input-toggle> prop \"items\" is required and all items must be the same type: ToggleValue. Passed value: ${toString(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 toggle have on/off style\n */\n @Prop() isOnOff = false;\n @Watch('isOnOff')\n watchIsOnOff(newValue: MgInputToggle['isOnOff']): void {\n if (newValue) this.classCollection.add(this.classOnOff);\n else this.classCollection.delete(this.classOnOff);\n }\n\n /**\n * Define if toggle display icon\n */\n @Prop() isIcon = false;\n @Watch('isIcon')\n watchIsIcon(newValue: MgInputToggle['isIcon']): void {\n if (newValue) this.classCollection.add(this.classIcon);\n else this.classCollection.delete(this.classIcon);\n }\n\n /**\n * Define if input is readonly\n */\n @Prop() readonly = false;\n @Watch('readonly')\n watchReadonly(newValue: MgInputToggle['readonly']): void {\n if (newValue) this.classCollection.add(classReadonly);\n else this.classCollection.delete(classReadonly);\n }\n\n /**\n * Define if input is disabled\n */\n @Prop() disabled = false;\n @Watch('disabled')\n watchDisabled(newValue: MgInputToggle['disabled']): void {\n if (newValue) this.classCollection.add(classDisabled);\n else this.classCollection.delete(classDisabled);\n }\n\n /**\n * Add a tooltip message next to the input\n */\n @Prop() tooltip?: string;\n\n /**\n * Define tooltip position\n */\n @Prop() tooltipPosition: TooltipPosition = 'input';\n\n /**\n * Add a help text under the input, usually expected data format and example\n */\n @Prop() helpText?: string;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-input--toggle']);\n\n /**\n * Formated items for display\n */\n @State() options: ToggleValue[];\n\n /**\n * Error message to display\n */\n @State() errorMessage: string;\n\n /**\n * Define input valid state\n */\n @State() valid: boolean;\n\n /**\n * Checked internal value\n */\n @State() checked = false;\n @Watch('checked')\n handleChecked(newValue: MgInputToggle['checked']): void {\n // style\n if (newValue) this.classCollection.add(this.classIsActive);\n else this.classCollection.delete(this.classIsActive);\n\n // update value\n this.value = this.getCheckedItem(newValue).value;\n }\n\n /**\n * Emited event when value change\n */\n @Event({ eventName: 'value-change' }) valueChange: EventEmitter<HTMLMgInputToggleElement['value']>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<boolean>;\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: boolean, errorMessage: string): Promise<void> {\n if (typeof valid !== 'boolean') {\n throw new Error('<mg-input-toggle> method \"setError()\" param \"valid\" must be a boolean.');\n } else if (!isValidString(errorMessage)) {\n throw new Error('<mg-input-toggle> method \"setError()\" param \"errorMessage\" must be a string.');\n } else {\n this.valid = valid;\n this.inputValid.emit(valid);\n this.setErrorMessage(valid ? undefined : errorMessage);\n }\n }\n\n /**\n * Set input error message\n * @param errorMessage - errorMessage override\n */\n private setErrorMessage = (errorMessage?: string): void => {\n // Set error message\n this.errorMessage = undefined;\n // Does have a custom error message\n if (!this.valid && errorMessage !== undefined) {\n this.errorMessage = errorMessage;\n }\n };\n\n /**\n * Reset value, validity, error and visual state\n */\n @Method()\n async reset(): Promise<void> {\n if (!this.readonly) {\n this.value = this.options[0].value;\n this.errorMessage = undefined;\n this.valid = undefined;\n this.setChecked();\n }\n }\n\n /**\n * Change checked value\n */\n private toggleChecked = (): void => {\n this.checked = !this.checked;\n };\n\n /**\n * Slots validation\n */\n private validateSlots = (): void => {\n const slots = Array.from(this.element.children);\n if (slots.length !== 2) {\n throw new Error('<mg-input-toggle> 2 slots are required.');\n } else if (!this.isIcon) {\n // Due to text-overflow set to ellipsis\n // we need to ensure that slot element have title to display value on mouse over\n slots.forEach(slot => slot.setAttribute('title', slot.textContent));\n }\n };\n\n /**\n * Get checked item\n * @param checked - checked item\n * @returns toggle value\n */\n private getCheckedItem = (checked: MgInputToggle['checked']): ToggleValue => {\n if (this.options?.length === 2) {\n return this.options[checked ? 1 : 0];\n } else {\n return null;\n }\n };\n /**\n * set checked state\n */\n private setChecked(): void {\n const optionTrueValueIndex = this.options.map(option => option.value).findIndex(value => value === true);\n\n if ([0, 1].includes(optionTrueValueIndex)) {\n // has \"value\" props type is not a boolean, it is bind/render as an attributes/props\n // true props will be represent by \"true\" string so we convert it has boolean\n // true attribute will be represent by \"\" string so we convert it has boolean\n // https://stenciljs.com/docs/properties\n if (['', 'true'].includes(this.value as string) && this.options.find(option => option.value) !== undefined) {\n this.value = true;\n }\n\n // when options are boolean values and ordered as [true,false] instead [false,true]\n // we need to reversed the checked value logic\n const selectedValue = this.value === this.options[optionTrueValueIndex].value;\n this.checked = optionTrueValueIndex === 0 ? !selectedValue : selectedValue;\n } else {\n this.checked = this.value === this.options[1].value;\n }\n }\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n */\n componentWillLoad(): void {\n // Check items format\n this.validateItems(this.items);\n // Check slots\n this.validateSlots();\n // init checked value\n this.setChecked();\n // apply handler\n this.watchIsIcon(this.isIcon);\n this.watchIsOnOff(this.isOnOff);\n this.watchReadonly(this.readonly);\n this.watchDisabled(this.disabled);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n const checkedItem = this.getCheckedItem(this.checked);\n return (\n <mg-input\n label={this.label}\n helpText={this.helpText}\n identifier={this.identifier}\n class={this.classCollection.join()}\n ariaDescribedbyIDs={[]}\n labelOnTop={this.labelOnTop}\n labelHide={this.labelHide}\n required={undefined}\n tooltip={this.tooltip}\n tooltipPosition={this.tooltipPosition}\n errorMessage={this.errorMessage}\n >\n {this.readonly ? (\n checkedItem && <b class=\"mg-c-input__readonly-value\">{checkedItem.title}</b>\n ) : (\n <button\n type=\"button\"\n role=\"switch\"\n aria-checked={this.checked.toString()}\n aria-readonly={this.disabled || this.readonly}\n id={this.identifier}\n class=\"mg-c-input__button-toggle\"\n disabled={this.disabled || this.readonly}\n onClick={this.toggleChecked}\n >\n <span aria-hidden=\"true\" class=\"mg-c-input__toggle-item-container\">\n <slot name=\"item-1\"></slot>\n </span>\n <span aria-hidden=\"true\" class=\"mg-c-input__toggle-item-container\">\n <slot name=\"item-2\"></slot>\n </span>\n </button>\n )}\n </mg-input>\n );\n }\n}\n"]}
|
|
@@ -18,8 +18,7 @@ export class MgItemMore {
|
|
|
18
18
|
*/
|
|
19
19
|
this.setProxyElement = (proxified) => {
|
|
20
20
|
const proxy = this.moreElementMenuItem.querySelector(`[identifier="${proxified.identifier}"]`);
|
|
21
|
-
|
|
22
|
-
if (!proxy) {
|
|
21
|
+
if (proxy === null) {
|
|
23
22
|
return;
|
|
24
23
|
}
|
|
25
24
|
// remove proxy id to prevent duplicate key. default html id is: '';
|
|
@@ -140,11 +139,11 @@ export class MgItemMore {
|
|
|
140
139
|
* @returns HTML Element
|
|
141
140
|
*/
|
|
142
141
|
render() {
|
|
143
|
-
return (h(Host, { key: '
|
|
142
|
+
return (h(Host, { key: '11c43154129c5756e80db0af3434c88cab2191f3', role: "listitem" }, this.parentMenu && (h("mg-menu-item", { key: '38fc92410328c317fb046f4e1ec4f94175d484fb', "data-overflow-more": true, "data-size": this.parentMenu.size, identifier: "mg-item-more", ref: el => {
|
|
144
143
|
if (el !== null) {
|
|
145
144
|
this.moreElementMenuItem = el;
|
|
146
145
|
}
|
|
147
|
-
} }, h("mg-icon", { key: '
|
|
146
|
+
} }, h("mg-icon", { key: '90e21f30004e38a1a0938359276dccd7458e5e86', icon: this.icon.icon, size: this.size, slot: "image" }), h("span", { key: '20f846c5718a19d39ad94abf59bab54658e1ff9c', class: { 'mg-u-visually-hidden': !this.slotlabel.display }, slot: "label" }, this.slotlabel.label), h("mg-menu", { key: 'b52f97129e736be9164ae18b717057d1bfc0cd0a', direction: Direction.VERTICAL, label: this.messages.menuLabel, size: this.size })))));
|
|
148
147
|
}
|
|
149
148
|
static get is() { return "mg-item-more"; }
|
|
150
149
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mg-item-more.js","sourceRoot":"","sources":["../../../../../src/components/molecules/internals/mg-item-more/mg-item-more.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAG3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;GAEG;AAMH,MAAM,OAAO,UAAU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AAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAC,OAAO,GAAW;YACvE,6DAAM,KAAK,EAAE,EAAE,sBAAsB,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,IAAI,EAAC,OAAO,IAC3E,IAAI,CAAC,SAAS,CAAC,KAAK,CAChB;YACP,gEAAS,SAAS,EAAE,SAAS,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,GAAY,CACtF,CAChB,CACI,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop, Element, Host, Watch, State } from '@stencil/core';\nimport { isValidString, nextTick, toString } from '@mgdis/stencil-helpers';\nimport type { IconType, SizeType, SlotLabelType } from './mg-item-more.conf';\nimport type { MessageType } from '../../../../locales/index.conf';\nimport { OverflowBehavior } from '../../../../utils/behaviors.utils';\nimport { Direction, sizes } from '../../menu/mg-menu/mg-menu.conf';\nimport { initLocales } from '../../../../locales';\n\n/**\n * @internal\n */\n@Component({\n tag: 'mg-item-more',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-item-more.css',\n shadow: true,\n})\nexport class MgItemMore {\n /************\n * Internal *\n ************/\n private readonly name = 'mg-item-more';\n private messages: MessageType;\n private parentMenuItems: HTMLMgMenuItemElement[];\n private moreElementMenuItem: HTMLMgMenuItemElement;\n private overflowBehavior: OverflowBehavior;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgItemMoreElement;\n\n /**\n * Define icon\n */\n @Prop() icon?: IconType = { icon: 'ellipsis-vertical' };\n @Watch('icon')\n validateIcon(newValue: MgItemMore['icon']): void {\n if (typeof newValue !== 'object' || (typeof newValue === 'object' && typeof newValue.icon !== 'string'))\n throw new Error(`<${this.name}> prop \"icon\" must match MgItemMore['icon'] type. Passed value: ${toString(newValue)}.`);\n }\n\n /**\n * Define slot label element\n */\n @Prop() slotlabel?: SlotLabelType = { display: false };\n @Watch('slotlabel')\n validateSlotLabel(newValue: MgItemMore['slotlabel']): void {\n if (typeof newValue !== 'object' || (typeof newValue === 'object' && typeof newValue.display !== 'boolean'))\n throw new Error(`<${this.name}> prop \"slotlabel\" must match MgItemMore['slotlabel'] type. Passed value: ${toString(newValue)}.`);\n else if (typeof newValue.label !== 'string') this.slotlabel.label = this.messages.menuLabel;\n }\n\n /**\n * Define component child menu size.\n */\n @Prop() size?: SizeType;\n @Watch('size')\n validateSize(newValue: MgItemMore['size']): void {\n if (newValue && !sizes.includes(newValue)) throw new Error(`<${this.name}> prop \"size\" must match MgItemMore['size'] type. Passed value: ${toString(newValue)}.`);\n }\n\n /**\n * Define component parent menu.\n */\n @State() parentMenu: HTMLMgMenuElement;\n\n /**\n * Set proxy element properties and listeners\n * @param proxified - element to proxify from\n */\n private setProxyElement = (proxified: HTMLMgMenuItemElement): void => {\n const proxy: HTMLMgMenuItemElement = this.moreElementMenuItem.querySelector(`[identifier=\"${proxified.identifier}\"]`);\n // eslint-disable-next-line @stencil-community/strict-boolean-conditions\n if (!proxy) {\n return;\n }\n\n // remove proxy id to prevent duplicate key. default html id is: '';\n if (isValidString(proxy.id)) proxy.id = '';\n\n const proxyClickHandler = (): void => {\n this.parentMenu\n .querySelector(`[identifier=\"${proxy.identifier}\"]`)\n .shadowRoot.querySelector('a, button')\n .dispatchEvent(new MouseEvent('click', { bubbles: true }));\n };\n\n // Watch the `item-updated` event to keep element needeed properties and innerHTML in sync between the proxified and the proxy elements\n const updateProxy = (element: HTMLMgMenuItemElement): void => {\n for (const key in element) {\n if (['identifier', 'href', 'targer', 'status', 'expanded'].includes(key)) element[key] ? proxy.setAttribute(key, element[key]) : proxy.removeAttribute(key);\n }\n\n proxy.innerHTML = element.innerHTML;\n // When `href` is updated we need to wait the full component re-render before update its handler\n setTimeout(() => {\n const interactiveElement = proxy.shadowRoot.querySelector('a, button');\n interactiveElement?.removeEventListener('click', proxyClickHandler);\n interactiveElement?.addEventListener('click', proxyClickHandler);\n });\n };\n\n updateProxy(proxified);\n\n proxified.addEventListener('item-updated', event => {\n updateProxy(event.target);\n });\n\n // update click event listener on proxy item and mirror the event on the main menu element\n // we need to wait mg-menu-item to be loaded to ensure the shadowroot is rendered\n proxy.addEventListener('item-loaded', () => {\n updateProxy(proxified);\n });\n };\n\n /***********\n * Methods *\n ***********/\n\n /**\n * render mg-item-more overflow element\n * @returns mg-item-more element\n */\n private renderMgMenuItemOverflowElement = (): HTMLMgItemMoreElement => {\n this.parentMenuItems.forEach((child: HTMLMgMenuItemElement) => {\n // create item-more menu items element from main menu-items clones\n this.moreElementMenuItem.querySelector('mg-menu').appendChild(child.cloneNode(true));\n\n // we need to get all `mg-menu-item` linked to the cloned one to set mirror process\n nextTick(() => {\n this.setProxyElement(child);\n if (child.querySelector('mg-menu') !== null) {\n child.querySelectorAll('mg-menu-item').forEach(this.setProxyElement);\n }\n });\n });\n\n return this.element;\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Set variables and validate props\n */\n componentWillLoad(): void {\n // init variables\n this.messages = initLocales(this.element).messages.itemMore as MessageType;\n\n // validate props\n this.validateIcon(this.icon);\n this.validateSlotLabel(this.slotlabel);\n this.validateSize(this.size);\n }\n\n /**\n * Ensure parent DOM is fully rendered with timeout method before parse elements\n * @returns timeout\n */\n componentDidLoad(): ReturnType<typeof setTimeout> {\n // ensure parent menu is fully rendered\n return setTimeout(() => {\n this.parentMenu = this.element.closest('mg-menu');\n });\n }\n\n /**\n * Set OverflowBehavior when parentMenu state is upate AND defined\n */\n componentDidUpdate(): void {\n if (this.parentMenu && this.overflowBehavior === undefined) {\n this.parentMenuItems = Array.from(this.parentMenu.children).filter(item => item.nodeName === 'MG-MENU-ITEM') as HTMLMgMenuItemElement[];\n this.overflowBehavior = new OverflowBehavior(this.parentMenu, this.renderMgMenuItemOverflowElement);\n }\n }\n\n /**\n * Disconnect overflow ResizeObserver\n */\n disconnectedCallback(): void {\n this.overflowBehavior?.disconnect();\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <Host role=\"listitem\">\n {this.parentMenu && (\n <mg-menu-item\n data-overflow-more\n data-size={this.parentMenu.size}\n identifier=\"mg-item-more\"\n ref={el => {\n if (el !== null) {\n this.moreElementMenuItem = el;\n }\n }}\n >\n <mg-icon icon={this.icon.icon} size={this.size} slot=\"image\"></mg-icon>\n <span class={{ 'mg-u-visually-hidden': !this.slotlabel.display }} slot=\"label\">\n {this.slotlabel.label}\n </span>\n <mg-menu direction={Direction.VERTICAL} label={this.messages.menuLabel} size={this.size}></mg-menu>\n </mg-menu-item>\n )}\n </Host>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mg-item-more.js","sourceRoot":"","sources":["../../../../../src/components/molecules/internals/mg-item-more/mg-item-more.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAG3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;GAEG;AAMH,MAAM,OAAO,UAAU;;QACrB;;sBAEc;QACG,SAAI,GAAG,cAAc,CAAC;QAkDvC;;;WAGG;QACK,oBAAe,GAAG,CAAC,SAAgC,EAAQ,EAAE;YACnE,MAAM,KAAK,GAA0B,IAAI,C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SAAS,CAAC,OAAO,EAAE,EAAE,IAAI,EAAC,OAAO,IAC3E,IAAI,CAAC,SAAS,CAAC,KAAK,CAChB;YACP,gEAAS,SAAS,EAAE,SAAS,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,GAAY,CACtF,CAChB,CACI,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop, Element, Host, Watch, State } from '@stencil/core';\nimport { isValidString, nextTick, toString } from '@mgdis/stencil-helpers';\nimport type { IconType, SizeType, SlotLabelType } from './mg-item-more.conf';\nimport type { MessageType } from '../../../../locales/index.conf';\nimport { OverflowBehavior } from '../../../../utils/behaviors.utils';\nimport { Direction, sizes } from '../../menu/mg-menu/mg-menu.conf';\nimport { initLocales } from '../../../../locales';\n\n/**\n * @internal\n */\n@Component({\n tag: 'mg-item-more',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-item-more.css',\n shadow: true,\n})\nexport class MgItemMore {\n /************\n * Internal *\n ************/\n private readonly name = 'mg-item-more';\n private messages: MessageType;\n private parentMenuItems: HTMLMgMenuItemElement[];\n private moreElementMenuItem: HTMLMgMenuItemElement;\n private overflowBehavior: OverflowBehavior;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgItemMoreElement;\n\n /**\n * Define icon\n */\n @Prop() icon?: IconType = { icon: 'ellipsis-vertical' };\n @Watch('icon')\n validateIcon(newValue: MgItemMore['icon']): void {\n if (typeof newValue !== 'object' || (typeof newValue === 'object' && typeof newValue.icon !== 'string'))\n throw new Error(`<${this.name}> prop \"icon\" must match MgItemMore['icon'] type. Passed value: ${toString(newValue)}.`);\n }\n\n /**\n * Define slot label element\n */\n @Prop() slotlabel?: SlotLabelType = { display: false };\n @Watch('slotlabel')\n validateSlotLabel(newValue: MgItemMore['slotlabel']): void {\n if (typeof newValue !== 'object' || (typeof newValue === 'object' && typeof newValue.display !== 'boolean'))\n throw new Error(`<${this.name}> prop \"slotlabel\" must match MgItemMore['slotlabel'] type. Passed value: ${toString(newValue)}.`);\n else if (typeof newValue.label !== 'string') this.slotlabel.label = this.messages.menuLabel;\n }\n\n /**\n * Define component child menu size.\n */\n @Prop() size?: SizeType;\n @Watch('size')\n validateSize(newValue: MgItemMore['size']): void {\n if (newValue && !sizes.includes(newValue)) throw new Error(`<${this.name}> prop \"size\" must match MgItemMore['size'] type. Passed value: ${toString(newValue)}.`);\n }\n\n /**\n * Define component parent menu.\n */\n @State() parentMenu: HTMLMgMenuElement;\n\n /**\n * Set proxy element properties and listeners\n * @param proxified - element to proxify from\n */\n private setProxyElement = (proxified: HTMLMgMenuItemElement): void => {\n const proxy: HTMLMgMenuItemElement = this.moreElementMenuItem.querySelector(`[identifier=\"${proxified.identifier}\"]`);\n if (proxy === null) {\n return;\n }\n\n // remove proxy id to prevent duplicate key. default html id is: '';\n if (isValidString(proxy.id)) proxy.id = '';\n\n const proxyClickHandler = (): void => {\n this.parentMenu\n .querySelector(`[identifier=\"${proxy.identifier}\"]`)\n .shadowRoot.querySelector('a, button')\n .dispatchEvent(new MouseEvent('click', { bubbles: true }));\n };\n\n // Watch the `item-updated` event to keep element needeed properties and innerHTML in sync between the proxified and the proxy elements\n const updateProxy = (element: HTMLMgMenuItemElement): void => {\n for (const key in element) {\n if (['identifier', 'href', 'targer', 'status', 'expanded'].includes(key)) element[key] ? proxy.setAttribute(key, element[key]) : proxy.removeAttribute(key);\n }\n\n proxy.innerHTML = element.innerHTML;\n // When `href` is updated we need to wait the full component re-render before update its handler\n setTimeout(() => {\n const interactiveElement = proxy.shadowRoot.querySelector('a, button');\n interactiveElement?.removeEventListener('click', proxyClickHandler);\n interactiveElement?.addEventListener('click', proxyClickHandler);\n });\n };\n\n updateProxy(proxified);\n\n proxified.addEventListener('item-updated', event => {\n updateProxy(event.target);\n });\n\n // update click event listener on proxy item and mirror the event on the main menu element\n // we need to wait mg-menu-item to be loaded to ensure the shadowroot is rendered\n proxy.addEventListener('item-loaded', () => {\n updateProxy(proxified);\n });\n };\n\n /***********\n * Methods *\n ***********/\n\n /**\n * render mg-item-more overflow element\n * @returns mg-item-more element\n */\n private renderMgMenuItemOverflowElement = (): HTMLMgItemMoreElement => {\n this.parentMenuItems.forEach((child: HTMLMgMenuItemElement) => {\n // create item-more menu items element from main menu-items clones\n this.moreElementMenuItem.querySelector('mg-menu').appendChild(child.cloneNode(true));\n\n // we need to get all `mg-menu-item` linked to the cloned one to set mirror process\n nextTick(() => {\n this.setProxyElement(child);\n if (child.querySelector('mg-menu') !== null) {\n child.querySelectorAll('mg-menu-item').forEach(this.setProxyElement);\n }\n });\n });\n\n return this.element;\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Set variables and validate props\n */\n componentWillLoad(): void {\n // init variables\n this.messages = initLocales(this.element).messages.itemMore as MessageType;\n\n // validate props\n this.validateIcon(this.icon);\n this.validateSlotLabel(this.slotlabel);\n this.validateSize(this.size);\n }\n\n /**\n * Ensure parent DOM is fully rendered with timeout method before parse elements\n * @returns timeout\n */\n componentDidLoad(): ReturnType<typeof setTimeout> {\n // ensure parent menu is fully rendered\n return setTimeout(() => {\n this.parentMenu = this.element.closest('mg-menu');\n });\n }\n\n /**\n * Set OverflowBehavior when parentMenu state is upate AND defined\n */\n componentDidUpdate(): void {\n if (this.parentMenu && this.overflowBehavior === undefined) {\n this.parentMenuItems = Array.from(this.parentMenu.children).filter(item => item.nodeName === 'MG-MENU-ITEM') as HTMLMgMenuItemElement[];\n this.overflowBehavior = new OverflowBehavior(this.parentMenu, this.renderMgMenuItemOverflowElement);\n }\n }\n\n /**\n * Disconnect overflow ResizeObserver\n */\n disconnectedCallback(): void {\n this.overflowBehavior?.disconnect();\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <Host role=\"listitem\">\n {this.parentMenu && (\n <mg-menu-item\n data-overflow-more\n data-size={this.parentMenu.size}\n identifier=\"mg-item-more\"\n ref={el => {\n if (el !== null) {\n this.moreElementMenuItem = el;\n }\n }}\n >\n <mg-icon icon={this.icon.icon} size={this.size} slot=\"image\"></mg-icon>\n <span class={{ 'mg-u-visually-hidden': !this.slotlabel.display }} slot=\"label\">\n {this.slotlabel.label}\n </span>\n <mg-menu direction={Direction.VERTICAL} label={this.messages.menuLabel} size={this.size}></mg-menu>\n </mg-menu-item>\n )}\n </Host>\n );\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mg-form.conf.js","sourceRoot":"","sources":["../../../../src/components/molecules/mg-form/mg-form.conf.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mg-form.conf.js","sourceRoot":"","sources":["../../../../src/components/molecules/mg-form/mg-form.conf.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,CAAU,CAAC;AAOzE;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,SAAS,EAAE,MAAM,CAAU,CAAC","sourcesContent":["import { AriaRole } from '../../../types';\n\n/**\n * List of all possibles roles\n */\nexport const roles = ['form', 'search', 'none', 'presentation'] as const;\n\n/**\n * Aria Role type from roles\n */\nexport type AriaRoleType = AriaRole & (typeof roles)[number];\n\n/**\n * List of all possibles required message status\n */\nexport const requiredMessageStatus = ['default', 'hide'] as const;\n\n/**\n * RequiredMessageStatus type from requiredMessageStatus\n */\nexport type RequiredMessageStatusType = (typeof requiredMessageStatus)[number];\n"]}
|
|
@@ -78,7 +78,7 @@ export class MgForm {
|
|
|
78
78
|
*/
|
|
79
79
|
this.setMgInputs = () => {
|
|
80
80
|
// Get slotted mgInputs
|
|
81
|
-
this.mgInputs = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-INPUT
|
|
81
|
+
this.mgInputs = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-INPUT'));
|
|
82
82
|
// Set inputs readonly or disabled based on form configuration
|
|
83
83
|
// Othewise listen to events
|
|
84
84
|
this.mgInputs.forEach(input => {
|
|
@@ -147,6 +147,18 @@ export class MgForm {
|
|
|
147
147
|
this.checkValidity();
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Reset form inputs values, validity and error state
|
|
152
|
+
*/
|
|
153
|
+
async reset() {
|
|
154
|
+
if (!this.readonly) {
|
|
155
|
+
await Promise.all(this.mgInputs.map(async (input) => {
|
|
156
|
+
if (input.reset !== undefined) {
|
|
157
|
+
await input.reset();
|
|
158
|
+
}
|
|
159
|
+
}));
|
|
160
|
+
}
|
|
161
|
+
}
|
|
150
162
|
/*************
|
|
151
163
|
* Lifecycle *
|
|
152
164
|
*************/
|
|
@@ -186,6 +198,7 @@ export class MgForm {
|
|
|
186
198
|
// Update mgInputs when mgForm content change
|
|
187
199
|
new MutationObserver(() => {
|
|
188
200
|
this.setMgInputs();
|
|
201
|
+
this.checkValidity();
|
|
189
202
|
}).observe(this.element, { childList: true });
|
|
190
203
|
}
|
|
191
204
|
/**
|
|
@@ -193,7 +206,7 @@ export class MgForm {
|
|
|
193
206
|
* @returns HTML Element
|
|
194
207
|
*/
|
|
195
208
|
render() {
|
|
196
|
-
return (h("form", { key: '
|
|
209
|
+
return (h("form", { key: 'ecfaff2bb897ce2c48ed352167bb418703a56c98', class: this.classCollection.join(), id: this.identifier, name: this.name, onSubmit: this.handleFormSubmit, role: this.ariaRole }, this.requiredMessageText && h("p", { key: '4d4fa2ff3cf4f25ebe0b009ae1995734bfcafd3b', innerHTML: this.requiredMessageText }), h("slot", { key: 'dc0c7acadf6b744335852f847a8336b018e28cb5' }), !this.readonly && !this.disabled && h("slot", { key: 'ede3ace32f6a88067845013fa65e5414cae5fcea', name: "actions" })));
|
|
197
210
|
}
|
|
198
211
|
static get is() { return "mg-form"; }
|
|
199
212
|
static get encapsulation() { return "shadow"; }
|
|
@@ -442,6 +455,23 @@ export class MgForm {
|
|
|
442
455
|
"text": "Display input error if it exists.",
|
|
443
456
|
"tags": []
|
|
444
457
|
}
|
|
458
|
+
},
|
|
459
|
+
"reset": {
|
|
460
|
+
"complexType": {
|
|
461
|
+
"signature": "() => Promise<void>",
|
|
462
|
+
"parameters": [],
|
|
463
|
+
"references": {
|
|
464
|
+
"Promise": {
|
|
465
|
+
"location": "global",
|
|
466
|
+
"id": "global::Promise"
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
"return": "Promise<void>"
|
|
470
|
+
},
|
|
471
|
+
"docs": {
|
|
472
|
+
"text": "Reset form inputs values, validity and error state",
|
|
473
|
+
"tags": []
|
|
474
|
+
}
|
|
445
475
|
}
|
|
446
476
|
};
|
|
447
477
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mg-form.js","sourceRoot":"","sources":["../../../../src/components/molecules/mg-form/mg-form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAgB,qBAAqB,EAA6B,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvG;;;GAGG;AAMH,MAAM,OAAO,MAAM;;QAQjB,UAAU;QACO,qBAAgB,GAAG,yBAAyB,CAAC;QAC7C,oBAAe,GAAG,yBAAyB,CAAC;QAqI7D;;WAEG;QACK,uBAAkB,GA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AAC;QACrB,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,CAAC;IAED;;;OAGG;IACH,MAAM;QACJ,OAAO,CACL,6DAAM,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ;YACjI,IAAI,CAAC,mBAAmB,IAAI,0DAAG,SAAS,EAAE,IAAI,CAAC,mBAAmB,GAAM;YACzE,8DAAa;YACZ,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,6DAAM,IAAI,EAAC,SAAS,GAAQ,CAC5D,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Method, Prop, State, Watch } from '@stencil/core';\nimport { createID, ClassList, toString, isValideID } from '@mgdis/stencil-helpers';\nimport { initLocales } from '../../../locales';\nimport { HTMLMgInputsElement } from '../inputs/mg-input/mg-input.conf';\nimport { AriaRoleType, requiredMessageStatus, RequiredMessageStatusType, roles } from './mg-form.conf';\n\n/**\n * @slot - Form content\n * @slot actions - Actions content\n */\n@Component({\n tag: 'mg-form',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-form.css',\n shadow: true,\n})\nexport class MgForm {\n /************\n * Internal *\n ************/\n\n private mgInputs: (HTMLMgInputsElement & { disabled: boolean })[];\n private mgButtons: HTMLMgButtonElement[];\n\n // Classes\n private readonly classAllRequired = 'mg-c-form--all-required';\n private readonly classLabelOnTop = 'mg-c-form--label-on-top';\n\n // Locales\n private messages;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgFormElement;\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n * If not set, it will be created.\n */\n @Prop() identifier: string = createID('mg-form');\n @Watch('identifier')\n watchIdentifier(newValue: MgForm['identifier']): void {\n if (!isValideID(newValue)) {\n console.error(`<mg-form> prop \"identifier\" value is invalid. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Input name\n * If not set the value equals the identifier\n */\n @Prop() name: string = this.identifier;\n\n /**\n * Define if form is readonly\n */\n @Prop() readonly = false;\n\n /**\n * Define when required message is display.\n * When it is unset, component use it internal logic to manage \"required message\" help text display.\n * When you set the prop to `default`, you override the component internal logique to torce it display \"required message\" help text.\n * When you set the prop to `hide`, it will prevent the rendering of the message in the component's DOM.\n * As **this element is an accessibility requirement in the view**,\n * you **MUST*** re-implement this message on your own and display it when your form contains required inputs.\n */\n @Prop() requiredMessage?: RequiredMessageStatusType;\n @Watch('requiredMessage')\n validateRequiredMessage(newValue): void {\n if (newValue && !requiredMessageStatus.includes(newValue)) {\n throw new Error(`<mg-form> prop \"requiredMessage\" must be one of: ${requiredMessageStatus.join(', ')}. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Define `<form/>` element aria role\n * see more about aria roles use case: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles\n */\n @Prop() ariaRole?: AriaRoleType;\n @Watch('ariaRole')\n validateAriaRole(newValue: MgForm['ariaRole']) {\n if (newValue && !roles.includes(newValue)) {\n throw new Error(`<mg-form> prop \"ariaRole\" must be one of: ${roles.join(', ')}. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Define if slotted mg-component's label are displayed on top\n */\n @Prop() labelOnTop?: boolean;\n @Watch('labelOnTop')\n handlelabelOnTop(newValue: MgForm['labelOnTop']) {\n if (newValue) {\n this.classCollection.add(this.classLabelOnTop);\n } else {\n this.classCollection.delete(this.classLabelOnTop);\n }\n }\n /**\n * Define if form is disabled\n */\n @Prop() disabled = false;\n @Watch('readonly')\n @Watch('disabled')\n @Watch('requiredMessage')\n handleAttributeChange(): void {\n this.setMgInputs();\n this.setRequiredMessage();\n }\n\n /**\n * Define form valid state\n */\n @Prop({ mutable: true }) valid: boolean;\n\n /**\n * Define form invalid state\n */\n @Prop({ mutable: true }) invalid: boolean;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-form']);\n\n /**\n * Required message\n */\n @State() requiredMessageText: string;\n\n /**\n * Emitted event on form validity check\n * Tells if form is valid or not\n */\n @Event({ eventName: 'form-valid' }) formValid: EventEmitter<HTMLMgFormElement['valid']>;\n\n /**\n * Emitted event on form submit\n */\n @Event({ eventName: 'form-submit' }) formSubmit: EventEmitter<boolean>;\n\n /**\n * Display input error if it exists.\n */\n @Method()\n async displayError(): Promise<void> {\n if (!this.readonly) {\n this.mgInputs.forEach(input => {\n input.displayError?.();\n });\n this.checkValidity();\n }\n }\n\n /**\n * Define required message based on mg-inputs required elements\n */\n private setRequiredMessage = (): void => {\n // init required message\n this.requiredMessageText = null;\n this.classCollection.delete(this.classAllRequired);\n\n if (this.requiredMessage === 'hide') return;\n else if (this.requiredMessage === 'default') {\n this.requiredMessageText = this.messages.form.required;\n return;\n }\n\n // If the form is disabled or readonly none of them are required\n // Check if all fields are not editable (readonly or disabled)\n const isEditable = input => !(input.disabled || input.readonly);\n const isMgInputToggle = input => input.nodeName === 'MG-INPUT-TOGGLE';\n if (!this.disabled && !this.readonly && this.mgInputs.some(input => isEditable(input) && !isMgInputToggle(input))) {\n // Get editable inputs\n const editableInputs: HTMLMgInputsElement[] = this.mgInputs.filter(isEditable);\n // Get required inputs\n // mg-input-toggle can not be required\n const requiredInputs: HTMLMgInputsElement[] = editableInputs.filter(input => !isMgInputToggle(input) && input.required);\n // All inputs are required\n if (\n [requiredInputs.length, editableInputs.length].every(length => length === 1) ||\n (requiredInputs.length > 1 && requiredInputs.length === editableInputs.filter(input => !isMgInputToggle(input)).length)\n ) {\n this.requiredMessageText = this.getRequiredMessageBasedOnCount(requiredInputs, 'allRequiredSingle', 'allRequired');\n this.classCollection.add(this.classAllRequired);\n }\n // Some fields are required\n else if (requiredInputs.length > 0) {\n this.requiredMessageText = this.getRequiredMessageBasedOnCount(requiredInputs, 'requiredSingle', 'required');\n }\n }\n };\n\n /**\n * Returns a required message based on the count of required inputs.\n * @param requiredInputs - An array of required input elements.\n * @param keySingle - The key for the singular message format.\n * @param keyPlural - The key for the plural message format.\n * @returns The appropriate required message based on the count of required inputs.\n */\n private getRequiredMessageBasedOnCount = (requiredInputs: HTMLMgInputsElement[], keySingle: string, keyPlural: string) =>\n this.messages.form[requiredInputs.length === 1 ? keySingle : keyPlural];\n\n /**\n * Check if form is valid\n */\n private checkValidity = (): void => {\n // Update required on input event\n this.setRequiredMessage();\n\n this.valid = !this.mgInputs.some(input => input.invalid);\n this.invalid = !this.valid;\n // We need to send valid event if it is the same value\n this.formValid.emit(this.valid);\n };\n\n /**\n * Handle Form Submit\n * @param event - submit event\n */\n private handleFormSubmit = (event: SubmitEvent): void => {\n event.preventDefault();\n this.formSubmit.emit();\n };\n\n /**\n * Set mgInputs\n */\n private setMgInputs = (): void => {\n // Get slotted mgInputs\n this.mgInputs = Array.from(this.element.querySelectorAll('*')).filter((node: Node) => node.nodeName.startsWith('MG-INPUT-')) as (HTMLMgInputsElement & { disabled: boolean })[];\n // Set inputs readonly or disabled based on form configuration\n // Othewise listen to events\n this.mgInputs.forEach(input => {\n if (this.labelOnTop) {\n input.labelOnTop = true;\n }\n if (this.readonly) {\n input.readonly = true;\n } else if (this.disabled) {\n input.disabled = true;\n } else {\n input.addEventListener('input-valid', this.checkValidity);\n }\n });\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n */\n componentWillLoad(): void {\n // Get locales\n this.messages = initLocales(this.element).messages;\n\n this.watchIdentifier(this.identifier);\n this.validateAriaRole(this.ariaRole);\n this.validateRequiredMessage(this.requiredMessage);\n this.handlelabelOnTop(this.labelOnTop);\n\n // Get slotted mgButtons\n this.mgButtons = Array.from(this.element.querySelectorAll('mg-button'));\n\n // Set button form identifier\n this.mgButtons.forEach(mgButton => {\n mgButton.setAttribute('form', this.identifier);\n });\n\n // Set mgInputs\n this.setMgInputs();\n\n // Check validity when slotted mgInputs are ready\n Promise.all(\n this.mgInputs.map(async input => {\n try {\n await input.componentOnReady();\n } catch {} // prevent error with VueJS first render\n }),\n ).then(() => {\n // Define required message and check validity\n this.checkValidity();\n });\n }\n\n /**\n * Add slot listeners\n */\n componentDidLoad(): void {\n // Update mgInputs when mgForm content change\n new MutationObserver(() => {\n this.setMgInputs();\n }).observe(this.element, { childList: true });\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <form class={this.classCollection.join()} id={this.identifier} name={this.name} onSubmit={this.handleFormSubmit} role={this.ariaRole}>\n {this.requiredMessageText && <p innerHTML={this.requiredMessageText}></p>}\n <slot></slot>\n {!this.readonly && !this.disabled && <slot name=\"actions\"></slot>}\n </form>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mg-form.js","sourceRoot":"","sources":["../../../../src/components/molecules/mg-form/mg-form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;A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AAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Method, Prop, State, Watch } from '@stencil/core';\nimport { createID, ClassList, toString, isValideID } from '@mgdis/stencil-helpers';\nimport { initLocales } from '../../../locales';\nimport { HTMLMgInputsElement } from '../inputs/mg-input/mg-input.conf';\nimport { AriaRoleType, requiredMessageStatus, RequiredMessageStatusType, roles } from './mg-form.conf';\n\n/**\n * @slot - Form content\n * @slot actions - Actions content\n */\n@Component({\n tag: 'mg-form',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-form.css',\n shadow: true,\n})\nexport class MgForm {\n /************\n * Internal *\n ************/\n\n private mgInputs: (HTMLMgInputsElement & { disabled: boolean })[];\n private mgButtons: HTMLMgButtonElement[];\n\n // Classes\n private readonly classAllRequired = 'mg-c-form--all-required';\n private readonly classLabelOnTop = 'mg-c-form--label-on-top';\n\n // Locales\n private messages;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgFormElement;\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n * If not set, it will be created.\n */\n @Prop() identifier: string = createID('mg-form');\n @Watch('identifier')\n watchIdentifier(newValue: MgForm['identifier']): void {\n if (!isValideID(newValue)) {\n console.error(`<mg-form> prop \"identifier\" value is invalid. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Input name\n * If not set the value equals the identifier\n */\n @Prop() name: string = this.identifier;\n\n /**\n * Define if form is readonly\n */\n @Prop() readonly = false;\n\n /**\n * Define when required message is display.\n * When it is unset, component use it internal logic to manage \"required message\" help text display.\n * When you set the prop to `default`, you override the component internal logique to torce it display \"required message\" help text.\n * When you set the prop to `hide`, it will prevent the rendering of the message in the component's DOM.\n * As **this element is an accessibility requirement in the view**,\n * you **MUST*** re-implement this message on your own and display it when your form contains required inputs.\n */\n @Prop() requiredMessage?: RequiredMessageStatusType;\n @Watch('requiredMessage')\n validateRequiredMessage(newValue): void {\n if (newValue && !requiredMessageStatus.includes(newValue)) {\n throw new Error(`<mg-form> prop \"requiredMessage\" must be one of: ${requiredMessageStatus.join(', ')}. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Define `<form/>` element aria role\n * see more about aria roles use case: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles\n */\n @Prop() ariaRole?: AriaRoleType;\n @Watch('ariaRole')\n validateAriaRole(newValue: MgForm['ariaRole']) {\n if (newValue && !roles.includes(newValue)) {\n throw new Error(`<mg-form> prop \"ariaRole\" must be one of: ${roles.join(', ')}. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Define if slotted mg-component's label are displayed on top\n */\n @Prop() labelOnTop?: boolean;\n @Watch('labelOnTop')\n handlelabelOnTop(newValue: MgForm['labelOnTop']) {\n if (newValue) {\n this.classCollection.add(this.classLabelOnTop);\n } else {\n this.classCollection.delete(this.classLabelOnTop);\n }\n }\n /**\n * Define if form is disabled\n */\n @Prop() disabled = false;\n @Watch('readonly')\n @Watch('disabled')\n @Watch('requiredMessage')\n handleAttributeChange(): void {\n this.setMgInputs();\n this.setRequiredMessage();\n }\n\n /**\n * Define form valid state\n */\n @Prop({ mutable: true }) valid: boolean;\n\n /**\n * Define form invalid state\n */\n @Prop({ mutable: true }) invalid: boolean;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-form']);\n\n /**\n * Required message\n */\n @State() requiredMessageText: string;\n\n /**\n * Emitted event on form validity check\n * Tells if form is valid or not\n */\n @Event({ eventName: 'form-valid' }) formValid: EventEmitter<HTMLMgFormElement['valid']>;\n\n /**\n * Emitted event on form submit\n */\n @Event({ eventName: 'form-submit' }) formSubmit: EventEmitter<boolean>;\n\n /**\n * Display input error if it exists.\n */\n @Method()\n async displayError(): Promise<void> {\n if (!this.readonly) {\n this.mgInputs.forEach(input => {\n input.displayError?.();\n });\n this.checkValidity();\n }\n }\n\n /**\n * Reset form inputs values, validity and error state\n */\n @Method()\n async reset(): Promise<void> {\n if (!this.readonly) {\n await Promise.all(\n this.mgInputs.map(async input => {\n if (input.reset !== undefined) {\n await input.reset();\n }\n }),\n );\n }\n }\n\n /**\n * Define required message based on mg-inputs required elements\n */\n private setRequiredMessage = (): void => {\n // init required message\n this.requiredMessageText = null;\n this.classCollection.delete(this.classAllRequired);\n\n if (this.requiredMessage === 'hide') return;\n else if (this.requiredMessage === 'default') {\n this.requiredMessageText = this.messages.form.required;\n return;\n }\n\n // If the form is disabled or readonly none of them are required\n // Check if all fields are not editable (readonly or disabled)\n const isEditable = input => !(input.disabled || input.readonly);\n const isMgInputToggle = input => input.nodeName === 'MG-INPUT-TOGGLE';\n if (!this.disabled && !this.readonly && this.mgInputs.some(input => isEditable(input) && !isMgInputToggle(input))) {\n // Get editable inputs\n const editableInputs: HTMLMgInputsElement[] = this.mgInputs.filter(isEditable);\n // Get required inputs\n // mg-input-toggle can not be required\n const requiredInputs: HTMLMgInputsElement[] = editableInputs.filter(input => !isMgInputToggle(input) && input.required);\n // All inputs are required\n if (\n [requiredInputs.length, editableInputs.length].every(length => length === 1) ||\n (requiredInputs.length > 1 && requiredInputs.length === editableInputs.filter(input => !isMgInputToggle(input)).length)\n ) {\n this.requiredMessageText = this.getRequiredMessageBasedOnCount(requiredInputs, 'allRequiredSingle', 'allRequired');\n this.classCollection.add(this.classAllRequired);\n }\n // Some fields are required\n else if (requiredInputs.length > 0) {\n this.requiredMessageText = this.getRequiredMessageBasedOnCount(requiredInputs, 'requiredSingle', 'required');\n }\n }\n };\n\n /**\n * Returns a required message based on the count of required inputs.\n * @param requiredInputs - An array of required input elements.\n * @param keySingle - The key for the singular message format.\n * @param keyPlural - The key for the plural message format.\n * @returns The appropriate required message based on the count of required inputs.\n */\n private getRequiredMessageBasedOnCount = (requiredInputs: HTMLMgInputsElement[], keySingle: string, keyPlural: string) =>\n this.messages.form[requiredInputs.length === 1 ? keySingle : keyPlural];\n\n /**\n * Check if form is valid\n */\n private checkValidity = (): void => {\n // Update required on input event\n this.setRequiredMessage();\n\n this.valid = !this.mgInputs.some(input => input.invalid);\n this.invalid = !this.valid;\n // We need to send valid event if it is the same value\n this.formValid.emit(this.valid);\n };\n\n /**\n * Handle Form Submit\n * @param event - submit event\n */\n private handleFormSubmit = (event: SubmitEvent): void => {\n event.preventDefault();\n this.formSubmit.emit();\n };\n\n /**\n * Set mgInputs\n */\n private setMgInputs = (): void => {\n // Get slotted mgInputs\n this.mgInputs = Array.from(this.element.querySelectorAll('*')).filter((node: Node) => node.nodeName.startsWith('MG-INPUT')) as (HTMLMgInputsElement & { disabled: boolean })[];\n // Set inputs readonly or disabled based on form configuration\n // Othewise listen to events\n this.mgInputs.forEach(input => {\n if (this.labelOnTop) {\n input.labelOnTop = true;\n }\n if (this.readonly) {\n input.readonly = true;\n } else if (this.disabled) {\n input.disabled = true;\n } else {\n input.addEventListener('input-valid', this.checkValidity);\n }\n });\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n */\n componentWillLoad(): void {\n // Get locales\n this.messages = initLocales(this.element).messages;\n\n this.watchIdentifier(this.identifier);\n this.validateAriaRole(this.ariaRole);\n this.validateRequiredMessage(this.requiredMessage);\n this.handlelabelOnTop(this.labelOnTop);\n\n // Get slotted mgButtons\n this.mgButtons = Array.from(this.element.querySelectorAll('mg-button'));\n\n // Set button form identifier\n this.mgButtons.forEach(mgButton => {\n mgButton.setAttribute('form', this.identifier);\n });\n\n // Set mgInputs\n this.setMgInputs();\n\n // Check validity when slotted mgInputs are ready\n Promise.all(\n this.mgInputs.map(async input => {\n try {\n await input.componentOnReady();\n } catch {} // prevent error with VueJS first render\n }),\n ).then(() => {\n // Define required message and check validity\n this.checkValidity();\n });\n }\n\n /**\n * Add slot listeners\n */\n componentDidLoad(): void {\n // Update mgInputs when mgForm content change\n new MutationObserver(() => {\n this.setMgInputs();\n this.checkValidity();\n }).observe(this.element, { childList: true });\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <form class={this.classCollection.join()} id={this.identifier} name={this.name} onSubmit={this.handleFormSubmit} role={this.ariaRole}>\n {this.requiredMessageText && <p innerHTML={this.requiredMessageText}></p>}\n <slot></slot>\n {!this.readonly && !this.disabled && <slot name=\"actions\"></slot>}\n </form>\n );\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mg-progress.conf.js","sourceRoot":"","sources":["../../../../src/components/molecules/mg-progress/mg-progress.conf.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,aAAa,EAAE,OAAO,CAAU,CAAC","sourcesContent":["import { AriaRole } from '../../../types';\n\n/**\n * List of all possibles roles\n */\nexport const roles = ['progressbar', 'meter'] as const;\n\n/**\n * Aria Role type from roles\n */\nexport type AriaRoleType = AriaRole & (typeof roles)[number];\n"]}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { h, Host } from "@stencil/core";
|
|
2
|
+
import { isValidNumber, isValidString, toString } from "@mgdis/stencil-helpers";
|
|
3
|
+
import { roles } from "./mg-progress.conf";
|
|
4
|
+
export class MgProgress {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.label = undefined;
|
|
7
|
+
this.ariaRole = 'progressbar';
|
|
8
|
+
this.value = 0;
|
|
9
|
+
this.min = 0;
|
|
10
|
+
this.max = 100;
|
|
11
|
+
}
|
|
12
|
+
watchLabel(newValue) {
|
|
13
|
+
if (!isValidString(newValue)) {
|
|
14
|
+
throw new Error(`<mg-progress> prop "label" must be a valid string. Passed value: ${toString(newValue)}.`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
watchAriaRole(newValue) {
|
|
18
|
+
if (newValue && !roles.includes(newValue)) {
|
|
19
|
+
throw new Error(`<mg-progress> prop "ariaRole" must be one of: ${roles.join(', ')}. Passed value: ${toString(newValue)}.`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
watchValue(newValue) {
|
|
23
|
+
if (newValue !== undefined && (!isValidNumber(newValue) || !(newValue >= this.min && newValue <= this.max)))
|
|
24
|
+
throw new Error(`<mg-progress> prop “value” must be a number within the range ${this.min} to ${this.max}. Passed value: ${toString(newValue)}.`);
|
|
25
|
+
}
|
|
26
|
+
watchMin(newValue) {
|
|
27
|
+
if (newValue !== 0 && newValue !== undefined && (!isValidNumber(newValue) || newValue >= this.max))
|
|
28
|
+
throw new Error(`<mg-progress> prop “min” must be a number lower than: ${this.max}. Passed value: ${toString(newValue)}.`);
|
|
29
|
+
}
|
|
30
|
+
watchMax(newValue) {
|
|
31
|
+
if (newValue !== 100 && newValue !== undefined && (!isValidNumber(newValue) || newValue <= this.min))
|
|
32
|
+
throw new Error(`<mg-progress> prop “max” must be a number greater than: ${this.min}. Passed value: ${toString(newValue)}.`);
|
|
33
|
+
}
|
|
34
|
+
/*************
|
|
35
|
+
* Lifecycle *
|
|
36
|
+
*************/
|
|
37
|
+
/**
|
|
38
|
+
* Check if component props are well configured on init
|
|
39
|
+
*/
|
|
40
|
+
componentWillLoad() {
|
|
41
|
+
// validate props
|
|
42
|
+
this.watchLabel(this.label);
|
|
43
|
+
this.watchAriaRole(this.ariaRole);
|
|
44
|
+
this.watchMin(this.min);
|
|
45
|
+
this.watchMax(this.max);
|
|
46
|
+
this.watchValue(this.value);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Render
|
|
50
|
+
* @returns HTML Element
|
|
51
|
+
*/
|
|
52
|
+
render() {
|
|
53
|
+
return (h(Host, { key: 'c2a8b5264af27dab4f81981a6d20d04d572321db', role: this.ariaRole, "aria-label": this.label, "aria-valuenow": this.value, "aria-valuemin": this.min, "aria-valuemax": this.max }, h("div", { key: '1ab08ca9582182c7c2e9cf1041e68cfd38390e3b', class: "mg-c-progress" }, h("div", { key: '95044f35b5fcc1b5eb380828acc3935ff30c6c1f', class: { 'mg-c-progress__bar': true, 'mg-c-progress__bar--active': this.value > this.min } }, h("div", { key: '4d3588379c0b1a135dd9118fd2cb3c00c9dd31cb', class: "mg-c-progress__fill", style: {
|
|
54
|
+
width: `${Math.round(((this.value - this.min) / (this.max - this.min)) * 100)}%`,
|
|
55
|
+
} })))));
|
|
56
|
+
}
|
|
57
|
+
static get is() { return "mg-progress"; }
|
|
58
|
+
static get encapsulation() { return "shadow"; }
|
|
59
|
+
static get originalStyleUrls() {
|
|
60
|
+
return {
|
|
61
|
+
"$": ["../../../../node_modules/@mgdis/styles/dist/components/mg-progress.css"]
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
static get styleUrls() {
|
|
65
|
+
return {
|
|
66
|
+
"$": ["../../../../node_modules/@mgdis/styles/dist/components/mg-progress.css"]
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
static get properties() {
|
|
70
|
+
return {
|
|
71
|
+
"label": {
|
|
72
|
+
"type": "string",
|
|
73
|
+
"mutable": false,
|
|
74
|
+
"complexType": {
|
|
75
|
+
"original": "string",
|
|
76
|
+
"resolved": "string",
|
|
77
|
+
"references": {}
|
|
78
|
+
},
|
|
79
|
+
"required": true,
|
|
80
|
+
"optional": false,
|
|
81
|
+
"docs": {
|
|
82
|
+
"tags": [],
|
|
83
|
+
"text": "Define label"
|
|
84
|
+
},
|
|
85
|
+
"attribute": "label",
|
|
86
|
+
"reflect": false
|
|
87
|
+
},
|
|
88
|
+
"ariaRole": {
|
|
89
|
+
"type": "string",
|
|
90
|
+
"mutable": false,
|
|
91
|
+
"complexType": {
|
|
92
|
+
"original": "AriaRoleType",
|
|
93
|
+
"resolved": "\"meter\" | \"progressbar\"",
|
|
94
|
+
"references": {
|
|
95
|
+
"AriaRoleType": {
|
|
96
|
+
"location": "import",
|
|
97
|
+
"path": "./mg-progress.conf",
|
|
98
|
+
"id": "src/components/molecules/mg-progress/mg-progress.conf.ts::AriaRoleType"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"required": false,
|
|
103
|
+
"optional": true,
|
|
104
|
+
"docs": {
|
|
105
|
+
"tags": [],
|
|
106
|
+
"text": "Define progress role\n- `progressbar` to indicate a progress, such as loading or percent completion of a task\n- `meter` to indicate a graphical display of a numeric value that varies within a defined range"
|
|
107
|
+
},
|
|
108
|
+
"attribute": "aria-role",
|
|
109
|
+
"reflect": false,
|
|
110
|
+
"defaultValue": "'progressbar'"
|
|
111
|
+
},
|
|
112
|
+
"value": {
|
|
113
|
+
"type": "number",
|
|
114
|
+
"mutable": false,
|
|
115
|
+
"complexType": {
|
|
116
|
+
"original": "number",
|
|
117
|
+
"resolved": "number",
|
|
118
|
+
"references": {}
|
|
119
|
+
},
|
|
120
|
+
"required": false,
|
|
121
|
+
"optional": true,
|
|
122
|
+
"docs": {
|
|
123
|
+
"tags": [],
|
|
124
|
+
"text": "Define current value\nBy default, it will be displayed as a percentage value.\nIf you don\u2019t specify the min and max props, the value should be a number within the range of 0 to 100."
|
|
125
|
+
},
|
|
126
|
+
"attribute": "value",
|
|
127
|
+
"reflect": false,
|
|
128
|
+
"defaultValue": "0"
|
|
129
|
+
},
|
|
130
|
+
"min": {
|
|
131
|
+
"type": "number",
|
|
132
|
+
"mutable": false,
|
|
133
|
+
"complexType": {
|
|
134
|
+
"original": "number",
|
|
135
|
+
"resolved": "number",
|
|
136
|
+
"references": {}
|
|
137
|
+
},
|
|
138
|
+
"required": false,
|
|
139
|
+
"optional": true,
|
|
140
|
+
"docs": {
|
|
141
|
+
"tags": [],
|
|
142
|
+
"text": "Define the minimum value in the range"
|
|
143
|
+
},
|
|
144
|
+
"attribute": "min",
|
|
145
|
+
"reflect": false,
|
|
146
|
+
"defaultValue": "0"
|
|
147
|
+
},
|
|
148
|
+
"max": {
|
|
149
|
+
"type": "number",
|
|
150
|
+
"mutable": false,
|
|
151
|
+
"complexType": {
|
|
152
|
+
"original": "number",
|
|
153
|
+
"resolved": "number",
|
|
154
|
+
"references": {}
|
|
155
|
+
},
|
|
156
|
+
"required": false,
|
|
157
|
+
"optional": true,
|
|
158
|
+
"docs": {
|
|
159
|
+
"tags": [],
|
|
160
|
+
"text": "Define the maximum value in the range"
|
|
161
|
+
},
|
|
162
|
+
"attribute": "max",
|
|
163
|
+
"reflect": false,
|
|
164
|
+
"defaultValue": "100"
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
static get watchers() {
|
|
169
|
+
return [{
|
|
170
|
+
"propName": "label",
|
|
171
|
+
"methodName": "watchLabel"
|
|
172
|
+
}, {
|
|
173
|
+
"propName": "ariaRole",
|
|
174
|
+
"methodName": "watchAriaRole"
|
|
175
|
+
}, {
|
|
176
|
+
"propName": "value",
|
|
177
|
+
"methodName": "watchValue"
|
|
178
|
+
}, {
|
|
179
|
+
"propName": "min",
|
|
180
|
+
"methodName": "watchMin"
|
|
181
|
+
}, {
|
|
182
|
+
"propName": "max",
|
|
183
|
+
"methodName": "watchMax"
|
|
184
|
+
}];
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=mg-progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mg-progress.js","sourceRoot":"","sources":["../../../../src/components/molecules/mg-progress/mg-progress.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,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G,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG;yBACjF,GACI,CACH,CACF,CACD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Host, Prop, Watch } from '@stencil/core';\nimport { isValidNumber, isValidString, toString } from '@mgdis/stencil-helpers';\nimport { AriaRoleType, roles } from './mg-progress.conf';\n\n@Component({\n tag: 'mg-progress',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-progress.css',\n shadow: true,\n})\nexport class MgProgress {\n /**************\n * Decorators *\n **************/\n\n /**\n * Define label\n */\n @Prop() label!: string;\n @Watch('label')\n watchLabel(newValue: MgProgress['label']): void {\n if (!isValidString(newValue)) {\n throw new Error(`<mg-progress> prop \"label\" must be a valid string. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Define progress role\n * - `progressbar` to indicate a progress, such as loading or percent completion of a task\n * - `meter` to indicate a graphical display of a numeric value that varies within a defined range\n */\n @Prop() ariaRole?: AriaRoleType = 'progressbar';\n @Watch('ariaRole')\n watchAriaRole(newValue: MgProgress['ariaRole']): void {\n if (newValue && !roles.includes(newValue)) {\n throw new Error(`<mg-progress> prop \"ariaRole\" must be one of: ${roles.join(', ')}. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Define current value\n * By default, it will be displayed as a percentage value.\n * If you don’t specify the min and max props, the value should be a number within the range of 0 to 100.\n */\n @Prop() value?: number = 0;\n @Watch('value')\n watchValue(newValue: MgProgress['value']): void {\n if (newValue !== undefined && (!isValidNumber(newValue) || !(newValue >= this.min && newValue <= this.max)))\n throw new Error(`<mg-progress> prop “value” must be a number within the range ${this.min} to ${this.max}. Passed value: ${toString(newValue)}.`);\n }\n\n /**\n * Define the minimum value in the range\n */\n @Prop() min?: number = 0;\n @Watch('min')\n watchMin(newValue: MgProgress['min']): void {\n if (newValue !== 0 && newValue !== undefined && (!isValidNumber(newValue) || newValue >= this.max))\n throw new Error(`<mg-progress> prop “min” must be a number lower than: ${this.max}. Passed value: ${toString(newValue)}.`);\n }\n\n /**\n * Define the maximum value in the range\n */\n @Prop() max?: number = 100;\n @Watch('max')\n watchMax(newValue: MgProgress['max']): void {\n if (newValue !== 100 && newValue !== undefined && (!isValidNumber(newValue) || newValue <= this.min))\n throw new Error(`<mg-progress> prop “max” must be a number greater than: ${this.min}. Passed value: ${toString(newValue)}.`);\n }\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n */\n componentWillLoad(): void {\n // validate props\n this.watchLabel(this.label);\n this.watchAriaRole(this.ariaRole);\n this.watchMin(this.min);\n this.watchMax(this.max);\n this.watchValue(this.value);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <Host role={this.ariaRole} aria-label={this.label} aria-valuenow={this.value} aria-valuemin={this.min} aria-valuemax={this.max}>\n <div class=\"mg-c-progress\">\n <div class={{ 'mg-c-progress__bar': true, 'mg-c-progress__bar--active': this.value > this.min }}>\n <div\n class=\"mg-c-progress__fill\"\n style={{\n width: `${Math.round(((this.value - this.min) / (this.max - this.min)) * 100)}%`,\n }}\n ></div>\n </div>\n </div>\n </Host>\n );\n }\n}\n"]}
|
|
@@ -36,7 +36,7 @@ export class MgSkipLinks {
|
|
|
36
36
|
* @returns HTML Element
|
|
37
37
|
*/
|
|
38
38
|
render() {
|
|
39
|
-
return (h("nav", { key: '
|
|
39
|
+
return (h("nav", { key: '0b4e4d6b9481a88faae78602b07c4f5e851da517', class: "mg-c-skip-links", role: "navigation", "aria-label": this.messages.skipLinks.navLabel }, h("ul", { key: 'aaa15193eb2c9e1d9ee3b2e2a7d8d0fd37836ed7', class: "mg-c-skip-links__list", role: "list" }, this.links.map(link => (h("li", { key: link.href }, h("a", { class: "mg-c-skip-links__link", href: link.href, onClick: this.handleLinkCLick }, link.label)))))));
|
|
40
40
|
}
|
|
41
41
|
static get is() { return "mg-skip-links"; }
|
|
42
42
|
static get encapsulation() { return "shadow"; }
|
|
@@ -223,7 +223,7 @@ export class MgTabs {
|
|
|
223
223
|
* @returns HTML Element
|
|
224
224
|
*/
|
|
225
225
|
render() {
|
|
226
|
-
return (h("div", { key: '
|
|
226
|
+
return (h("div", { key: '54bad50e0a610aaae267fb34384384a2aa3a2295', class: this.classCollection.join() }, h("header", { key: '8bc4f73112f9de115b8558a7d322398b62983fb7', role: "tablist", "aria-label": this.label, class: "mg-c-tabs__header" }, this.tabs.map((tab, index) => (h("button", { key: tab.label, role: "tab", id: this.getElementId(this.identifier, index), class: {
|
|
227
227
|
[`${this.buttonTabBaseClass}`]: true,
|
|
228
228
|
[`${this.buttonTabBaseClass}--horizontal`]: true,
|
|
229
229
|
[`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.tabHasStatus(tab, Status.ACTIVE),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Defines the possible values for size\n */\nexport type Size = 'xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge';\n\n/**\n * Defines the possible values for variant\n */\nexport type Variant = 'info' | 'success' | 'warning' | 'danger' | 'danger-alt' | 'primary' | 'secondary' | 'app' | 'light' | 'dark' | 'flat' | 'text-color' | 'link';\n\n/**\n * Defines the possible values for variantStyle\n */\nexport type VariantStyle = 'icon' | 'background' | 'bar-left' | 'full';\n\n/**\n * Defines the possible values for input error\n */\nexport type InputError = 'min' | 'max' | 'minMax' | 'required' | 'badInput';\n\n/**\n * Defines the possible values for status\n */\nexport type Status = 'visible' | 'hidden' | 'disabled' | 'active';\n\n/**\n * Define option type\n */\nexport type Option = {\n title: string;\n value: unknown;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Defines the possible values for size\n */\nexport type Size = 'xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge';\n\n/**\n * Defines the possible values for variant\n */\nexport type Variant = 'info' | 'success' | 'warning' | 'danger' | 'danger-alt' | 'primary' | 'secondary' | 'app' | 'light' | 'dark' | 'flat' | 'text-color' | 'link';\n\n/**\n * Defines the possible values for variantStyle\n */\nexport type VariantStyle = 'icon' | 'background' | 'bar-left' | 'full';\n\n/**\n * Defines the possible values for ariaRole\n */\nexport type AriaRole = 'progressbar' | 'meter' | 'form' | 'search' | 'none' | 'presentation';\n\n/**\n * Defines the possible values for input error\n */\nexport type InputError = 'min' | 'max' | 'minMax' | 'required' | 'badInput';\n\n/**\n * Defines the possible values for status\n */\nexport type Status = 'visible' | 'hidden' | 'disabled' | 'active';\n\n/**\n * Define option type\n */\nexport type Option = {\n title: string;\n value: unknown;\n};\n"]}
|