@mgdis/mg-components 6.4.0 → 6.6.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-a3269bfc.js → index-019dd5c0.js} +3 -3
- package/dist/cjs/{index-a3269bfc.js.map → index-019dd5c0.js.map} +1 -1
- package/dist/cjs/{index-911898e4.js → index-1a5a1081.js} +270 -241
- package/dist/cjs/index-1a5a1081.js.map +1 -0
- package/dist/cjs/{index.es-325100d7.js → index.es-903492c5.js} +43 -44
- package/dist/cjs/index.es-903492c5.js.map +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mg-action-more_36.cjs.entry.js +2418 -1996
- package/dist/cjs/mg-action-more_36.cjs.entry.js.map +1 -1
- package/dist/cjs/mg-alert.cjs.entry.js +8 -8
- package/dist/cjs/mg-components.cjs.js +3 -3
- package/dist/cjs/mg-components.cjs.js.map +1 -1
- package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +16790 -0
- package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js.map +1 -0
- package/dist/cjs/mg-input.conf-5bbcea79.js +23 -0
- package/dist/cjs/mg-input.conf-5bbcea79.js.map +1 -0
- package/dist/cjs/mg-loader.cjs.entry.js +6 -6
- package/dist/cjs/mg-progress.cjs.entry.js +12 -12
- package/dist/collection/assets/icons/index.js +1 -1
- package/dist/collection/assets/icons/index.js.map +1 -1
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +1 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js.map +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +68 -38
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +1 -1
- 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 +1 -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.js +2 -2
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/editor/index.js +110 -0
- package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/editor/index.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js +846 -0
- package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +3 -5
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +1 -1
- package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js +4 -4
- package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js.map +1 -1
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.conf.js +1 -1
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.conf.js.map +1 -1
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +16 -17
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js.map +1 -1
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +19 -9
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js.map +1 -1
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +3 -3
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js.map +1 -1
- package/dist/collection/components/molecules/mg-alert/mg-alert.js +1 -1
- package/dist/collection/components/molecules/mg-details/mg-details.js +6 -1
- package/dist/collection/components/molecules/mg-details/mg-details.js.map +1 -1
- package/dist/collection/components/molecules/mg-form/mg-form.js +2 -2
- package/dist/collection/components/molecules/mg-form/mg-form.js.map +1 -1
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.conf.js +5 -2
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.conf.js.map +1 -1
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +74 -17
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js.map +1 -1
- package/dist/collection/components/molecules/mg-loader/mg-loader.js +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js +2 -2
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +2 -2
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +3 -3
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +2 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js.map +1 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +90 -46
- package/dist/collection/components/molecules/mg-popover/mg-popover.js.map +1 -1
- package/dist/collection/components/molecules/mg-progress/mg-progress.js +1 -1
- 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/collection/utils/behaviors.utils.js +4 -1
- package/dist/collection/utils/behaviors.utils.js.map +1 -1
- package/dist/collection/utils/floating-ui.utils.js +28 -0
- package/dist/collection/utils/floating-ui.utils.js.map +1 -0
- package/dist/components/floating-ui.utils.js +2094 -0
- package/dist/components/floating-ui.utils.js.map +1 -0
- package/dist/components/index.es.js +37 -38
- package/dist/components/index.es.js.map +1 -1
- package/dist/components/index2.js +2 -2
- package/dist/components/mg-action-more.js +8 -8
- package/dist/components/mg-action-more.js.map +1 -1
- package/dist/components/mg-alert.js +6 -6
- package/dist/components/mg-badge2.js +6 -6
- package/dist/components/mg-button2.js +6 -6
- package/dist/components/mg-card2.js +1 -1
- package/dist/components/mg-card2.js.map +1 -1
- package/dist/components/mg-character-left2.js +4 -4
- package/dist/components/mg-details.js +8 -3
- package/dist/components/mg-details.js.map +1 -1
- package/dist/components/mg-form.js +9 -9
- package/dist/components/mg-form.js.map +1 -1
- package/dist/components/mg-icon2.js +7 -7
- package/dist/components/mg-icon2.js.map +1 -1
- package/dist/components/mg-illustrated-message.js +69 -16
- package/dist/components/mg-illustrated-message.js.map +1 -1
- package/dist/components/mg-input-checkbox.js +11 -11
- package/dist/components/mg-input-checkbox.js.map +1 -1
- package/dist/components/mg-input-date.js +13 -13
- package/dist/components/mg-input-date.js.map +1 -1
- package/dist/components/mg-input-numeric.js +14 -14
- package/dist/components/mg-input-numeric.js.map +1 -1
- package/dist/components/mg-input-password.js +4 -4
- package/dist/components/mg-input-password.js.map +1 -1
- package/dist/components/mg-input-radio.js +8 -8
- package/dist/components/mg-input-radio.js.map +1 -1
- package/dist/components/mg-input-rich-text-editor.d.ts +11 -0
- package/dist/components/mg-input-rich-text-editor.js +16866 -0
- package/dist/components/mg-input-rich-text-editor.js.map +1 -0
- package/dist/components/mg-input-select2.js +8 -8
- package/dist/components/mg-input-select2.js.map +1 -1
- package/dist/components/mg-input-text2.js +11 -13
- package/dist/components/mg-input-text2.js.map +1 -1
- package/dist/components/mg-input-textarea.js +8 -8
- package/dist/components/mg-input-textarea.js.map +1 -1
- package/dist/components/mg-input-title2.js +4 -4
- package/dist/components/mg-input-toggle.js +7 -7
- package/dist/components/mg-input2.js +9 -9
- package/dist/components/mg-input2.js.map +1 -1
- package/dist/components/mg-item-more2.js +24 -22
- package/dist/components/mg-item-more2.js.map +1 -1
- package/dist/components/mg-loader.js +4 -4
- package/dist/components/mg-menu-item2.js +30 -20
- package/dist/components/mg-menu-item2.js.map +1 -1
- package/dist/components/mg-message2.js +7 -7
- package/dist/components/mg-message2.js.map +1 -1
- package/dist/components/mg-modal.js +11 -11
- package/dist/components/mg-modal.js.map +1 -1
- package/dist/components/mg-pagination2.js +9 -9
- package/dist/components/mg-panel.js +11 -11
- package/dist/components/mg-panel.js.map +1 -1
- package/dist/components/mg-popover-content2.js +4 -4
- package/dist/components/mg-popover-content2.js.map +1 -1
- package/dist/components/mg-popover2.js +89 -47
- package/dist/components/mg-popover2.js.map +1 -1
- package/dist/components/mg-progress.js +11 -11
- package/dist/components/mg-skip-links.js +3 -3
- package/dist/components/mg-tabs.js +13 -13
- package/dist/components/mg-tag.js +4 -4
- package/dist/components/mg-tooltip-content2.js +1 -1
- package/dist/components/mg-tooltip-content2.js.map +1 -1
- package/dist/components/mg-tooltip2.js +70 -41
- package/dist/components/mg-tooltip2.js.map +1 -1
- package/dist/esm/{index-1f32332a.js → index-5059254f.js} +270 -241
- package/dist/esm/index-5059254f.js.map +1 -0
- package/dist/esm/{index-9bd10f5d.js → index-6b7bdd63.js} +3 -3
- package/dist/esm/{index-9bd10f5d.js.map → index-6b7bdd63.js.map} +1 -1
- package/dist/esm/{index.es-a2587b72.js → index.es-b80b758c.js} +38 -39
- package/dist/esm/index.es-b80b758c.js.map +1 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mg-action-more_36.entry.js +2370 -1948
- package/dist/esm/mg-action-more_36.entry.js.map +1 -1
- package/dist/esm/mg-alert.entry.js +8 -8
- package/dist/esm/mg-components.js +4 -4
- package/dist/esm/mg-components.js.map +1 -1
- package/dist/esm/mg-input-rich-text-editor.entry.js +16786 -0
- package/dist/esm/mg-input-rich-text-editor.entry.js.map +1 -0
- package/dist/esm/mg-input.conf-712c7bb6.js +16 -0
- package/dist/esm/mg-input.conf-712c7bb6.js.map +1 -0
- package/dist/esm/mg-loader.entry.js +6 -6
- package/dist/esm/mg-progress.entry.js +12 -12
- 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-f48d964f.entry.js → p-0ae49cc4.entry.js} +2 -2
- package/dist/mg-components/p-17f0b7eb.entry.js +2 -0
- package/dist/mg-components/p-17f0b7eb.entry.js.map +1 -0
- package/dist/mg-components/p-1c126a81.entry.js +2 -0
- package/dist/mg-components/p-1c126a81.entry.js.map +1 -0
- package/dist/mg-components/p-2884f369.js +2 -0
- package/dist/mg-components/p-2884f369.js.map +1 -0
- package/dist/mg-components/{p-3b052ac0.entry.js → p-361cc090.entry.js} +2 -2
- package/dist/mg-components/p-3c6710be.js +2 -0
- package/dist/mg-components/p-3c6710be.js.map +1 -0
- package/dist/mg-components/{p-dc436f3c.js → p-4049bd40.js} +2 -2
- package/dist/mg-components/{p-0ead5317.entry.js → p-c4f37d1f.entry.js} +2 -2
- package/dist/mg-components/p-e39791fa.js +3 -0
- package/dist/mg-components/p-e39791fa.js.map +1 -0
- package/dist/types/assets/icons/index.d.ts +1 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +6 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +7 -6
- package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/editor/index.d.ts +21 -0
- package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.d.ts +202 -0
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.conf.d.ts +2 -6
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +3 -2
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +14 -7
- package/dist/types/components/molecules/mg-details/mg-details.d.ts +4 -0
- package/dist/types/components/molecules/mg-illustrated-message/mg-illustrated-message.conf.d.ts +10 -3
- package/dist/types/components/molecules/mg-illustrated-message/mg-illustrated-message.d.ts +17 -3
- package/dist/types/components/molecules/mg-popover/mg-popover.conf.d.ts +6 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +13 -8
- package/dist/types/components.d.ts +225 -14
- package/dist/types/types/index.d.ts +4 -0
- package/dist/types/utils/floating-ui.utils.d.ts +19 -0
- package/ide/intellij/web-types.json +374 -17
- package/ide/vscode/css-custom-data.json +4 -0
- package/ide/vscode/html-custom-data.json +289 -4
- package/package.json +25 -24
- package/dist/cjs/index-911898e4.js.map +0 -1
- package/dist/cjs/index.es-325100d7.js.map +0 -1
- package/dist/components/popper.js +0 -1794
- package/dist/components/popper.js.map +0 -1
- package/dist/esm/index-1f32332a.js.map +0 -1
- package/dist/esm/index.es-a2587b72.js.map +0 -1
- package/dist/mg-components/p-35898742.js +0 -3
- package/dist/mg-components/p-35898742.js.map +0 -1
- package/dist/mg-components/p-6810a565.entry.js +0 -2
- package/dist/mg-components/p-6810a565.entry.js.map +0 -1
- package/dist/mg-components/p-b986c107.js +0 -2
- package/dist/mg-components/p-b986c107.js.map +0 -1
- /package/dist/mg-components/{p-f48d964f.entry.js.map → p-0ae49cc4.entry.js.map} +0 -0
- /package/dist/mg-components/{p-3b052ac0.entry.js.map → p-361cc090.entry.js.map} +0 -0
- /package/dist/mg-components/{p-dc436f3c.js.map → p-4049bd40.js.map} +0 -0
- /package/dist/mg-components/{p-0ead5317.entry.js.map → p-c4f37d1f.entry.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
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Q;gCACrC,CAAA,MAAA,IAAI,CAAC,KAAK,0CAAE,KAAK,KAAI,gBAAU,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,EAAC,aAAa,EAAC,OAAO,EAAC,YAAY,GAAY,CACxH,CAChB,CAAA;yBAAA,CACF,CACO,CACN,CACK,CACR,CACF,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Element, Prop, Watch, State, Host } from '@stencil/core';\nimport { createID, toString } from '@mgdis/stencil-helpers';\nimport { Status } from '../menu/mg-menu-item/mg-menu-item.conf';\nimport { Direction } from '../menu/mg-menu/mg-menu.conf';\nimport { initLocales } from '../../../locales';\nimport type { MessageType } from '../../../locales/index.conf';\nimport type { MgActionMoreItemType, MgActionMoreButtonType, MgActionMoreIconType, MgActionMoreDividerType } from './mg-action-more.conf';\n\n/**\n * MgActionMore['items'] type guard\n * @param prop - commponent items prop\n * @returns return true if type is valid\n */\nconst isMgActionMoreItems = (prop: unknown): prop is MgActionMoreItemType[] => {\n const items = prop as MgActionMoreItemType[];\n return (\n typeof items === 'object' &&\n items.every(item => (typeof item === 'object' && typeof item.label === 'string' && typeof item.mouseEventHandler === 'function') || isMgActionMoreDivider(item))\n );\n};\n\n/**\n * MgActionMoreDividerType type guard\n * @param item - component item\n * @returns return true if type is valid\n */\nconst isMgActionMoreDivider = (item: unknown): item is MgActionMoreDividerType => typeof item === 'object' && (item as MgActionMoreDividerType).isDivider;\n\n/**\n * MgActionMore['button'] type guard\n * @param prop - commponent button prop\n * @returns return true if type is valid\n */\nconst isMgActionMoreButton = (prop: unknown): prop is MgActionMoreButtonType => {\n const button = prop as MgActionMoreButtonType;\n return typeof button === 'object' && typeof button.variant === 'string' && typeof button.isIcon === 'boolean';\n};\n\n/**\n * MgActionMore['icon'] type guard\n * @param prop - commponent icon prop\n * @returns return true if type is valid\n */\nconst isMgActionMoreIcon = (prop: unknown): prop is MgActionMoreIconType => {\n const icon = prop as MgActionMoreIconType;\n return typeof icon === 'object' && typeof icon.icon === 'string';\n};\n\n@Component({\n tag: 'mg-action-more',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-action-more.css',\n shadow: true,\n})\nexport class MgActionMore {\n /************\n * Internal *\n ************/\n\n private readonly name = 'mg-action-more';\n private readonly classBase = 'mg-c-action-more';\n private readonly mgPopoverIdentifier = createID(this.name);\n private messages: MessageType;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgActionMoreElement;\n\n /**\n * Define the menu-items elements\n */\n @Prop() items!: (MgActionMoreItemType | MgActionMoreDividerType)[];\n @Watch('items')\n validateItems(newValue: MgActionMore['items']): void {\n if (!isMgActionMoreItems(newValue)) {\n throw new Error(\n `<${this.name}> prop \"items\" is required and all values must be the same type, MgActionMoreItemType or MgActionMoreDividerType. Passed value: ${toString(newValue)}.`,\n );\n } else if (isMgActionMoreItems(newValue) && newValue.length > 0 && (isMgActionMoreDivider(newValue[0]) || isMgActionMoreDivider(newValue[newValue.length - 1]))) {\n throw new Error(`<${this.name}> prop \"items\" can’t have a divider at the beginning or the end of the array. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Define displayed icon\n */\n @Prop({ mutable: true }) icon?: MgActionMoreIconType;\n @Watch('icon')\n validateIcon(newValue: MgActionMore['icon']): void {\n if (newValue && !isMgActionMoreIcon(newValue)) {\n throw new Error(`<${this.name}> prop \"icon\" must match MgActionMoreIconType. Passed value: ${toString(newValue)}.`);\n } else if (newValue?.icon === undefined && Boolean(this.button.isIcon)) {\n this.icon = { icon: 'ellipsis' };\n }\n }\n\n /**\n * Define button properties\n */\n @Prop() button?: MgActionMoreButtonType = { variant: 'flat', isIcon: true };\n @Watch('button')\n validateButton(newValue: MgActionMore['button']): void {\n if (newValue && !isMgActionMoreButton(newValue)) {\n throw new Error(`<${this.name}> prop \"button\" must match MgActionMoreButtonType. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Define if chevron is display\n */\n @Prop() displayChevron?: boolean;\n @Watch('displayChevron')\n validateDisplayChevron(newValue: MgActionMore['displayChevron']): void {\n if (newValue && this.button.isIcon === true) {\n throw new Error(`<${this.name}> prop \"displayChevron\" can't be used with a 'button\" prop \"isIcon\" attribute.`);\n }\n }\n /**\n * Menu expanded state\n */\n @State() expanded = false;\n\n /************\n * Methods *\n ***********/\n\n /**\n * Toggle expanded props\n */\n private toggleExpanded = (): void => {\n this.expanded = !this.expanded;\n };\n\n /**\n * Handle popover display change value\n * @param event - display change updated value\n */\n private handleDisplayChange = (event: CustomEvent): void => {\n this.expanded = event.detail;\n };\n\n /**\n * Button click handler\n */\n private handleButton = (): void => {\n this.toggleExpanded();\n };\n\n /**\n * Item click handler\n * @param event - click event\n * @param customHandler - item['mouseEventHandler']\n */\n private handleItemClick = (event: MouseEvent, customHandler: MgActionMoreItemType['mouseEventHandler']) => {\n this.expanded = false;\n customHandler(event);\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Validate props\n */\n componentWillLoad(): void {\n this.messages = initLocales(this.element).messages.actionMore as MessageType;\n this.validateItems(this.items);\n this.validateButton(this.button);\n this.validateIcon(this.icon);\n this.validateDisplayChevron(this.displayChevron);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n const buttonLabel = this.button.label || this.messages.label;\n const buttonContent = [buttonLabel];\n\n if (!this.button.isIcon && this.displayChevron) {\n buttonContent.push(\n <span\n class={{\n [`${this.classBase}__chevron`]: true,\n [`${this.classBase}__chevron--rotate`]: this.expanded === true,\n }}\n >\n <mg-icon icon=\"chevron-down\"></mg-icon>\n </span>,\n );\n }\n\n return (\n <Host data-mg-popover-guard={this.mgPopoverIdentifier}>\n <span class={this.classBase}>\n <mg-popover identifier={this.mgPopoverIdentifier} display={this.expanded} onDisplay-change={this.handleDisplayChange}>\n <mg-button variant={this.button.variant} isIcon={this.button.isIcon} disabled={this.button.disabled} type=\"button\" label={buttonLabel} onClick={this.handleButton}>\n {this.icon && <mg-icon {...this.icon}></mg-icon>}\n {!this.button.isIcon && buttonContent}\n </mg-button>\n <div slot=\"content\">\n <mg-menu direction={Direction.VERTICAL} label={this.messages.label}>\n {this.items.map(item =>\n isMgActionMoreDivider(item) ? (\n <mg-divider class=\"mg-c-action-more__divider\" key=\"divider\"></mg-divider>\n ) : (\n <mg-menu-item\n key={item.label}\n status={item.status || Status.VISIBLE}\n target={item.target}\n href={item.href}\n // eslint-disable-next-line react/jsx-no-bind\n onClick={e => this.handleItemClick(e, item.mouseEventHandler)}\n >\n {item.icon?.icon && <mg-icon icon={item.icon.icon} variant={item.icon.variant} variantStyle={item.icon.variantStyle} slot=\"image\"></mg-icon>}\n <span slot=\"label\">{item.label}</span>\n {item.badge?.label && <mg-badge label={item.badge.label} value={item.badge.value} slot=\"information\" variant=\"text-color\"></mg-badge>}\n </mg-menu-item>\n ),\n )}\n </mg-menu>\n </div>\n </mg-popover>\n </span>\n </Host>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mg-action-more.js","sourceRoot":"","sources":["../../../../src/components/molecules/mg-action-more/mg-action-more.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,wCAAwC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB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;;;;;;;;;CACF","sourcesContent":["import { Component, h, Element, Prop, Watch, State, Host } from '@stencil/core';\nimport { createID, toString } from '@mgdis/stencil-helpers';\nimport { Status } from '../menu/mg-menu-item/mg-menu-item.conf';\nimport { directions } from '../menu/mg-menu/mg-menu.conf';\nimport { initLocales } from '../../../locales';\nimport type { MessageType } from '../../../locales/index.conf';\nimport type { MgActionMoreItemType, MgActionMoreButtonType, MgActionMoreIconType, MgActionMoreDividerType } from './mg-action-more.conf';\n\n/**\n * MgActionMore['items'] type guard\n * @param prop - commponent items prop\n * @returns return true if type is valid\n */\nconst isMgActionMoreItems = (prop: unknown): prop is MgActionMoreItemType[] => {\n const items = prop as MgActionMoreItemType[];\n return (\n typeof items === 'object' &&\n items.every(item => (typeof item === 'object' && typeof item.label === 'string' && typeof item.mouseEventHandler === 'function') || isMgActionMoreDivider(item))\n );\n};\n\n/**\n * MgActionMoreDividerType type guard\n * @param item - component item\n * @returns return true if type is valid\n */\nconst isMgActionMoreDivider = (item: unknown): item is MgActionMoreDividerType => typeof item === 'object' && (item as MgActionMoreDividerType).isDivider;\n\n/**\n * MgActionMore['button'] type guard\n * @param prop - commponent button prop\n * @returns return true if type is valid\n */\nconst isMgActionMoreButton = (prop: unknown): prop is MgActionMoreButtonType => {\n const button = prop as MgActionMoreButtonType;\n return typeof button === 'object' && typeof button.variant === 'string' && typeof button.isIcon === 'boolean';\n};\n\n/**\n * MgActionMore['icon'] type guard\n * @param prop - commponent icon prop\n * @returns return true if type is valid\n */\nconst isMgActionMoreIcon = (prop: unknown): prop is MgActionMoreIconType => {\n const icon = prop as MgActionMoreIconType;\n return typeof icon === 'object' && typeof icon.icon === 'string';\n};\n\n@Component({\n tag: 'mg-action-more',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-action-more.css',\n shadow: true,\n})\nexport class MgActionMore {\n /************\n * Internal *\n ************/\n\n private readonly name = 'mg-action-more';\n private readonly classBase = 'mg-c-action-more';\n private readonly mgPopoverIdentifier = createID(this.name);\n private messages: MessageType;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgActionMoreElement;\n\n /**\n * Define the menu-items elements\n */\n @Prop() items!: (MgActionMoreItemType | MgActionMoreDividerType)[];\n @Watch('items')\n validateItems(newValue: MgActionMore['items']): void {\n if (!isMgActionMoreItems(newValue)) {\n throw new Error(\n `<${this.name}> prop \"items\" is required and all values must be the same type, MgActionMoreItemType or MgActionMoreDividerType. Passed value: ${toString(newValue)}.`,\n );\n } else if (isMgActionMoreItems(newValue) && newValue.length > 0 && (isMgActionMoreDivider(newValue[0]) || isMgActionMoreDivider(newValue[newValue.length - 1]))) {\n throw new Error(`<${this.name}> prop \"items\" can’t have a divider at the beginning or the end of the array. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Define displayed icon\n */\n @Prop({ mutable: true }) icon?: MgActionMoreIconType;\n @Watch('icon')\n validateIcon(newValue: MgActionMore['icon']): void {\n if (newValue && !isMgActionMoreIcon(newValue)) {\n throw new Error(`<${this.name}> prop \"icon\" must match MgActionMoreIconType. Passed value: ${toString(newValue)}.`);\n } else if (newValue?.icon === undefined && Boolean(this.button.isIcon)) {\n this.icon = { icon: 'ellipsis' };\n }\n }\n\n /**\n * Define button properties\n */\n @Prop() button?: MgActionMoreButtonType = { variant: 'flat', isIcon: true };\n @Watch('button')\n validateButton(newValue: MgActionMore['button']): void {\n if (newValue && !isMgActionMoreButton(newValue)) {\n throw new Error(`<${this.name}> prop \"button\" must match MgActionMoreButtonType. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Define if chevron is display\n */\n @Prop() displayChevron?: boolean;\n @Watch('displayChevron')\n validateDisplayChevron(newValue: MgActionMore['displayChevron']): void {\n if (newValue && this.button.isIcon === true) {\n throw new Error(`<${this.name}> prop \"displayChevron\" can't be used with a 'button\" prop \"isIcon\" attribute.`);\n }\n }\n /**\n * Menu expanded state\n */\n @State() expanded = false;\n\n /************\n * Methods *\n ***********/\n\n /**\n * Toggle expanded props\n */\n private toggleExpanded = (): void => {\n this.expanded = !this.expanded;\n };\n\n /**\n * Handle popover display change value\n * @param event - display change updated value\n */\n private handleDisplayChange = (event: CustomEvent): void => {\n this.expanded = event.detail;\n };\n\n /**\n * Button click handler\n */\n private handleButton = (): void => {\n this.toggleExpanded();\n };\n\n /**\n * Item click handler\n * @param event - click event\n * @param customHandler - item['mouseEventHandler']\n */\n private handleItemClick = (event: MouseEvent, customHandler: MgActionMoreItemType['mouseEventHandler']) => {\n this.expanded = false;\n customHandler(event);\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Validate props\n */\n componentWillLoad(): void {\n this.messages = initLocales(this.element).messages.actionMore as MessageType;\n this.validateItems(this.items);\n this.validateButton(this.button);\n this.validateIcon(this.icon);\n this.validateDisplayChevron(this.displayChevron);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n const buttonLabel = this.button.label || this.messages.label;\n const buttonContent = [buttonLabel];\n\n if (!this.button.isIcon && this.displayChevron) {\n buttonContent.push(\n <span\n class={{\n [`${this.classBase}__chevron`]: true,\n [`${this.classBase}__chevron--rotate`]: this.expanded === true,\n }}\n >\n <mg-icon icon=\"chevron-down\"></mg-icon>\n </span>,\n );\n }\n\n return (\n <Host data-mg-popover-guard={this.mgPopoverIdentifier}>\n <span class={this.classBase}>\n <mg-popover identifier={this.mgPopoverIdentifier} display={this.expanded} onDisplay-change={this.handleDisplayChange}>\n <mg-button variant={this.button.variant} isIcon={this.button.isIcon} disabled={this.button.disabled} type=\"button\" label={buttonLabel} onClick={this.handleButton}>\n {this.icon && <mg-icon {...this.icon}></mg-icon>}\n {!this.button.isIcon && buttonContent}\n </mg-button>\n <div slot=\"content\">\n <mg-menu direction={directions.VERTICAL} label={this.messages.label}>\n {this.items.map(item =>\n isMgActionMoreDivider(item) ? (\n <mg-divider class=\"mg-c-action-more__divider\" key=\"divider\"></mg-divider>\n ) : (\n <mg-menu-item\n key={item.label}\n status={item.status || Status.VISIBLE}\n target={item.target}\n href={item.href}\n // eslint-disable-next-line react/jsx-no-bind\n onClick={e => this.handleItemClick(e, item.mouseEventHandler)}\n >\n {item.icon?.icon && <mg-icon icon={item.icon.icon} variant={item.icon.variant} variantStyle={item.icon.variantStyle} slot=\"image\"></mg-icon>}\n <span slot=\"label\">{item.label}</span>\n {item.badge?.label && <mg-badge label={item.badge.label} value={item.badge.value} slot=\"information\" variant=\"text-color\"></mg-badge>}\n </mg-menu-item>\n ),\n )}\n </mg-menu>\n </div>\n </mg-popover>\n </span>\n </Host>\n );\n }\n}\n"]}
|
|
@@ -134,7 +134,7 @@ export class MgAlert {
|
|
|
134
134
|
* @returns HTML Element
|
|
135
135
|
*/
|
|
136
136
|
render() {
|
|
137
|
-
return (h("mg-message", { key: '
|
|
137
|
+
return (h("mg-message", { key: '3978c0f16d1577cf9e488f75d710e6580e0064f5', class: this.classCollection.join(), role: ['info', 'success'].includes(this.variant) ? 'status' : 'alert', variant: this.variant, variantStyle: this.variantStyle }, h("slot", { key: '5e7dc7c38d5c2b6bbb65b8dd26d0eb3f499b5a2f' }), this.hasActions ? (h("span", { slot: "actions" }, h("slot", { name: "actions" }))) : (h("span", { class: "mg-c-alert__close-button" }, h("mg-button", { "is-icon": true, variant: "flat", label: this.messages.alert.closeButton, onClick: this.handleClose }, h("mg-icon", { icon: "cross" }))))));
|
|
138
138
|
}
|
|
139
139
|
static get is() { return "mg-alert"; }
|
|
140
140
|
static get encapsulation() { return "shadow"; }
|
|
@@ -38,13 +38,17 @@ export class MgDetails {
|
|
|
38
38
|
componentWillLoad() {
|
|
39
39
|
this.validateTitles(this.toggleClosed);
|
|
40
40
|
this.validateTitles(this.toggleOpened);
|
|
41
|
+
this.element.addEventListener('click', (event) => {
|
|
42
|
+
if (event.target.closest('[slot="summary"] mg-button, mg-button[slot="summary"]'))
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
});
|
|
41
45
|
}
|
|
42
46
|
/**
|
|
43
47
|
* Render
|
|
44
48
|
* @returns HTML Element
|
|
45
49
|
*/
|
|
46
50
|
render() {
|
|
47
|
-
return (h("details", { key: '
|
|
51
|
+
return (h("details", { key: '941fc56c10cd54a7975dc9b8adf5b7e24dfe89ce', class: "mg-c-details", onToggle: this.handleToggle, open: this.expanded, ref: (el) => (this.details = el) }, h("summary", { key: '8e0a1107069245a5920d28dced132ab73b25dcf1' }, h("slot", { key: '9530891ab1e8e60a1725aa146146bbd846bb7869', name: "summary" }), h("span", { key: '60163fa52f9c96bc15d60a016a2f17c3327f2b2f', class: "mg-c-details__toggle" }, h("mg-icon", { key: '69c033059e73b5ab336dfe5aeac122b78c65adbf', icon: "chevron-up", class: { 'mg-c-details__toggle-icon': true, 'mg-c-details__toggle-icon--reverse': !this.expanded } }), h("span", { key: '341d8915d9327cf811c21e4021446ff77b471029', class: { 'mg-u-visually-hidden': this.hideSummary } }, this.expanded ? this.toggleOpened : this.toggleClosed))), h("div", { key: '6681fe531a0076a8c016b55c6223492ac5613da4', class: "mg-c-details__details" }, h("slot", { key: 'a09d6f88af12ee0756c9f86d0adcbf01903461c5', name: "details" }))));
|
|
48
52
|
}
|
|
49
53
|
static get is() { return "mg-details"; }
|
|
50
54
|
static get encapsulation() { return "shadow"; }
|
|
@@ -163,6 +167,7 @@ export class MgDetails {
|
|
|
163
167
|
}
|
|
164
168
|
}];
|
|
165
169
|
}
|
|
170
|
+
static get elementRef() { return "element"; }
|
|
166
171
|
static get watchers() {
|
|
167
172
|
return [{
|
|
168
173
|
"propName": "toggleClosed",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mg-details.js","sourceRoot":"","sources":["../../../../src/components/molecules/mg-details/mg-details.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"mg-details.js","sourceRoot":"","sources":["../../../../src/components/molecules/mg-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AAI,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAsB,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;YAClI;gBACE,6DAAM,IAAI,EAAC,SAAS,GAAQ;gBAC5B,6DAAM,KAAK,EAAC,sBAAsB;oBAChC,gEAAS,IAAI,EAAC,YAAY,EAAC,KAAK,EAAE,EAAE,2BAA2B,EAAE,IAAI,EAAE,oCAAoC,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAY;oBACzI,6DAAM,KAAK,EAAE,EAAE,sBAAsB,EAAE,IAAI,CAAC,WAAW,EAAE,IAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAQ,CACpH,CACC;YACV,4DAAK,KAAK,EAAC,uBAAuB;gBAChC,6DAAM,IAAI,EAAC,SAAS,GAAQ,CACxB,CACE,CACX,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Event, EventEmitter, h, Prop, Watch, Element } from '@stencil/core';\nimport { isValidString } from '@mgdis/stencil-helpers';\n\n/**\n * @slot summary - Summary content\n * @slot details - Details content\n */\n@Component({\n tag: 'mg-details',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-details.css',\n shadow: true,\n})\nexport class MgDetails {\n /************\n * Internal *\n ************/\n\n // HTML selector\n private details: HTMLDetailsElement;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgDetailsElement;\n\n /**\n * Displayed title when details are closed\n */\n @Prop() toggleClosed!: string;\n\n /**\n * Displayed title when details are opened\n */\n @Prop() toggleOpened!: string;\n @Watch('toggleClosed')\n @Watch('toggleOpened')\n validateTitles(newValue: string): void {\n if (!isValidString(newValue)) {\n throw new Error(\n `<mg-details> prop \"toggleClosed\" and \"toggleOpened\" is required and must be a valid string. Passed value: \"toggleClosed='${this.toggleClosed}'\" and \"toggleOpened='${this.toggleOpened}'\".`,\n );\n }\n }\n\n /**\n * Hide summary element\n */\n @Prop() hideSummary = false;\n\n /**\n * Define if details are diplayed\n */\n @Prop({ mutable: true }) expanded = false;\n @Watch('expanded')\n handleExpanded(newValue: boolean): void {\n this.expandedChange.emit(newValue);\n }\n\n /**\n * Emmited event when expanded change\n */\n @Event({ eventName: 'expanded-change' }) expandedChange: EventEmitter<HTMLMgDetailsElement['expanded']>;\n\n /**\n * Handle details toggle\n */\n private handleToggle = (): void => {\n this.expanded = this.details.open;\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n */\n componentWillLoad(): void {\n this.validateTitles(this.toggleClosed);\n this.validateTitles(this.toggleOpened);\n this.element.addEventListener('click', (event: MouseEvent & { target: HTMLElement }) => {\n if (event.target.closest('[slot=\"summary\"] mg-button, mg-button[slot=\"summary\"]')) event.preventDefault();\n });\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <details class=\"mg-c-details\" onToggle={this.handleToggle} open={this.expanded} ref={(el: HTMLDetailsElement) => (this.details = el)}>\n <summary>\n <slot name=\"summary\"></slot>\n <span class=\"mg-c-details__toggle\">\n <mg-icon icon=\"chevron-up\" class={{ 'mg-c-details__toggle-icon': true, 'mg-c-details__toggle-icon--reverse': !this.expanded }}></mg-icon>\n <span class={{ 'mg-u-visually-hidden': this.hideSummary }}>{this.expanded ? this.toggleOpened : this.toggleClosed}</span>\n </span>\n </summary>\n <div class=\"mg-c-details__details\">\n <slot name=\"details\"></slot>\n </div>\n </details>\n );\n }\n}\n"]}
|
|
@@ -208,7 +208,7 @@ export class MgForm {
|
|
|
208
208
|
componentDidLoad() {
|
|
209
209
|
// Update mgInputs when mgForm content change
|
|
210
210
|
const observerOptions = { childList: true, subtree: true };
|
|
211
|
-
new MutationObserver(
|
|
211
|
+
new MutationObserver(mutations => {
|
|
212
212
|
if (mutations.some(mutation => Object.keys(observerOptions).includes(mutation.type))) {
|
|
213
213
|
this.setMgInputs();
|
|
214
214
|
this.checkValidity();
|
|
@@ -220,7 +220,7 @@ export class MgForm {
|
|
|
220
220
|
* @returns HTML Element
|
|
221
221
|
*/
|
|
222
222
|
render() {
|
|
223
|
-
return (h("form", { key: '
|
|
223
|
+
return (h("form", { key: 'a592ab555ddc0a5132fdf99b3de102d95ef8cc30', class: this.classCollection.join(), id: this.identifier, name: this.name, onSubmit: this.handleFormSubmit, role: this.ariaRole }, this.requiredMessageText && h("p", { key: 'c7a0b19f51394d16bb80de4e0995e22213a6dc17', innerHTML: this.requiredMessageText }), h("slot", { key: 'd6b6c2f15b3a0f1ca93c46506b892bf4bab8f095' }), !this.readonly && !this.disabled && h("slot", { key: 'b758ae4e77d9534b44673494b536134526596651', name: "actions" })));
|
|
224
224
|
}
|
|
225
225
|
static get is() { return "mg-form"; }
|
|
226
226
|
static get encapsulation() { return "shadow"; }
|
|
@@ -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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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 * 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 const observerOptions = { childList: true, subtree: true }\n new MutationObserver((mutations) => {\n if(mutations.some(mutation => Object.keys(observerOptions).includes(mutation.type))) {\n this.setMgInputs();\n this.checkValidity();\n }\n }).observe(this.element, observerOptions);\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;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;A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,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 * 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 const observerOptions = { childList: true, subtree: true };\n new MutationObserver(mutations => {\n if (mutations.some(mutation => Object.keys(observerOptions).includes(mutation.type))) {\n this.setMgInputs();\n this.checkValidity();\n }\n }).observe(this.element, observerOptions);\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"]}
|
package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.conf.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* List of all possibles sizes
|
|
3
3
|
*/
|
|
4
|
-
const sizes = ['medium', '
|
|
5
|
-
|
|
4
|
+
export const sizes = ['small', 'medium', 'large'];
|
|
5
|
+
/**
|
|
6
|
+
* List of all possibles directions
|
|
7
|
+
*/
|
|
8
|
+
export const directions = ['vertical', 'horizontal'];
|
|
6
9
|
//# sourceMappingURL=mg-illustrated-message.conf.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mg-illustrated-message.conf.js","sourceRoot":"","sources":["../../../../src/components/molecules/mg-illustrated-message/mg-illustrated-message.conf.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,KAAK,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAU,CAAC","sourcesContent":["import type { Size } from '../../../types';\n\n/**\n * List of all possibles sizes\n */\
|
|
1
|
+
{"version":3,"file":"mg-illustrated-message.conf.js","sourceRoot":"","sources":["../../../../src/components/molecules/mg-illustrated-message/mg-illustrated-message.conf.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAU,CAAC;AAM3D;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,UAAU,EAAE,YAAY,CAAU,CAAC","sourcesContent":["import type { Size, Direction } from '../../../types';\n\n/**\n * List of all possibles sizes\n */\nexport const sizes = ['small', 'medium', 'large'] as const;\n/**\n * IllustratedMessage size type\n */\nexport type IllustratedMessageSizeType = Size & (typeof sizes)[number];\n\n/**\n * List of all possibles directions\n */\nexport const directions = ['vertical', 'horizontal'] as const;\n/**\n * IllustratedMessage direction type\n */\nexport type IllustratedMessageDirectionType = Direction & (typeof directions)[number];\n"]}
|
package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { h } from "@stencil/core";
|
|
2
|
-
import { isTagName } from "@mgdis/stencil-helpers";
|
|
2
|
+
import { ClassList, isTagName, toString } from "@mgdis/stencil-helpers";
|
|
3
|
+
import { directions, sizes } from "./mg-illustrated-message.conf";
|
|
3
4
|
/**
|
|
4
5
|
* @slot illustration - Illustration content
|
|
5
6
|
* @slot title - Title content
|
|
@@ -15,17 +16,48 @@ export class MgIllustratedMessage {
|
|
|
15
16
|
* Define component orientation
|
|
16
17
|
*/
|
|
17
18
|
this.direction = 'vertical';
|
|
19
|
+
/**
|
|
20
|
+
* Component classes
|
|
21
|
+
*/
|
|
22
|
+
this.classCollection = new ClassList(['mg-c-illustrated-message']);
|
|
18
23
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
watchSize(newValue, oldValue) {
|
|
25
|
+
if (!sizes.includes(newValue)) {
|
|
26
|
+
throw new Error(`<mg-illustrated-message> prop "size" must be one of: ${sizes.join(', ')}. Passed value: ${toString(newValue)}.`);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
if (oldValue !== undefined) {
|
|
30
|
+
this.classCollection.delete(`mg-c-illustrated-message--size-${oldValue}`);
|
|
31
|
+
}
|
|
32
|
+
this.classCollection.add(`mg-c-illustrated-message--size-${newValue}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
watchDirection(newValue, oldValue) {
|
|
36
|
+
if (newValue !== undefined && !directions.includes(newValue)) {
|
|
37
|
+
throw new Error(`<mg-illustrated-message> prop "direction" must be one of: ${directions.join(', ')}. Passed value: ${toString(newValue)}.`);
|
|
38
|
+
}
|
|
39
|
+
else if (newValue === 'horizontal') {
|
|
40
|
+
this.classCollection.add('mg-c-illustrated-message--direction-horizontal');
|
|
41
|
+
}
|
|
42
|
+
else if (oldValue === 'horizontal') {
|
|
43
|
+
this.classCollection.delete('mg-c-illustrated-message--direction-horizontal');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/***********
|
|
47
|
+
* Methods *
|
|
48
|
+
***********/
|
|
22
49
|
/**
|
|
23
|
-
*
|
|
50
|
+
* Validate slots
|
|
24
51
|
*/
|
|
25
|
-
|
|
52
|
+
validateSlots() {
|
|
26
53
|
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
54
|
+
const slottedTitle = this.element.querySelector('[slot="title"]');
|
|
27
55
|
const slottedIllustrations = this.element.querySelectorAll('[slot="illustration"]');
|
|
28
|
-
|
|
56
|
+
const slottedDetails = this.element.querySelectorAll('[slot="details"]');
|
|
57
|
+
if (slottedDetails.length === 0 && slottedTitle === null) {
|
|
58
|
+
throw new Error('<mg-illustrated-message> Slot "title" or "details" must be present.');
|
|
59
|
+
}
|
|
60
|
+
else if (slottedTitle !== null && !isTagName(slottedTitle, headingTags)) {
|
|
29
61
|
throw new Error(`<mg-illustrated-message> Slotted title must be a heading: ${headingTags.join(', ')}.`);
|
|
30
62
|
}
|
|
31
63
|
else if (slottedIllustrations.length !== 1) {
|
|
@@ -33,18 +65,23 @@ export class MgIllustratedMessage {
|
|
|
33
65
|
}
|
|
34
66
|
slottedIllustrations[0].setAttribute('aria-hidden', 'true');
|
|
35
67
|
}
|
|
68
|
+
/*************
|
|
69
|
+
* Lifecycle *
|
|
70
|
+
*************/
|
|
71
|
+
/**
|
|
72
|
+
* Check if component props are well configured on init
|
|
73
|
+
*/
|
|
74
|
+
componentWillLoad() {
|
|
75
|
+
this.watchDirection(this.direction);
|
|
76
|
+
this.watchSize(this.size);
|
|
77
|
+
this.validateSlots();
|
|
78
|
+
}
|
|
36
79
|
/**
|
|
37
80
|
* Render
|
|
38
81
|
* @returns HTML Element
|
|
39
82
|
*/
|
|
40
83
|
render() {
|
|
41
|
-
return (h("div", { key: '
|
|
42
|
-
'mg-c-illustrated-message': true,
|
|
43
|
-
'mg-c-illustrated-message--horizontal': this.direction === 'horizontal',
|
|
44
|
-
} }, h("div", { key: '05d260716090d503dde8e0dddc79db0a5f553f0b', class: {
|
|
45
|
-
'mg-c-illustrated-message__illustration': true,
|
|
46
|
-
'mg-c-illustrated-message__illustration--small': this.size === 'small',
|
|
47
|
-
} }, h("slot", { key: '119f517d66d9d4fe1bbc84341fccab9db1070c06', name: "illustration" })), h("div", { key: 'cc00f05411b3d8103e566d01d48a6ab66438027c', class: "mg-c-illustrated-message__slots" }, h("div", { key: '1832b69ce391c8c018bfc3acad75ded56dc0d484', class: "mg-c-illustrated-message__title" }, h("slot", { key: 'd0dfb8c433246571c140797f99f434cb64c67e7e', name: "title" })), h("div", { key: '75b18511e74d1d4d049e698c3fb43ad4f00450c3', class: "mg-c-illustrated-message__details" }, h("slot", { key: '78e11fa31da149666973e03fe707e302d60f8989', name: "details" })))));
|
|
84
|
+
return (h("div", { key: '2149de3930476c30fa95c8b117076751fff95029', class: this.classCollection.join() }, h("div", { key: '2795cb4895296c33b0aaf2ff8b2dcda464ce7f60', class: "mg-c-illustrated-message__illustration" }, h("slot", { key: 'fd9f3c1fbcd10bf220d6dd527bf5a8485c505078', name: "illustration" })), h("div", { key: '1acf58c99a54bc100b98ca4bf37ef4fd32242a5f', class: "mg-c-illustrated-message__slots" }, h("slot", { key: 'a1945bb8898198066958f06082e27c6fe3c26153', name: "title" }), h("slot", { key: '97b69594078389495397985e8ccb1e5e0dd4bc3f', name: "details" }))));
|
|
48
85
|
}
|
|
49
86
|
static get is() { return "mg-illustrated-message"; }
|
|
50
87
|
static get encapsulation() { return "shadow"; }
|
|
@@ -65,7 +102,7 @@ export class MgIllustratedMessage {
|
|
|
65
102
|
"mutable": false,
|
|
66
103
|
"complexType": {
|
|
67
104
|
"original": "IllustratedMessageSizeType",
|
|
68
|
-
"resolved": "\"medium\" | \"small\"",
|
|
105
|
+
"resolved": "\"large\" | \"medium\" | \"small\"",
|
|
69
106
|
"references": {
|
|
70
107
|
"IllustratedMessageSizeType": {
|
|
71
108
|
"location": "import",
|
|
@@ -90,9 +127,15 @@ export class MgIllustratedMessage {
|
|
|
90
127
|
"type": "string",
|
|
91
128
|
"mutable": false,
|
|
92
129
|
"complexType": {
|
|
93
|
-
"original": "
|
|
130
|
+
"original": "IllustratedMessageDirectionType",
|
|
94
131
|
"resolved": "\"horizontal\" | \"vertical\"",
|
|
95
|
-
"references": {
|
|
132
|
+
"references": {
|
|
133
|
+
"IllustratedMessageDirectionType": {
|
|
134
|
+
"location": "import",
|
|
135
|
+
"path": "./mg-illustrated-message.conf",
|
|
136
|
+
"id": "src/components/molecules/mg-illustrated-message/mg-illustrated-message.conf.ts::IllustratedMessageDirectionType"
|
|
137
|
+
}
|
|
138
|
+
}
|
|
96
139
|
},
|
|
97
140
|
"required": false,
|
|
98
141
|
"optional": false,
|
|
@@ -108,6 +151,20 @@ export class MgIllustratedMessage {
|
|
|
108
151
|
}
|
|
109
152
|
};
|
|
110
153
|
}
|
|
154
|
+
static get states() {
|
|
155
|
+
return {
|
|
156
|
+
"classCollection": {}
|
|
157
|
+
};
|
|
158
|
+
}
|
|
111
159
|
static get elementRef() { return "element"; }
|
|
160
|
+
static get watchers() {
|
|
161
|
+
return [{
|
|
162
|
+
"propName": "size",
|
|
163
|
+
"methodName": "watchSize"
|
|
164
|
+
}, {
|
|
165
|
+
"propName": "direction",
|
|
166
|
+
"methodName": "watchDirection"
|
|
167
|
+
}];
|
|
168
|
+
}
|
|
112
169
|
}
|
|
113
170
|
//# sourceMappingURL=mg-illustrated-message.js.map
|
package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mg-illustrated-message.js","sourceRoot":"","sources":["../../../../src/components/molecules/mg-illustrated-message/mg-illustrated-message.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"mg-illustrated-message.js","sourceRoot":"","sources":["../../../../src/components/molecules/mg-illustrated-message/mg-illustrated-message.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,UAA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;QACJ,OAAO,CACL,4DAAK,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE;YACrC,4DAAK,KAAK,EAAC,wCAAwC;gBACjD,6DAAM,IAAI,EAAC,cAAc,GAAQ,CAC7B;YACN,4DAAK,KAAK,EAAC,iCAAiC;gBAC1C,6DAAM,IAAI,EAAC,OAAO,GAAQ;gBAC1B,6DAAM,IAAI,EAAC,SAAS,GAAQ,CACxB,CACF,CACP,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, h, Prop, State, Watch } from '@stencil/core';\nimport { ClassList, isTagName, toString } from '@mgdis/stencil-helpers';\nimport { directions, type IllustratedMessageDirectionType, type IllustratedMessageSizeType, sizes } from './mg-illustrated-message.conf';\n\n/**\n * @slot illustration - Illustration content\n * @slot title - Title content\n * @slot details - Details content\n */\n@Component({\n tag: 'mg-illustrated-message',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-illustrated-message.css',\n shadow: true,\n})\nexport class MgIllustratedMessage {\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgIllustratedMessageElement;\n\n /**\n * Define illustration size\n */\n @Prop() size: IllustratedMessageSizeType = 'medium';\n @Watch('size')\n watchSize(newValue: IllustratedMessageSizeType, oldValue?: IllustratedMessageSizeType): void {\n if (!sizes.includes(newValue)) {\n throw new Error(`<mg-illustrated-message> prop \"size\" must be one of: ${sizes.join(', ')}. Passed value: ${toString(newValue)}.`);\n } else {\n if (oldValue !== undefined) {\n this.classCollection.delete(`mg-c-illustrated-message--size-${oldValue}`);\n }\n this.classCollection.add(`mg-c-illustrated-message--size-${newValue}`);\n }\n }\n\n /**\n * Define component orientation\n */\n @Prop() direction: IllustratedMessageDirectionType = 'vertical';\n @Watch('direction')\n watchDirection(newValue: IllustratedMessageDirectionType, oldValue?: IllustratedMessageDirectionType): void {\n if (newValue !== undefined && !directions.includes(newValue)) {\n throw new Error(`<mg-illustrated-message> prop \"direction\" must be one of: ${directions.join(', ')}. Passed value: ${toString(newValue)}.`);\n } else if (newValue === 'horizontal') {\n this.classCollection.add('mg-c-illustrated-message--direction-horizontal');\n } else if (oldValue === 'horizontal') {\n this.classCollection.delete('mg-c-illustrated-message--direction-horizontal');\n }\n }\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-illustrated-message']);\n\n /***********\n * Methods *\n ***********/\n\n /**\n * Validate slots\n */\n private validateSlots(): void {\n const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];\n const slottedTitle = this.element.querySelector('[slot=\"title\"]');\n const slottedIllustrations = this.element.querySelectorAll('[slot=\"illustration\"]');\n const slottedDetails = this.element.querySelectorAll('[slot=\"details\"]');\n\n if (slottedDetails.length === 0 && slottedTitle === null) {\n throw new Error('<mg-illustrated-message> Slot \"title\" or \"details\" must be present.');\n } else if (slottedTitle !== null && !isTagName(slottedTitle, headingTags)) {\n throw new Error(`<mg-illustrated-message> Slotted title must be a heading: ${headingTags.join(', ')}.`);\n } else if (slottedIllustrations.length !== 1) {\n throw new Error('<mg-illustrated-message> Slotted illustration must be present and unique.');\n }\n\n slottedIllustrations[0].setAttribute('aria-hidden', 'true');\n }\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n */\n componentWillLoad(): void {\n this.watchDirection(this.direction);\n this.watchSize(this.size);\n this.validateSlots();\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <div class={this.classCollection.join()}>\n <div class=\"mg-c-illustrated-message__illustration\">\n <slot name=\"illustration\"></slot>\n </div>\n <div class=\"mg-c-illustrated-message__slots\">\n <slot name=\"title\"></slot>\n <slot name=\"details\"></slot>\n </div>\n </div>\n );\n }\n}\n"]}
|
|
@@ -23,7 +23,7 @@ export class MgLoader {
|
|
|
23
23
|
* @returns HTML Element
|
|
24
24
|
*/
|
|
25
25
|
render() {
|
|
26
|
-
return (h("div", { key: '
|
|
26
|
+
return (h("div", { key: 'b9442e1060b119499a8f35444be6b371d340dffc', class: "mg-c-loader", "aria-live": "polite" }, h("mg-icon", { key: '9ef418d26dd97c570147c99948509368a8abe84b', icon: "loader", spin: true }), h("span", { key: '4cff50728afc076ffa202fa1b3973573d2a073e8', class: { 'mg-u-visually-hidden': this.messageHide } }, this.message || this.messages.loader.inProgess)));
|
|
27
27
|
}
|
|
28
28
|
static get is() { return "mg-loader"; }
|
|
29
29
|
static get encapsulation() { return "shadow"; }
|
|
@@ -86,9 +86,9 @@ export class MgMessage {
|
|
|
86
86
|
* @returns HTML Element
|
|
87
87
|
*/
|
|
88
88
|
render() {
|
|
89
|
-
return (h("div", { key: '
|
|
89
|
+
return (h("div", { key: 'd0a2c215951c0ef62588b5c1d13879a1ff9f8d1f', class: this.classCollection.join() }, h("mg-card", { key: '171d1c0452561a4a2729aea0a32d47e6831b1f50' }, this.variantStyle === 'bar-left' && h("span", { key: '482d2e6c2f51aafa1b434b24aab0fe9c3cb8141e', class: "mg-c-message__bar" }), h("span", { key: 'd6ec954a4eb499458bbdd0c7ba5fb5686c3afc0b', class: "mg-c-message__icon" }, h("mg-icon", { key: '32daba88c0c32cea0012ee6e80b97445aed3533c', icon: this.getIcon() })), h("div", { key: 'fc77d6745f2ae8d0c8de393598dad8d4c3b7f074', class: "mg-c-message__content" }, h("span", { key: 'e73d7327e259c457c66b2faf2ff26b3ca07bf24d', class: "mg-c-message__content-slot" }, h("slot", { key: 'c15d52b9cf7b4f974f0d92c7eceaeecba7708f37' })), this.hasActions && [
|
|
90
90
|
h("span", { class: "mg-c-message__content-separator", key: "content-separator" }),
|
|
91
|
-
h("span", { class: "mg-c-message__content-actions-slot", key: "content-actions-slot" }, h("slot", { key: '
|
|
91
|
+
h("span", { class: "mg-c-message__content-actions-slot", key: "content-actions-slot" }, h("slot", { key: '0ebf36c9be1bed739bede04f4cf8352f0580f53f', name: "actions" })),
|
|
92
92
|
]))));
|
|
93
93
|
}
|
|
94
94
|
static get is() { return "mg-message"; }
|
|
@@ -106,11 +106,11 @@ export class MgModal {
|
|
|
106
106
|
* @returns HTML Element
|
|
107
107
|
*/
|
|
108
108
|
render() {
|
|
109
|
-
return (h("dialog", { key: '
|
|
109
|
+
return (h("dialog", { key: 'd9bc9c48122e4a607122ad62afb1229061860e70', role: this.dialogRole, id: this.identifier, class: this.classCollection.join(), "aria-labelledby": this.titleId, ref: (el) => {
|
|
110
110
|
if (el !== null) {
|
|
111
111
|
this.dialog = el;
|
|
112
112
|
}
|
|
113
|
-
} }, h("mg-card", { key: '
|
|
113
|
+
} }, h("mg-card", { key: 'fdddd50b0d87d50025eb65297ffdde890db84daa' }, h("div", { key: 'a168d0ec2be896b381ed6079f2f50f0e06fbef0c', class: "mg-c-modal__dialog" }, h("header", { key: 'f6c902fb1c424d14a0cf36fbe6904137e1f25a77', class: "mg-c-modal__header" }, this.closeButton && (h("span", { key: '3bfd0399c679cd4695b7ec6baf93852f551f500f', class: "mg-c-modal__close-button" }, h("mg-button", { key: '65d9a1001c74869bde17c5b10e4d7f6d40927d5c', "is-icon": true, variant: "flat", label: this.messages.modal.closeButton, onClick: this.handleClose }, h("mg-icon", { key: '4afd89c06bb4667d03dc8f57cafc2de937989539', icon: "cross" })))), h("h1", { key: '0e8714311653249fc9f567072bb83a82f40be657', class: "mg-c-modal__title", id: this.titleId }, this.modalTitle)), h("article", { key: '8bea86261d774672f59161b8356d88bb8ce6934f', class: "mg-c-modal__content" }, h("slot", { key: 'e1be91919ea7c4c6564bdab5fd4637a1f70670af' })), this.hasActions && (h("footer", { key: 'ed52ba51f38a5638e8ab525863631304ec32e4f8', class: "mg-c-modal__footer" }, h("slot", { key: '2ea047455de5f22876a0fc97e95321360aa55b33', name: "actions" })))))));
|
|
114
114
|
}
|
|
115
115
|
static get is() { return "mg-modal"; }
|
|
116
116
|
static get encapsulation() { return "shadow"; }
|
|
@@ -108,10 +108,10 @@ export class MgPagination {
|
|
|
108
108
|
* @returns HTML Element
|
|
109
109
|
*/
|
|
110
110
|
render() {
|
|
111
|
-
const navigationActionButton = (disabled, action) => (h("mg-button", { key: '
|
|
111
|
+
const navigationActionButton = (disabled, action) => (h("mg-button", { key: 'adf311f317e6d071e73e6ee11f323f2957a6c7c5', label: this.messages.pagination[`${action}Page`],
|
|
112
112
|
// eslint-disable-next-line react/jsx-no-bind
|
|
113
|
-
onClick: () => this.handleGoToPage(action, disabled), disabled: disabled, variant: "flat", isIcon: this.hideNavigationLabels }, action === NavigationAction.PREVIOUS && h("mg-icon", { key: '
|
|
114
|
-
return (h(Host, { key: '
|
|
113
|
+
onClick: () => this.handleGoToPage(action, disabled), disabled: disabled, variant: "flat", isIcon: this.hideNavigationLabels }, action === NavigationAction.PREVIOUS && h("mg-icon", { key: '23cd025ff4d5085f60a762ca02bec7ea4d08b47a', icon: "chevron-left" }), !this.hideNavigationLabels && this.messages.general[action], action === NavigationAction.NEXT && h("mg-icon", { key: '5e178d7571d840b691349999a0dc9986ea9a97d1', icon: "chevron-right" })));
|
|
114
|
+
return (h(Host, { key: '549c2a5e08db08ff4db40f283dc941e3c918aa48', hidden: this.totalPages < 2 }, h("nav", { key: '6dad6fcdc86313bd8a89a253bf8b34417b5d7a9b', role: "navigation", "aria-label": this.label, id: this.identifier, class: { 'mg-c-pagination': true, 'mg-c-pagination--hide-page-count': this.hidePageCount } }, navigationActionButton(this.currentPage <= 1, NavigationAction.PREVIOUS), !this.hidePageCount && (h("div", { key: '779c725432c4e35c82a25c9b48619b30d94aa3fd', class: "mg-c-pagination__page-count" }, h("mg-input-select", { key: '9ebbb2eb315ceb906b87c1866a2230a07fc456eb', identifier: `${this.identifier}-select`, items: range(1, this.totalPages).map(page => page.toString()), label: this.messages.pagination.selectPage, "label-hide": true, "on-value-change": this.handleSelect, value: this.currentPage.toString(), "placeholder-hide": true }), h("span", { key: '562ef9a11ec557bf498ac4d62be095cbc4c71d22', class: "mg-u-visually-hidden" }, this.messages.pagination.page, " ", this.currentPage), "/ ", this.totalPages, " ", this.totalPages > 1 ? this.messages.pagination.pages : this.messages.pagination.page)), navigationActionButton(this.currentPage >= this.totalPages, NavigationAction.NEXT))));
|
|
115
115
|
}
|
|
116
116
|
static get is() { return "mg-pagination"; }
|
|
117
117
|
static get encapsulation() { return "shadow"; }
|
|
@@ -188,7 +188,7 @@ export class MgPanel {
|
|
|
188
188
|
*/
|
|
189
189
|
render() {
|
|
190
190
|
const headerId = `${this.identifier}-header`;
|
|
191
|
-
return (h("section", { key: '
|
|
191
|
+
return (h("section", { key: 'ffe1c2453e1247f8a5a3c439f6f87fc1ceefe06b', class: this.classCollection.join(), id: this.identifier }, h("mg-card", { key: '77dfb890d2090af6eca0f332aaff07f737946f50' }, h("header", { key: '2c20eab45a175c8f176dd7c003fc336b4f98d058', class: { 'mg-c-panel__header': true, 'mg-c-panel__header--reverse': this.titlePosition === 'right' }, id: headerId }, this.renderHeaderChildren()), h("article", { key: '2c359205023c9b25c2b88ae6aad404663330d3a5', class: "mg-c-panel__content", id: `${this.identifier}-content`, "aria-labelledby": headerId, hidden: !this.expanded }, h("slot", { key: 'f4c5ce16b3709529d5808a51c1d1f7a0677d82f2' })))));
|
|
192
192
|
}
|
|
193
193
|
static get is() { return "mg-panel"; }
|
|
194
194
|
static get encapsulation() { return "shadow"; }
|
package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js
CHANGED
|
@@ -46,7 +46,7 @@ export class MgPopoverContent {
|
|
|
46
46
|
* @returns HTML Element
|
|
47
47
|
*/
|
|
48
48
|
render() {
|
|
49
|
-
return (h(Host, { key: '
|
|
49
|
+
return (h(Host, { key: '44aa95d34a4c4beeb5c6d1a59e7e7df999393e52' }, h("mg-card", { key: '483195ec364eaaf78df768993706129cb0ce268e', class: this.classCollection.join() }, this.closeButton && (h("mg-button", { key: '4e2b4f7b563c591120ba208e74c501b0bee7497b', "is-icon": true, variant: "flat", label: this.messages.general.close, onClick: this.handleCloseButton }, h("mg-icon", { key: '58a678df3947e4dbfb718c588ccdc97e611915b9', icon: "cross" }))), h("div", { key: 'e7a9debe373ea8947cde108732f635f39b5305a6', class: "mg-c-popover-content__title" }, h("slot", { key: '15fb949256a5f31e8776cdbd7465f46a73db4876', name: "title" })), h("slot", { key: 'ee914630e089763ec3a059cdd6b4c3eba0c2cfa0', name: "content" })), h("slot", { key: '9c25549d1543a77b3cc459caf8bd8df0b279a036', name: "arrow" })));
|
|
50
50
|
}
|
|
51
51
|
static get is() { return "mg-popover-content"; }
|
|
52
52
|
static get encapsulation() { return "shadow"; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mg-popover.conf.js","sourceRoot":"","sources":["../../../../src/components/molecules/mg-popover/mg-popover.conf.tsx"],"names":[],"mappings":"AACA,cAAc,kCAAkC,CAAC","sourcesContent":["import { type ExtendedPlacement, placements } from '../../../utils/floating-ui.utils';\nexport * from '../../../utils/floating-ui.utils';\n\n/**\n * Placement type from placements\n */\nexport type PopoverPlacementType = ExtendedPlacement & (typeof placements)[number];\n"]}
|