UNPKG

hongluan-ui

Version:
1 lines 4.48 kB
{"version":3,"file":"config-provider.mjs","sources":["../../../../../../packages/components/config-provider/src/config-provider.ts"],"sourcesContent":["import { defineComponent, renderSlot, watch } from 'vue'\nimport { isValidComponentSize } from '@hongluan-ui/utils'\nimport { PREFIX } from '@hongluan-ui/constants'\nimport { useEmptyValuesProps, provideGlobalConfig } from '@hongluan-ui/hooks'\n\nimport type { PropType, VNode, ExtractPropTypes } from 'vue'\nimport type { Indexable } from '@hongluan-ui/utils'\nimport type { ComponentSize } from '@hongluan-ui/constants'\nimport type { ExperimentalFeatures } from '@hongluan-ui/tokens'\nimport type { Language } from '@hongluan-ui/locale'\nimport type { MessageConfigContext } from '@hongluan-ui/components/message'\n\nexport const messageConfig: MessageConfigContext = {}\n\nexport const configProviderProps = {\n /**\n * @description Controlling if the users want a11y features\n */\n a11y: {\n type: Boolean,\n default: true,\n },\n /**\n * @description Locale Object\n */\n locale: {\n type: Object as PropType<Language>,\n },\n /**\n * @description global component size\n */\n size: {\n type: String as PropType<ComponentSize>,\n validator: isValidComponentSize,\n },\n /**\n * @description global Initial zIndex\n */\n zIndex: Number,\n touchmoveForbid: {\n type: Boolean,\n default: true,\n },\n systemIcons: {\n type: Object as PropType<Indexable<VNode>>,\n value: () => ({}),\n },\n /**\n * @description features at experimental stage to be added, all features are default to be set to false | ^[object]\n */\n experimentalFeatures: {\n type: Object as PropType<ExperimentalFeatures>,\n },\n /**\n * @description Controls if we should handle keyboard navigation\n */\n keyboardNavigation: {\n type: Boolean,\n default: true,\n },\n /**\n * @description message related configuration, [see the following table](#message-attributes)\n */\n message: {\n type: Object as PropType<MessageConfigContext>,\n },\n /**\n * @description global component className prefix (cooperated with [$namespace](https://github.com/element-plus/element-plus/blob/dev/packages/theme-chalk/src/mixins/config.scss#L1)) | ^[string]\n */\n namespace: {\n type: String,\n default: PREFIX.toLocaleLowerCase(),\n },\n ...useEmptyValuesProps,\n}\nexport type ConfigProviderProps = ExtractPropTypes<typeof configProviderProps>\n\nconst ConfigProvider = defineComponent({\n name: 'ConfigProvider',\n props: configProviderProps,\n\n setup(props, { slots }) {\n watch(\n () => props.message,\n val => {\n Object.assign(messageConfig, val ?? {})\n },\n { immediate: true, deep: true },\n )\n const config = provideGlobalConfig(props)\n return () => renderSlot(slots, 'default', { config: config?.value })\n },\n})\n\nexport type ConfigProviderInstance = InstanceType<typeof ConfigProvider>\nexport default ConfigProvider\n\n"],"names":[],"mappings":";;;;;;;;;AAIY,MAAC,aAAa,GAAG,GAAG;AACpB,MAAC,mBAAmB,GAAG;AACnC,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,IAAI;AACjB,GAAG;AACH,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,GAAG;AACH,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,SAAS,EAAE,oBAAoB;AACnC,GAAG;AACH,EAAE,MAAM,EAAE,MAAM;AAChB,EAAE,eAAe,EAAE;AACnB,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,IAAI;AACjB,GAAG;AACH,EAAE,WAAW,EAAE;AACf,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,KAAK,EAAE,OAAO,EAAE,CAAC;AACrB,GAAG;AACH,EAAE,oBAAoB,EAAE;AACxB,IAAI,IAAI,EAAE,MAAM;AAChB,GAAG;AACH,EAAE,kBAAkB,EAAE;AACtB,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,IAAI;AACjB,GAAG;AACH,EAAE,OAAO,EAAE;AACX,IAAI,IAAI,EAAE,MAAM;AAChB,GAAG;AACH,EAAE,SAAS,EAAE;AACb,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,MAAM,CAAC,iBAAiB,EAAE;AACvC,GAAG;AACH,EAAE,GAAG,mBAAmB;AACxB,EAAE;AACG,MAAC,cAA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