yuyeon 0.1.2-rc.2 → 0.2.1-rc.1

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.
Files changed (171) hide show
  1. package/dist/yuyeon.js +2592 -2523
  2. package/dist/yuyeon.umd.cjs +11 -11
  3. package/lib/abstract/items.mjs +1 -1
  4. package/lib/abstract/items.mjs.map +1 -1
  5. package/lib/components/alert/YAlert.mjs +4 -3
  6. package/lib/components/alert/YAlert.mjs.map +1 -1
  7. package/lib/components/badge/YBadge.mjs +1 -1
  8. package/lib/components/badge/YBadge.mjs.map +1 -1
  9. package/lib/components/button/YButton.mjs +3 -3
  10. package/lib/components/button/YButton.mjs.map +1 -1
  11. package/lib/components/checkbox/YCheckbox.mjs +1 -1
  12. package/lib/components/checkbox/YCheckbox.mjs.map +1 -1
  13. package/lib/components/date-picker/YDateCalendar.mjs +1 -1
  14. package/lib/components/date-picker/YDateCalendar.mjs.map +1 -1
  15. package/lib/components/date-picker/YDatePicker.mjs +1 -1
  16. package/lib/components/date-picker/YDatePicker.mjs.map +1 -1
  17. package/lib/components/date-picker/YDatePickerControl.mjs +1 -1
  18. package/lib/components/date-picker/YDatePickerControl.mjs.map +1 -1
  19. package/lib/components/date-picker/YMonthPicker.mjs +1 -1
  20. package/lib/components/date-picker/YMonthPicker.mjs.map +1 -1
  21. package/lib/components/date-picker/YYearPicker.mjs +1 -1
  22. package/lib/components/date-picker/YYearPicker.mjs.map +1 -1
  23. package/lib/components/dialog/YDialog.mjs +1 -1
  24. package/lib/components/dialog/YDialog.mjs.map +1 -1
  25. package/lib/components/dropdown/YDropdown.mjs +1 -1
  26. package/lib/components/dropdown/YDropdown.mjs.map +1 -1
  27. package/lib/components/field-input/YFieldInput.mjs +1 -1
  28. package/lib/components/field-input/YFieldInput.mjs.map +1 -1
  29. package/lib/components/icon/YIcon.mjs +1 -1
  30. package/lib/components/icon/YIcon.mjs.map +1 -1
  31. package/lib/components/img/YImg.mjs +5 -5
  32. package/lib/components/img/YImg.mjs.map +1 -1
  33. package/lib/components/input/YInput.mjs +1 -1
  34. package/lib/components/input/YInput.mjs.map +1 -1
  35. package/lib/components/ip-field/YIpv4Field.mjs +1 -1
  36. package/lib/components/ip-field/YIpv4Field.mjs.map +1 -1
  37. package/lib/components/layer/YLayer.mjs +1 -1
  38. package/lib/components/layer/YLayer.mjs.map +1 -1
  39. package/lib/components/layer/base.mjs +1 -1
  40. package/lib/components/layer/base.mjs.map +1 -1
  41. package/lib/components/layer/content.mjs +1 -1
  42. package/lib/components/layer/content.mjs.map +1 -1
  43. package/lib/components/layer/scroll-strategies.mjs +1 -1
  44. package/lib/components/layer/scroll-strategies.mjs.map +1 -1
  45. package/lib/components/list/YList.mjs +1 -1
  46. package/lib/components/list/YList.mjs.map +1 -1
  47. package/lib/components/list/YListItem.mjs +1 -1
  48. package/lib/components/list/YListItem.mjs.map +1 -1
  49. package/lib/components/menu/YMenu.mjs +1 -1
  50. package/lib/components/menu/YMenu.mjs.map +1 -1
  51. package/lib/components/pagination/YPagination.mjs +1 -1
  52. package/lib/components/pagination/YPagination.mjs.map +1 -1
  53. package/lib/components/select/YSelect.mjs +1 -1
  54. package/lib/components/select/YSelect.mjs.map +1 -1
  55. package/lib/components/snackbar/YSnackbar.mjs +6 -6
  56. package/lib/components/snackbar/YSnackbar.mjs.map +1 -1
  57. package/lib/components/tab/YTabs.mjs +1 -1
  58. package/lib/components/tab/YTabs.mjs.map +1 -1
  59. package/lib/components/table/YDataTable.mjs +1 -1
  60. package/lib/components/table/YDataTable.mjs.map +1 -1
  61. package/lib/components/table/YDataTableBody.mjs +1 -1
  62. package/lib/components/table/YDataTableBody.mjs.map +1 -1
  63. package/lib/components/table/YDataTableHead.mjs +1 -1
  64. package/lib/components/table/YDataTableHead.mjs.map +1 -1
  65. package/lib/components/table/YDataTableRow.mjs +1 -1
  66. package/lib/components/table/YDataTableRow.mjs.map +1 -1
  67. package/lib/components/table/YDataTableServer.mjs +1 -1
  68. package/lib/components/table/YDataTableServer.mjs.map +1 -1
  69. package/lib/components/table/YTable.mjs +1 -1
  70. package/lib/components/table/YTable.mjs.map +1 -1
  71. package/lib/components/table/composibles/header.mjs +1 -1
  72. package/lib/components/table/composibles/header.mjs.map +1 -1
  73. package/lib/components/table/composibles/items.mjs +1 -1
  74. package/lib/components/table/composibles/items.mjs.map +1 -1
  75. package/lib/components/table/composibles/pagination.mjs +1 -1
  76. package/lib/components/table/composibles/pagination.mjs.map +1 -1
  77. package/lib/components/table/composibles/selection.mjs +1 -1
  78. package/lib/components/table/composibles/selection.mjs.map +1 -1
  79. package/lib/components/table/composibles/sorting.mjs +1 -1
  80. package/lib/components/table/composibles/sorting.mjs.map +1 -1
  81. package/lib/components/tooltip/YTooltip.mjs +1 -1
  82. package/lib/components/tooltip/YTooltip.mjs.map +1 -1
  83. package/lib/components/tree-view/YTreeView.mjs +1 -1
  84. package/lib/components/tree-view/YTreeView.mjs.map +1 -1
  85. package/lib/components/tree-view/YTreeViewNode.mjs +1 -1
  86. package/lib/components/tree-view/YTreeViewNode.mjs.map +1 -1
  87. package/lib/composables/choice.mjs +1 -1
  88. package/lib/composables/choice.mjs.map +1 -1
  89. package/lib/composables/coordinate/index.mjs +1 -1
  90. package/lib/composables/coordinate/index.mjs.map +1 -1
  91. package/lib/composables/date/index.mjs +1 -1
  92. package/lib/composables/date/index.mjs.map +1 -1
  93. package/lib/composables/defaults/index.mjs +99 -0
  94. package/lib/composables/defaults/index.mjs.map +1 -0
  95. package/lib/composables/defaults/share.mjs +2 -0
  96. package/lib/composables/defaults/share.mjs.map +1 -0
  97. package/lib/composables/defaults/types.mjs +2 -0
  98. package/lib/composables/defaults/types.mjs.map +1 -0
  99. package/lib/composables/dimension.mjs +1 -1
  100. package/lib/composables/dimension.mjs.map +1 -1
  101. package/lib/composables/focus.mjs +1 -1
  102. package/lib/composables/focus.mjs.map +1 -1
  103. package/lib/composables/form.mjs +1 -1
  104. package/lib/composables/form.mjs.map +1 -1
  105. package/lib/composables/i18n/index.mjs +2 -2
  106. package/lib/composables/i18n/index.mjs.map +1 -1
  107. package/lib/composables/list-items.mjs +1 -1
  108. package/lib/composables/list-items.mjs.map +1 -1
  109. package/lib/composables/resize-observer.mjs +1 -1
  110. package/lib/composables/resize-observer.mjs.map +1 -1
  111. package/lib/composables/theme/index.mjs +2 -2
  112. package/lib/composables/theme/index.mjs.map +1 -1
  113. package/lib/index.mjs +6 -1
  114. package/lib/index.mjs.map +1 -1
  115. package/lib/util/component/component.mjs +21 -0
  116. package/lib/util/component/component.mjs.map +1 -0
  117. package/lib/util/component/index.mjs +64 -0
  118. package/lib/util/component/index.mjs.map +1 -0
  119. package/lib/util/component/inject-self.mjs +10 -0
  120. package/lib/util/component/inject-self.mjs.map +1 -0
  121. package/lib/util/component/props.mjs +41 -0
  122. package/lib/util/component/props.mjs.map +1 -0
  123. package/lib/util/component/types.mjs +2 -0
  124. package/lib/util/component/types.mjs.map +1 -0
  125. package/lib/util/index.mjs +1 -1
  126. package/lib/util/index.mjs.map +1 -1
  127. package/lib/util/vue-component/index.mjs +63 -0
  128. package/lib/util/vue-component/index.mjs.map +1 -0
  129. package/lib/util/vue-component/props.mjs +37 -0
  130. package/lib/util/vue-component/props.mjs.map +1 -0
  131. package/lib/util/vue-component/types.mjs +2 -0
  132. package/lib/util/vue-component/types.mjs.map +1 -0
  133. package/package.json +1 -1
  134. package/types/components/alert/YAlert.d.ts +2 -13
  135. package/types/components/badge/YBadge.d.ts +3 -3
  136. package/types/components/date-picker/YDateCalendar.d.ts +7 -7
  137. package/types/components/date-picker/YDatePicker.d.ts +22 -22
  138. package/types/components/date-picker/YMonthPicker.d.ts +3 -3
  139. package/types/components/date-picker/YYearPicker.d.ts +3 -3
  140. package/types/components/dialog/YDialog.d.ts +42 -42
  141. package/types/components/dropdown/YDropdown.d.ts +18 -18
  142. package/types/components/field-input/YFieldInput.d.ts +3 -3
  143. package/types/components/form/YForm.d.ts +1 -1
  144. package/types/components/hover/YHover.d.ts +1 -1
  145. package/types/components/icon/YIcon.d.ts +4 -4
  146. package/types/components/input/YInput.d.ts +3 -3
  147. package/types/components/ip-field/YIpv4Field.d.ts +2 -2
  148. package/types/components/layer/YLayer.d.ts +5 -5
  149. package/types/components/menu/YMenu.d.ts +7 -7
  150. package/types/components/pagination/YPagination.d.ts +20 -20
  151. package/types/components/select/YSelect.d.ts +93 -93
  152. package/types/components/snackbar/YSnackbar.d.ts +29 -9
  153. package/types/components/tab/YTabs.d.ts +1 -1
  154. package/types/components/textarea/YTextarea.d.ts +6 -6
  155. package/types/components/tooltip/YTooltip.d.ts +9 -9
  156. package/types/components/tree-view/YTreeView.d.ts +2 -2
  157. package/types/composables/coordinate/index.d.ts +2 -2
  158. package/types/composables/defaults/index.d.ts +11 -0
  159. package/types/composables/defaults/share.d.ts +4 -0
  160. package/types/composables/defaults/types.d.ts +12 -0
  161. package/types/composables/form.d.ts +1 -1
  162. package/types/globals.d.ts +1 -0
  163. package/types/util/component/component.d.ts +4 -0
  164. package/types/util/component/index.d.ts +11 -0
  165. package/types/util/component/inject-self.d.ts +3 -0
  166. package/types/util/component/props.d.ts +32 -0
  167. package/types/util/component/types.d.ts +21 -0
  168. package/types/util/index.d.ts +1 -1
  169. package/types/util/vue-component/index.d.ts +10 -0
  170. package/types/util/vue-component/props.d.ts +31 -0
  171. package/types/util/vue-component/types.d.ts +4 -0
@@ -1,6 +1,6 @@
1
1
  import { computed } from 'vue';
2
2
  import { toStyleSizeValue } from "../util/ui.mjs";
3
- import { propsFactory } from "../util/vue-component.mjs";
3
+ import { propsFactory } from "../util/component/index.mjs";
4
4
  const dimensionPropsOptions = {
5
5
  minWidth: [Number, String],
6
6
  width: [Number, String],
@@ -1 +1 @@
1
- {"version":3,"file":"dimension.mjs","names":["computed","toStyleSizeValue","propsFactory","dimensionPropsOptions","minWidth","Number","String","width","maxWidth","minHeight","height","maxHeight","pressDimensionPropsOptions","useDimension","props","dimensionStyles"],"sources":["../../src/composables/dimension.ts"],"sourcesContent":["import { ExtractPropTypes, PropType, computed } from 'vue';\n\nimport { toStyleSizeValue } from '../util/ui';\nimport { propsFactory } from '../util/vue-component';\n\nconst dimensionPropsOptions = {\n minWidth: [Number, String] as PropType<number | string>,\n width: [Number, String] as PropType<number | string>,\n maxWidth: [Number, String] as PropType<number | string>,\n minHeight: [Number, String] as PropType<number | string>,\n height: [Number, String] as PropType<number | string>,\n maxHeight: [Number, String] as PropType<number | string>,\n};\n\nexport const pressDimensionPropsOptions = propsFactory(\n dimensionPropsOptions,\n 'dimension',\n);\n\nexport function useDimension(\n props: ExtractPropTypes<typeof dimensionPropsOptions>,\n) {\n const dimensionStyles = computed(() => ({\n minWidth: toStyleSizeValue(props.minWidth),\n width: toStyleSizeValue(props.width),\n maxWidth: toStyleSizeValue(props.maxWidth),\n minHeight: toStyleSizeValue(props.minHeight),\n height: toStyleSizeValue(props.height),\n maxHeight: toStyleSizeValue(props.maxHeight),\n }));\n\n return {\n dimensionStyles,\n };\n}\n"],"mappings":"AAAA,SAAqCA,QAAQ,QAAQ,KAAK;AAAC,SAElDC,gBAAgB;AAAA,SAChBC,YAAY;AAErB,MAAMC,qBAAqB,GAAG;EAC5BC,QAAQ,EAAE,CAACC,MAAM,EAAEC,MAAM,CAA8B;EACvDC,KAAK,EAAE,CAACF,MAAM,EAAEC,MAAM,CAA8B;EACpDE,QAAQ,EAAE,CAACH,MAAM,EAAEC,MAAM,CAA8B;EACvDG,SAAS,EAAE,CAACJ,MAAM,EAAEC,MAAM,CAA8B;EACxDI,MAAM,EAAE,CAACL,MAAM,EAAEC,MAAM,CAA8B;EACrDK,SAAS,EAAE,CAACN,MAAM,EAAEC,MAAM;AAC5B,CAAC;AAED,OAAO,MAAMM,0BAA0B,GAAGV,YAAY,CACpDC,qBAAqB,EACrB,WACF,CAAC;AAED,OAAO,SAASU,YAAYA,CAC1BC,KAAqD,EACrD;EACA,MAAMC,eAAe,GAAGf,QAAQ,CAAC,OAAO;IACtCI,QAAQ,EAAEH,gBAAgB,CAACa,KAAK,CAACV,QAAQ,CAAC;IAC1CG,KAAK,EAAEN,gBAAgB,CAACa,KAAK,CAACP,KAAK,CAAC;IACpCC,QAAQ,EAAEP,gBAAgB,CAACa,KAAK,CAACN,QAAQ,CAAC;IAC1CC,SAAS,EAAER,gBAAgB,CAACa,KAAK,CAACL,SAAS,CAAC;IAC5CC,MAAM,EAAET,gBAAgB,CAACa,KAAK,CAACJ,MAAM,CAAC;IACtCC,SAAS,EAAEV,gBAAgB,CAACa,KAAK,CAACH,SAAS;EAC7C,CAAC,CAAC,CAAC;EAEH,OAAO;IACLI;EACF,CAAC;AACH"}
1
+ {"version":3,"file":"dimension.mjs","names":["computed","toStyleSizeValue","propsFactory","dimensionPropsOptions","minWidth","Number","String","width","maxWidth","minHeight","height","maxHeight","pressDimensionPropsOptions","useDimension","props","dimensionStyles"],"sources":["../../src/composables/dimension.ts"],"sourcesContent":["import { ExtractPropTypes, PropType, computed } from 'vue';\r\n\r\nimport { toStyleSizeValue } from '../util/ui';\r\nimport { propsFactory } from '../util/component';\r\n\r\nconst dimensionPropsOptions = {\r\n minWidth: [Number, String] as PropType<number | string>,\r\n width: [Number, String] as PropType<number | string>,\r\n maxWidth: [Number, String] as PropType<number | string>,\r\n minHeight: [Number, String] as PropType<number | string>,\r\n height: [Number, String] as PropType<number | string>,\r\n maxHeight: [Number, String] as PropType<number | string>,\r\n};\r\n\r\nexport const pressDimensionPropsOptions = propsFactory(\r\n dimensionPropsOptions,\r\n 'dimension',\r\n);\r\n\r\nexport function useDimension(\r\n props: ExtractPropTypes<typeof dimensionPropsOptions>,\r\n) {\r\n const dimensionStyles = computed(() => ({\r\n minWidth: toStyleSizeValue(props.minWidth),\r\n width: toStyleSizeValue(props.width),\r\n maxWidth: toStyleSizeValue(props.maxWidth),\r\n minHeight: toStyleSizeValue(props.minHeight),\r\n height: toStyleSizeValue(props.height),\r\n maxHeight: toStyleSizeValue(props.maxHeight),\r\n }));\r\n\r\n return {\r\n dimensionStyles,\r\n };\r\n}\r\n"],"mappings":"AAAA,SAAqCA,QAAQ,QAAQ,KAAK;AAAC,SAElDC,gBAAgB;AAAA,SAChBC,YAAY;AAErB,MAAMC,qBAAqB,GAAG;EAC5BC,QAAQ,EAAE,CAACC,MAAM,EAAEC,MAAM,CAA8B;EACvDC,KAAK,EAAE,CAACF,MAAM,EAAEC,MAAM,CAA8B;EACpDE,QAAQ,EAAE,CAACH,MAAM,EAAEC,MAAM,CAA8B;EACvDG,SAAS,EAAE,CAACJ,MAAM,EAAEC,MAAM,CAA8B;EACxDI,MAAM,EAAE,CAACL,MAAM,EAAEC,MAAM,CAA8B;EACrDK,SAAS,EAAE,CAACN,MAAM,EAAEC,MAAM;AAC5B,CAAC;AAED,OAAO,MAAMM,0BAA0B,GAAGV,YAAY,CACpDC,qBAAqB,EACrB,WACF,CAAC;AAED,OAAO,SAASU,YAAYA,CAC1BC,KAAqD,EACrD;EACA,MAAMC,eAAe,GAAGf,QAAQ,CAAC,OAAO;IACtCI,QAAQ,EAAEH,gBAAgB,CAACa,KAAK,CAACV,QAAQ,CAAC;IAC1CG,KAAK,EAAEN,gBAAgB,CAACa,KAAK,CAACP,KAAK,CAAC;IACpCC,QAAQ,EAAEP,gBAAgB,CAACa,KAAK,CAACN,QAAQ,CAAC;IAC1CC,SAAS,EAAER,gBAAgB,CAACa,KAAK,CAACL,SAAS,CAAC;IAC5CC,MAAM,EAAET,gBAAgB,CAACa,KAAK,CAACJ,MAAM,CAAC;IACtCC,SAAS,EAAEV,gBAAgB,CAACa,KAAK,CAACH,SAAS;EAC7C,CAAC,CAAC,CAAC;EAEH,OAAO;IACLI;EACF,CAAC;AACH"}
@@ -1,4 +1,4 @@
1
- import { propsFactory } from "../util/vue-component.mjs";
1
+ import { propsFactory } from "../util/component/index.mjs";
2
2
  import { computed } from "vue";
3
3
  import { useModelDuplex } from "./communication.mjs";
4
4
  const focusPropsOptions = {
@@ -1 +1 @@
1
- {"version":3,"file":"focus.mjs","names":["propsFactory","computed","useModelDuplex","focusPropsOptions","focused","Boolean","Function","pressFocusPropsOptions","useFocus","props","className","whenFocus","value","whenBlur","focusedClasses"],"sources":["../../src/composables/focus.ts"],"sourcesContent":["import { propsFactory } from \"../util/vue-component\";\r\nimport { computed, ExtractPropTypes, PropType } from \"vue\";\r\nimport { useModelDuplex } from \"./communication\";\r\n\r\nconst focusPropsOptions = {\r\n focused: Boolean,\r\n 'onUpdate:focused': Function as PropType<(v: boolean) => void>,\r\n};\r\n\r\nexport const pressFocusPropsOptions = propsFactory(focusPropsOptions, 'focus');\r\n\r\nexport function useFocus(props: ExtractPropTypes<typeof focusPropsOptions>, className: string) {\r\n const focused = useModelDuplex(props, 'focused');\r\n\r\n function whenFocus() {\r\n focused.value = true;\r\n }\r\n\r\n function whenBlur() {\r\n focused.value = false;\r\n }\r\n\r\n const focusedClasses = computed(() => {\r\n return {\r\n [`${className}--focused`]: focused.value,\r\n }\r\n })\r\n\r\n return {\r\n focused,\r\n whenFocus,\r\n whenBlur,\r\n focusedClasses,\r\n }\r\n}\r\n"],"mappings":"SAASA,YAAY;AACrB,SAASC,QAAQ,QAAoC,KAAK;AAAC,SAClDC,cAAc;AAEvB,MAAMC,iBAAiB,GAAG;EACxBC,OAAO,EAAEC,OAAO;EAChB,kBAAkB,EAAEC;AACtB,CAAC;AAED,OAAO,MAAMC,sBAAsB,GAAGP,YAAY,CAACG,iBAAiB,EAAE,OAAO,CAAC;AAE9E,OAAO,SAASK,QAAQA,CAACC,KAAiD,EAAEC,SAAiB,EAAE;EAC7F,MAAMN,OAAO,GAAGF,cAAc,CAACO,KAAK,EAAE,SAAS,CAAC;EAEhD,SAASE,SAASA,CAAA,EAAG;IACnBP,OAAO,CAACQ,KAAK,GAAG,IAAI;EACtB;EAEA,SAASC,QAAQA,CAAA,EAAG;IAClBT,OAAO,CAACQ,KAAK,GAAG,KAAK;EACvB;EAEA,MAAME,cAAc,GAAGb,QAAQ,CAAC,MAAM;IACpC,OAAO;MACL,CAAE,GAAES,SAAU,WAAU,GAAGN,OAAO,CAACQ;IACrC,CAAC;EACH,CAAC,CAAC;EAEF,OAAO;IACLR,OAAO;IACPO,SAAS;IACTE,QAAQ;IACRC;EACF,CAAC;AACH"}
1
+ {"version":3,"file":"focus.mjs","names":["propsFactory","computed","useModelDuplex","focusPropsOptions","focused","Boolean","Function","pressFocusPropsOptions","useFocus","props","className","whenFocus","value","whenBlur","focusedClasses"],"sources":["../../src/composables/focus.ts"],"sourcesContent":["import { propsFactory } from \"../util/component\";\r\nimport { computed, ExtractPropTypes, PropType } from \"vue\";\r\nimport { useModelDuplex } from \"./communication\";\r\n\r\nconst focusPropsOptions = {\r\n focused: Boolean,\r\n 'onUpdate:focused': Function as PropType<(v: boolean) => void>,\r\n};\r\n\r\nexport const pressFocusPropsOptions = propsFactory(focusPropsOptions, 'focus');\r\n\r\nexport function useFocus(props: ExtractPropTypes<typeof focusPropsOptions>, className: string) {\r\n const focused = useModelDuplex(props, 'focused');\r\n\r\n function whenFocus() {\r\n focused.value = true;\r\n }\r\n\r\n function whenBlur() {\r\n focused.value = false;\r\n }\r\n\r\n const focusedClasses = computed(() => {\r\n return {\r\n [`${className}--focused`]: focused.value,\r\n }\r\n })\r\n\r\n return {\r\n focused,\r\n whenFocus,\r\n whenBlur,\r\n focusedClasses,\r\n }\r\n}\r\n"],"mappings":"SAASA,YAAY;AACrB,SAASC,QAAQ,QAAoC,KAAK;AAAC,SAClDC,cAAc;AAEvB,MAAMC,iBAAiB,GAAG;EACxBC,OAAO,EAAEC,OAAO;EAChB,kBAAkB,EAAEC;AACtB,CAAC;AAED,OAAO,MAAMC,sBAAsB,GAAGP,YAAY,CAACG,iBAAiB,EAAE,OAAO,CAAC;AAE9E,OAAO,SAASK,QAAQA,CAACC,KAAiD,EAAEC,SAAiB,EAAE;EAC7F,MAAMN,OAAO,GAAGF,cAAc,CAACO,KAAK,EAAE,SAAS,CAAC;EAEhD,SAASE,SAASA,CAAA,EAAG;IACnBP,OAAO,CAACQ,KAAK,GAAG,IAAI;EACtB;EAEA,SAASC,QAAQA,CAAA,EAAG;IAClBT,OAAO,CAACQ,KAAK,GAAG,KAAK;EACvB;EAEA,MAAME,cAAc,GAAGb,QAAQ,CAAC,MAAM;IACpC,OAAO;MACL,CAAE,GAAES,SAAU,WAAU,GAAGN,OAAO,CAACQ;IACrC,CAAC;EACH,CAAC,CAAC;EAEF,OAAO;IACLR,OAAO;IACPO,SAAS;IACTE,QAAQ;IACRC;EACF,CAAC;AACH"}
@@ -1,5 +1,5 @@
1
1
  import { computed, inject, provide, ref, shallowRef, toRef } from 'vue';
2
- import { propsFactory } from "../util/vue-component.mjs";
2
+ import { propsFactory } from "../util/component/index.mjs";
3
3
  import { useModelDuplex } from "./communication.mjs";
4
4
  export const YUYEON_FORM_KEY = Symbol.for('yuyeon.form');
5
5
  export const pressFormPropsOptions = propsFactory({
@@ -1 +1 @@
1
- {"version":3,"file":"form.mjs","names":["computed","inject","provide","ref","shallowRef","toRef","propsFactory","useModelDuplex","YUYEON_FORM_KEY","Symbol","for","pressFormPropsOptions","readonly","Boolean","disabled","loading","modelValue","type","default","validateOn","String","createForm","props","model","isValidating","inputs","errors","isReadonly","isDisabled","isLoading","validate","results","valid","value","item","itemErrors","length","push","id","vnode","exposed","component","register","input","isError","unregister","filter","update","found","find","provideInstance","isValid","useForm"],"sources":["../../src/composables/form.ts"],"sourcesContent":["import {\n ComputedRef,\n InjectionKey,\n PropType,\n Ref,\n computed,\n inject,\n provide,\n ref,\n shallowRef,\n toRef, VNode,\n} from 'vue';\n\nimport { EventProp, propsFactory } from '../util/vue-component';\nimport { useModelDuplex } from './communication';\nimport { ValidationProps } from './validation';\n\nexport interface FormInput {\n id: number | string;\n vnode: VNode;\n validate: () => Promise<any[]>;\n isError: boolean | undefined | null;\n errors: any[];\n}\n\nexport interface InputValidationResult {\n id: number | string;\n vnode: VNode;\n exposed: any;\n errors: any[];\n}\n\nexport interface FormValidationResult {\n valid: boolean;\n errors: InputValidationResult[];\n}\n\nexport interface SubmitEventPromise\n extends SubmitEvent,\n Promise<FormValidationResult> {}\n\nexport interface FormInstance {\n register: (input: {\n id: number | string;\n vnode: VNode;\n validate: () => Promise<any[]>;\n resetValidation: () => Promise<void>;\n }) => void;\n unregister: (id: number | string) => void;\n update: (\n id: number | string,\n isError: boolean | undefined | null,\n errors: any[],\n ) => void;\n inputs: Ref<FormInput[]>;\n isDisabled: ComputedRef<boolean>;\n isReadonly: ComputedRef<boolean>;\n isLoading: ComputedRef<boolean>;\n isValidating: Ref<boolean>;\n isValid: Ref<boolean | null>;\n validateOn: Ref<FormProps['validateOn']>;\n}\n\nexport const YUYEON_FORM_KEY: InjectionKey<FormInstance> =\n Symbol.for('yuyeon.form');\n\nexport interface FormProps {\n readonly: boolean;\n disabled: boolean;\n loading: boolean;\n modelValue: boolean | null;\n 'onUpdate:modelValue': EventProp<[boolean | null]> | undefined;\n validateOn: ValidationProps['validateOn'];\n}\n\nexport const pressFormPropsOptions = propsFactory(\n {\n readonly: Boolean,\n disabled: Boolean,\n loading: Boolean,\n modelValue: {\n type: Boolean as PropType<boolean | null>,\n default: null,\n },\n validateOn: {\n type: String as PropType<ValidationProps['validateOn']>,\n default: 'input',\n },\n },\n 'form',\n);\n\nexport function createForm(props: FormProps) {\n const model = useModelDuplex(props);\n const isValidating = shallowRef(false);\n const inputs = ref<FormInput[]>([]);\n const errors = ref<InputValidationResult[]>([]);\n\n const isReadonly = computed(() => props.readonly);\n const isDisabled = computed(() => props.disabled);\n const isLoading = computed(() => props.loading);\n\n async function validate() {\n const results: InputValidationResult[] = [];\n let valid = true;\n\n errors.value = [];\n isValidating.value = true;\n\n for (const item of inputs.value) {\n const itemErrors = await item.validate();\n\n if (itemErrors.length > 0) {\n valid = false;\n\n results.push({\n id: item.id,\n vnode: item.vnode,\n exposed: item.vnode.component?.exposed,\n errors: itemErrors,\n });\n }\n }\n\n errors.value = results;\n isValidating.value = false;\n\n return { valid, errors: errors.value };\n }\n\n function register(input: {\n id: number | string;\n vnode: VNode;\n validate: () => Promise<any[]>;\n }) {\n const { id, validate, vnode } = input;\n inputs.value.push({\n id,\n validate,\n vnode,\n isError: null,\n errors: [],\n });\n }\n\n function unregister(id: number | string) {\n inputs.value = inputs.value.filter((input) => input.id !== id);\n }\n\n function update(\n id: number | string,\n isError: boolean | undefined | null,\n errors: any[],\n ) {\n const found = inputs.value.find((item) => item.id === id);\n\n if (!found) return;\n\n found.isError = isError;\n found.errors = errors;\n }\n\n const provideInstance: FormInstance = {\n inputs,\n isDisabled,\n isReadonly,\n isLoading,\n isValid: model,\n isValidating,\n register,\n unregister,\n update,\n validateOn: toRef(props, 'validateOn'),\n };\n\n provide(YUYEON_FORM_KEY, provideInstance);\n\n return {\n inputs,\n errors,\n isValid: model,\n isDisabled,\n isReadonly,\n isLoading,\n isValidating,\n validate,\n };\n}\n\nexport function useForm() {\n return inject(YUYEON_FORM_KEY, null);\n}\n"],"mappings":"AAAA,SAKEA,QAAQ,EACRC,MAAM,EACNC,OAAO,EACPC,GAAG,EACHC,UAAU,EACVC,KAAK,QACA,KAAK;AAAC,SAEOC,YAAY;AAAA,SACvBC,cAAc;AAiDvB,OAAO,MAAMC,eAA2C,GACtDC,MAAM,CAACC,GAAG,CAAC,aAAa,CAAC;AAW3B,OAAO,MAAMC,qBAAqB,GAAGL,YAAY,CAC/C;EACEM,QAAQ,EAAEC,OAAO;EACjBC,QAAQ,EAAED,OAAO;EACjBE,OAAO,EAAEF,OAAO;EAChBG,UAAU,EAAE;IACVC,IAAI,EAAEJ,OAAmC;IACzCK,OAAO,EAAE;EACX,CAAC;EACDC,UAAU,EAAE;IACVF,IAAI,EAAEG,MAAiD;IACvDF,OAAO,EAAE;EACX;AACF,CAAC,EACD,MACF,CAAC;AAED,OAAO,SAASG,UAAUA,CAACC,KAAgB,EAAE;EAC3C,MAAMC,KAAK,GAAGhB,cAAc,CAACe,KAAK,CAAC;EACnC,MAAME,YAAY,GAAGpB,UAAU,CAAC,KAAK,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MAChBC,EAAE;MACFR,QAAQ;MACRS,KAAK;MACLK,OAAO,EAAE,IAAI;MACblB,MAAM,EAAE;IACV,CAAC,CAAC;EACJ;EAEA,SAASmB,UAAUA,CAACP,EAAmB,EAAE;IACvCb,MAAM,CAACQ,KAAK,GAAGR,MAAM,CAACQ,KAAK,CAACa,MAAM,CAAEH,KAAK,IAAKA,KAAK,CAACL,EAAE,KAAKA,EAAE,CAAC;EAChE;EAEA,SAASS,MAAMA,CACbT,EAAmB,EACnBM,OAAmC,EACnClB,MAAa,EACb;IACA,MAAMsB,KAAK,GAAGvB,MAAM,CAACQ,KAAK,CAACgB,IAAI,CAAEf,IAAI,IAAKA,IAAI,CAACI,EAAE,KAAKA,EAAE,CAAC;IAEzD,IAAI,CAACU,KAAK,EAAE;IAEZA,KAAK,CAACJ,OAAO,GAAGA,OAAO;IACvBI,KAAK,CAACtB,MAAM,GAAGA,MAAM;EACvB;EAEA,MAAMwB,eAA6B,GAAG;IACpCzB,MAAM;IACNG,UAAU;IACVD,UAAU;IACVE,SAAS;IACTsB,OAAO,EAAE5B,KAAK;IACdC,YAAY;IACZkB,QAAQ;IACRG,UAAU;IACVE,MAAM;IACN5B,UAAU,EAAEd,KAAK,CAACiB,KAAK,EAAE,YAAY;EACvC,CAAC;EAEDpB,OAAO,CAACM,eAAe,EAAE0C,eAAe,CAAC;EAEzC,OAAO;IACLzB,MAAM;IACNC,MAAM;IACNyB,OAAO,EAAE5B,KAAK;IACdK,UAAU;IACVD,UAAU;IACVE,SAAS;IACTL,YAAY;IACZM;EACF,CAAC;AACH;AAEA,OAAO,SAASsB,OAAOA,CAAA,EAAG;EACxB,OAAOnD,MAAM,CAACO,eAAe,EAAE,IAAI,CAAC;AACtC"}
1
+ {"version":3,"file":"form.mjs","names":["computed","inject","provide","ref","shallowRef","toRef","propsFactory","useModelDuplex","YUYEON_FORM_KEY","Symbol","for","pressFormPropsOptions","readonly","Boolean","disabled","loading","modelValue","type","default","validateOn","String","createForm","props","model","isValidating","inputs","errors","isReadonly","isDisabled","isLoading","validate","results","valid","value","item","itemErrors","length","push","id","vnode","exposed","component","register","input","isError","unregister","filter","update","found","find","provideInstance","isValid","useForm"],"sources":["../../src/composables/form.ts"],"sourcesContent":["import {\r\n ComputedRef,\r\n InjectionKey,\r\n PropType,\r\n Ref,\r\n computed,\r\n inject,\r\n provide,\r\n ref,\r\n shallowRef,\r\n toRef, VNode,\r\n} from 'vue';\r\n\r\nimport { EventProp, propsFactory } from '../util/component';\r\nimport { useModelDuplex } from './communication';\r\nimport { ValidationProps } from './validation';\r\n\r\nexport interface FormInput {\r\n id: number | string;\r\n vnode: VNode;\r\n validate: () => Promise<any[]>;\r\n isError: boolean | undefined | null;\r\n errors: any[];\r\n}\r\n\r\nexport interface InputValidationResult {\r\n id: number | string;\r\n vnode: VNode;\r\n exposed: any;\r\n errors: any[];\r\n}\r\n\r\nexport interface FormValidationResult {\r\n valid: boolean;\r\n errors: InputValidationResult[];\r\n}\r\n\r\nexport interface SubmitEventPromise\r\n extends SubmitEvent,\r\n Promise<FormValidationResult> {}\r\n\r\nexport interface FormInstance {\r\n register: (input: {\r\n id: number | string;\r\n vnode: VNode;\r\n validate: () => Promise<any[]>;\r\n resetValidation: () => Promise<void>;\r\n }) => void;\r\n unregister: (id: number | string) => void;\r\n update: (\r\n id: number | string,\r\n isError: boolean | undefined | null,\r\n errors: any[],\r\n ) => void;\r\n inputs: Ref<FormInput[]>;\r\n isDisabled: ComputedRef<boolean>;\r\n isReadonly: ComputedRef<boolean>;\r\n isLoading: ComputedRef<boolean>;\r\n isValidating: Ref<boolean>;\r\n isValid: Ref<boolean | null>;\r\n validateOn: Ref<FormProps['validateOn']>;\r\n}\r\n\r\nexport const YUYEON_FORM_KEY: InjectionKey<FormInstance> =\r\n Symbol.for('yuyeon.form');\r\n\r\nexport interface FormProps {\r\n readonly: boolean;\r\n disabled: boolean;\r\n loading: boolean;\r\n modelValue: boolean | null;\r\n 'onUpdate:modelValue': EventProp<[boolean | null]> | undefined;\r\n validateOn: ValidationProps['validateOn'];\r\n}\r\n\r\nexport const pressFormPropsOptions = propsFactory(\r\n {\r\n readonly: Boolean,\r\n disabled: Boolean,\r\n loading: Boolean,\r\n modelValue: {\r\n type: Boolean as PropType<boolean | null>,\r\n default: null,\r\n },\r\n validateOn: {\r\n type: String as PropType<ValidationProps['validateOn']>,\r\n default: 'input',\r\n },\r\n },\r\n 'form',\r\n);\r\n\r\nexport function createForm(props: FormProps) {\r\n const model = useModelDuplex(props);\r\n const isValidating = shallowRef(false);\r\n const inputs = ref<FormInput[]>([]);\r\n const errors = ref<InputValidationResult[]>([]);\r\n\r\n const isReadonly = computed(() => props.readonly);\r\n const isDisabled = computed(() => props.disabled);\r\n const isLoading = computed(() => props.loading);\r\n\r\n async function validate() {\r\n const results: InputValidationResult[] = [];\r\n let valid = true;\r\n\r\n errors.value = [];\r\n isValidating.value = true;\r\n\r\n for (const item of inputs.value) {\r\n const itemErrors = await item.validate();\r\n\r\n if (itemErrors.length > 0) {\r\n valid = false;\r\n\r\n results.push({\r\n id: item.id,\r\n vnode: item.vnode,\r\n exposed: item.vnode.component?.exposed,\r\n errors: itemErrors,\r\n });\r\n }\r\n }\r\n\r\n errors.value = results;\r\n isValidating.value = false;\r\n\r\n return { valid, errors: errors.value };\r\n }\r\n\r\n function register(input: {\r\n id: number | string;\r\n vnode: VNode;\r\n validate: () => Promise<any[]>;\r\n }) {\r\n const { id, validate, vnode } = input;\r\n inputs.value.push({\r\n id,\r\n validate,\r\n vnode,\r\n isError: null,\r\n errors: [],\r\n });\r\n }\r\n\r\n function unregister(id: number | string) {\r\n inputs.value = inputs.value.filter((input) => input.id !== id);\r\n }\r\n\r\n function update(\r\n id: number | string,\r\n isError: boolean | undefined | null,\r\n errors: any[],\r\n ) {\r\n const found = inputs.value.find((item) => item.id === id);\r\n\r\n if (!found) return;\r\n\r\n found.isError = isError;\r\n found.errors = errors;\r\n }\r\n\r\n const provideInstance: FormInstance = {\r\n inputs,\r\n isDisabled,\r\n isReadonly,\r\n isLoading,\r\n isValid: model,\r\n isValidating,\r\n register,\r\n unregister,\r\n update,\r\n validateOn: toRef(props, 'validateOn'),\r\n };\r\n\r\n provide(YUYEON_FORM_KEY, provideInstance);\r\n\r\n return {\r\n inputs,\r\n errors,\r\n isValid: model,\r\n isDisabled,\r\n isReadonly,\r\n isLoading,\r\n isValidating,\r\n validate,\r\n };\r\n}\r\n\r\nexport function useForm() {\r\n return inject(YUYEON_FORM_KEY, null);\r\n}\r\n"],"mappings":"AAAA,SAKEA,QAAQ,EACRC,MAAM,EACNC,OAAO,EACPC,GAAG,EACHC,UAAU,EACVC,KAAK,QACA,KAAK;AAAC,SAEOC,YAAY;AAAA,SACvBC,cAAc;AAiDvB,OAAO,MAAMC,eAA2C,GACtDC,MAAM,CAACC,GAAG,CAAC,aAAa,CAAC;AAW3B,OAAO,MAAMC,qBAAqB,GAAGL,YAAY,CAC/C;EACEM,QAAQ,EAAEC,OAAO;EACjBC,QAAQ,EAAED,OAAO;EACjBE,OAAO,EAAEF,OAAO;EAChBG,UAAU,EAAE;IACVC,IAAI,EAAEJ,OAAmC;IACzCK,OAAO,EAAE;EACX,CAAC;EACDC,UAAU,EAAE;IACVF,IAAI,EAAEG,MAAiD;IACvDF,OAAO,EAAE;EACX;AACF,CAAC,EACD,MACF,CAAC;AAED,OAAO,SAASG,UAAUA,CAACC,KAAgB,EAAE;EAC3C,MAAMC,KAAK,GAAGhB,cAAc,CAACe,KAAK,CAAC;EACnC,MAAME,YAAY,GAAGpB,UAAU,CAAC,KAAK,CAAC;EACtC,MAAMqB,MAAM,GAAGtB,GAAG,CAAc,EAAE,CAAC;EACnC,MAAMuB,MAAM,GAAGvB,GAAG,CAA0B,EAAE,CAAC;EAE/C,MAAMwB,UAAU,GAAG3B,QAAQ,CAAC,MAAMsB,KAAK,CAACV,QAAQ,CAAC;EACjD,MAAMgB,UAAU,GAAG5B,QAAQ,CAAC,MAAMsB,KAAK,CAACR,QAAQ,CA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AC;EAChE;EAEA,SAASS,MAAMA,CACbT,EAAmB,EACnBM,OAAmC,EACnClB,MAAa,EACb;IACA,MAAMsB,KAAK,GAAGvB,MAAM,CAACQ,KAAK,CAACgB,IAAI,CAAEf,IAAI,IAAKA,IAAI,CAACI,EAAE,KAAKA,EAAE,CAAC;IAEzD,IAAI,CAACU,KAAK,EAAE;IAEZA,KAAK,CAACJ,OAAO,GAAGA,OAAO;IACvBI,KAAK,CAACtB,MAAM,GAAGA,MAAM;EACvB;EAEA,MAAMwB,eAA6B,GAAG;IACpCzB,MAAM;IACNG,UAAU;IACVD,UAAU;IACVE,SAAS;IACTsB,OAAO,EAAE5B,KAAK;IACdC,YAAY;IACZkB,QAAQ;IACRG,UAAU;IACVE,MAAM;IACN5B,UAAU,EAAEd,KAAK,CAACiB,KAAK,EAAE,YAAY;EACvC,CAAC;EAEDpB,OAAO,CAACM,eAAe,EAAE0C,eAAe,CAAC;EAEzC,OAAO;IACLzB,MAAM;IACNC,MAAM;IACNyB,OAAO,EAAE5B,KAAK;IACdK,UAAU;IACVD,UAAU;IACVE,SAAS;IACTL,YAAY;IACZM;EACF,CAAC;AACH;AAEA,OAAO,SAASsB,OAAOA,CAAA,EAAG;EACxB,OAAOnD,MAAM,CAACO,eAAe,EAAE,IAAI,CAAC;AACtC"}
@@ -12,12 +12,12 @@ export function createI18nModule(options) {
12
12
  }
13
13
  export function useI18n() {
14
14
  const i18n = inject(YUYEON_I18N_KEY);
15
- if (!i18n) throw new Error('Not found provided "I18nModule"');
15
+ if (!i18n) throw new Error('【yuyeon】 Not found provided "I18nModule"');
16
16
  return i18n;
17
17
  }
18
18
  export function provideI18n(props) {
19
19
  const i18n = inject(YUYEON_I18N_KEY);
20
- if (!i18n) throw new Error('Not found provided "I18nModule"');
20
+ if (!i18n) throw new Error('【yuyeon】 Not found provided "I18nModule"');
21
21
  const locale = i18n.getContext(props);
22
22
  const rtl = createRtlProvideValue(locale, i18n.rtl, props);
23
23
  const state = {
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["inject","provide","createLocaleModule","createRtlModule","createRtlProvideValue","YUYEON_I18N_KEY","createI18nModule","options","localeModule","rtlModule","useI18n","i18n","Error","provideI18n","props","locale","getContext","rtl","state"],"sources":["../../../src/composables/i18n/index.ts"],"sourcesContent":["import {inject, provide} from 'vue';\r\n\r\nimport { LocaleModule, LocaleOptions } from '../../i18n/types';\r\nimport { createLocaleModule } from './locale';\r\nimport {\r\n RtlModule,\r\n RtlOptions,\r\n RtlProps,\r\n createRtlModule,\r\n createRtlProvideValue,\r\n} from './rtl';\r\nimport { YUYEON_I18N_KEY } from './share';\r\n\r\nexport function createI18nModule(options?: LocaleOptions & RtlOptions) {\r\n const localeModule = createLocaleModule(options);\r\n const rtlModule = createRtlModule(localeModule, options);\r\n\r\n return {\r\n localeModule,\r\n rtlModule,\r\n };\r\n}\r\n\r\nexport function useI18n(): LocaleModule & RtlModule {\r\n const i18n = inject<any>(YUYEON_I18N_KEY);\r\n if (!i18n) throw new Error('Not found provided \"I18nModule\"');\r\n return i18n;\r\n}\r\n\r\nexport function provideI18n(props: LocaleOptions & RtlProps) {\r\n const i18n = inject<any>(YUYEON_I18N_KEY);\r\n if (!i18n) throw new Error('Not found provided \"I18nModule\"');\r\n\r\n const locale = i18n.getContext(props);\r\n const rtl = createRtlProvideValue(locale, i18n.rtl, props);\r\n\r\n const state = {\r\n ...locale,\r\n ...rtl,\r\n };\r\n provide(YUYEON_I18N_KEY, state);\r\n\r\n return state;\r\n}\r\n"],"mappings":"AAAA,SAAQA,MAAM,EAAEC,OAAO,QAAO,KAAK;AAAC,SAG3BC,kBAAkB;AAAA,SAKzBC,eAAe,EACfC,qBAAqB;AAAA,SAEdC,eAAe;AAExB,OAAO,SAASC,gBAAgBA,CAACC,OAAoC,EAAE;EACrE,MAAMC,YAAY,GAAGN,kBAAkB,CAACK,OAAO,CAAC;EAChD,MAAME,SAAS,GAAGN,eAAe,CAACK,YAAY,EAAED,OAAO,CAAC;EAExD,OAAO;IACLC,YAAY;IACZC;EACF,CAAC;AACH;AAEA,OAAO,SAASC,OAAOA,CAAA,EAA6B;EAClD,MAAMC,IAAI,GAAGX,MAAM,CAAMK,eAAe,CAAC;EACzC,IAAI,CAACM,IAAI,EAAE,MAAM,IAAIC,KAAK,CAAC,iCAAiC,CAAC;EAC7D,OAAOD,IAAI;AACb;AAEA,OAAO,SAASE,WAAWA,CAACC,KAA+B,EAAE;EAC3D,MAAMH,IAAI,GAAGX,MAAM,CAAMK,eAAe,CAAC;EACzC,IAAI,CAACM,IAAI,EAAE,MAAM,IAAIC,KAAK,CAAC,iCAAiC,CAAC;EAE7D,MAAMG,MAAM,GAAGJ,IAAI,CAACK,UAAU,CAACF,KAAK,CAAC;EACrC,MAAMG,GAAG,GAAGb,qBAAqB,CAACW,MAAM,EAAEJ,IAAI,CAACM,GAAG,EAAEH,KAAK,CAAC;EAE1D,MAAMI,KAAK,GAAG;IACZ,GAAGH,MAAM;IACT,GAAGE;EACL,CAAC;EACDhB,OAAO,CAACI,eAAe,EAAEa,KAAK,CAAC;EAE/B,OAAOA,KAAK;AACd"}
1
+ {"version":3,"file":"index.mjs","names":["inject","provide","createLocaleModule","createRtlModule","createRtlProvideValue","YUYEON_I18N_KEY","createI18nModule","options","localeModule","rtlModule","useI18n","i18n","Error","provideI18n","props","locale","getContext","rtl","state"],"sources":["../../../src/composables/i18n/index.ts"],"sourcesContent":["import { inject, provide } from 'vue';\n\nimport { LocaleModule, LocaleOptions } from '../../i18n/types';\nimport { createLocaleModule } from './locale';\nimport {\n RtlModule,\n RtlOptions,\n RtlProps,\n createRtlModule,\n createRtlProvideValue,\n} from './rtl';\nimport { YUYEON_I18N_KEY } from './share';\n\nexport function createI18nModule(options?: LocaleOptions & RtlOptions) {\n const localeModule = createLocaleModule(options);\n const rtlModule = createRtlModule(localeModule, options);\n\n return {\n localeModule,\n rtlModule,\n };\n}\n\nexport function useI18n(): LocaleModule & RtlModule {\n const i18n = inject<any>(YUYEON_I18N_KEY);\n if (!i18n) throw new Error('【yuyeon】 Not found provided \"I18nModule\"');\n return i18n;\n}\n\nexport function provideI18n(props: LocaleOptions & RtlProps) {\n const i18n = inject<any>(YUYEON_I18N_KEY);\n if (!i18n) throw new Error('【yuyeon】 Not found provided \"I18nModule\"');\n\n const locale = i18n.getContext(props);\n const rtl = createRtlProvideValue(locale, i18n.rtl, props);\n\n const state = {\n ...locale,\n ...rtl,\n };\n provide(YUYEON_I18N_KEY, state);\n\n return state;\n}\n"],"mappings":"AAAA,SAASA,MAAM,EAAEC,OAAO,QAAQ,KAAK;AAAC,SAG7BC,kBAAkB;AAAA,SAKzBC,eAAe,EACfC,qBAAqB;AAAA,SAEdC,eAAe;AAExB,OAAO,SAASC,gBAAgBA,CAACC,OAAoC,EAAE;EACrE,MAAMC,YAAY,GAAGN,kBAAkB,CAACK,OAAO,CAAC;EAChD,MAAME,SAAS,GAAGN,eAAe,CAACK,YAAY,EAAED,OAAO,CAAC;EAExD,OAAO;IACLC,YAAY;IACZC;EACF,CAAC;AACH;AAEA,OAAO,SAASC,OAAOA,CAAA,EAA6B;EAClD,MAAMC,IAAI,GAAGX,MAAM,CAAMK,eAAe,CAAC;EACzC,IAAI,CAACM,IAAI,EAAE,MAAM,IAAIC,KAAK,CAAC,0CAA0C,CAAC;EACtE,OAAOD,IAAI;AACb;AAEA,OAAO,SAASE,WAAWA,CAACC,KAA+B,EAAE;EAC3D,MAAMH,IAAI,GAAGX,MAAM,CAAMK,eAAe,CAAC;EACzC,IAAI,CAACM,IAAI,EAAE,MAAM,IAAIC,KAAK,CAAC,0CAA0C,CAAC;EAEtE,MAAMG,MAAM,GAAGJ,IAAI,CAACK,UAAU,CAACF,KAAK,CAAC;EACrC,MAAMG,GAAG,GAAGb,qBAAqB,CAACW,MAAM,EAAEJ,IAAI,CAACM,GAAG,EAAEH,KAAK,CAAC;EAE1D,MAAMI,KAAK,GAAG;IACZ,GAAGH,MAAM;IACT,GAAGE;EACL,CAAC;EACDhB,OAAO,CAACI,eAAe,EAAEa,KAAK,CAAC;EAE/B,OAAOA,KAAK;AACd"}
@@ -1,7 +1,7 @@
1
1
  import { computed } from 'vue';
2
2
  import { pressItemsPropsOptions } from "../abstract/items.mjs";
3
3
  import { deepEqual, getPropertyFromItem } from "../util/common.mjs";
4
- import { propsFactory } from "../util/vue-component.mjs";
4
+ import { propsFactory } from "../util/component/index.mjs";
5
5
  const listItemsPropsOptions = {
6
6
  ...pressItemsPropsOptions({
7
7
  itemKey: 'value',
@@ -1 +1 @@
1
- {"version":3,"file":"list-items.mjs","names":["computed","pressItemsPropsOptions","deepEqual","getPropertyFromItem","propsFactory","listItemsPropsOptions","itemKey","itemChildren","returnItem","Boolean","pressListItemsPropsOptions","refineListItems","props","items","ret","item","push","refineListItem","hide","disabled","text","itemText","value","children","Array","isArray","undefined","raw","useItems","toRefineItems","values","filter","v","some","map","found","find","toEmitItems","_ref","_ref2"],"sources":["../../src/composables/list-items.ts"],"sourcesContent":["import type { ExtractPropTypes, Ref } from 'vue';\nimport { computed } from 'vue';\n\nimport { pressItemsPropsOptions } from '../abstract/items';\nimport { deepEqual, getPropertyFromItem } from '../util/common';\nimport { propsFactory } from '../util/vue-component';\n\nexport interface ListItem<T = any> {\n value: any;\n text: string;\n hide: boolean;\n disabled: boolean;\n props: {\n [key: string]: any;\n value: any;\n text: string;\n };\n children?: ListItem<T>[];\n raw: T;\n}\n\nconst listItemsPropsOptions = {\n ...pressItemsPropsOptions({\n itemKey: 'value',\n itemChildren: false,\n }),\n returnItem: Boolean,\n};\n\ntype ListItemProps = ExtractPropTypes<typeof listItemsPropsOptions>;\n\nexport const pressListItemsPropsOptions = propsFactory(\n listItemsPropsOptions,\n 'list-items',\n);\n\nexport function refineListItems(\n props: Omit<ListItemProps, 'items'>,\n items: any[],\n) {\n const ret: ListItem[] = [];\n for (const item of items) {\n ret.push(refineListItem(props, item));\n }\n return ret;\n}\n\nexport function refineListItem(\n props: Omit<ListItemProps, 'items'>,\n item: any,\n): ListItem {\n const hide = !!item?.hide;\n const disabled = !!item?.disabled;\n const text = getPropertyFromItem(item, props.itemText, item);\n const value = props.returnItem\n ? item\n : getPropertyFromItem(item, props.itemKey, text);\n const children = getPropertyFromItem(item, props.itemChildren);\n\n return {\n value,\n text,\n hide,\n disabled,\n props: {\n value,\n text,\n },\n children: Array.isArray(children)\n ? refineListItems(props, children)\n : undefined,\n raw: item,\n };\n}\n\nexport function useItems(props: ListItemProps) {\n const items = computed(() => refineListItems(props, props.items));\n\n function toRefineItems(values: any[]) {\n return values\n .filter(\n (v) => v !== null || items.value.some((item) => item.value === null),\n )\n .map((v) => {\n const found = items.value.find((item) => deepEqual(v, item.value));\n return found ?? refineListItem(props, v);\n });\n }\n\n function toEmitItems(items: any[]) {\n return props.returnItem\n ? items.map(({ raw }) => raw)\n : items.map(({ value }) => value);\n }\n\n return {\n items,\n toEmitItems,\n toRefineItems,\n };\n}\n"],"mappings":"AACA,SAASA,QAAQ,QAAQ,KAAK;AAAC,SAEtBC,sBAAsB;AAAA,SACtBC,SAAS,EAAEC,mBAAmB;AAAA,SAC9BC,YAAY;AAgBrB,MAAMC,qBAAqB,GAAG;EAC5B,GAAGJ,sBAAsB,CAAC;IACxBK,OAAO,EAAE,OAAO;IAChBC,YAAY,EAAE;EAChB,CAAC,CAAC;EACFC,UAAU,EAAEC;AACd,CAAC;AAID,OAAO,MAAMC,0BAA0B,GAAGN,YAAY,CACpDC,qBAAqB,EACrB,YACF,CAAC;AAED,OAAO,SAASM,eAAeA,CAC7BC,KAAmC,EACnCC,KAAY,EACZ;EACA,MAAMC,GAAe,GAAG,EAAE;EAC1B,KAAK,MAAMC,IAAI,IAAIF,KAAK,EAAE;IACxBC,GAAG,CAACE,IAAI,CAACC,cAAc,CAACL,KAAK,EAAEG,IAAI,CAAC,CAAC;EACvC;EACA,OAAOD,GAAG;AACZ;AAEA,OAAO,SAASG,cAAcA,CAC5BL,KAAmC,EACnCG,IAAS,EACC;EACV,MAAMG,IAAI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ACL,KAAK,EAAEoB,CAAC,CAAC;IAC1C,CAAC,CAAC;EACN;EAEA,SAASK,WAAWA,CAACxB,KAAY,EAAE;IACjC,OAAOD,KAAK,CAACJ,UAAU,GACnBK,KAAK,CAACqB,GAAG,CAACI,IAAA;MAAA,IAAC;QAAEX;MAAI,CAAC,GAAAW,IAAA;MAAA,OAAKX,GAAG;IAAA,EAAC,GAC3Bd,KAAK,CAACqB,GAAG,CAACK,KAAA;MAAA,IAAC;QAAEjB;MAAM,CAAC,GAAAiB,KAAA;MAAA,OAAKjB,KAAK;IAAA,EAAC;EACrC;EAEA,OAAO;IACLT,KAAK;IACLwB,WAAW;IACXR;EACF,CAAC;AACH"}
1
+ {"version":3,"file":"list-items.mjs","names":["computed","pressItemsPropsOptions","deepEqual","getPropertyFromItem","propsFactory","listItemsPropsOptions","itemKey","itemChildren","returnItem","Boolean","pressListItemsPropsOptions","refineListItems","props","items","ret","item","push","refineListItem","hide","disabled","text","itemText","value","children","Array","isArray","undefined","raw","useItems","toRefineItems","values","filter","v","some","map","found","find","toEmitItems","_ref","_ref2"],"sources":["../../src/composables/list-items.ts"],"sourcesContent":["import type { ExtractPropTypes, Ref } from 'vue';\r\nimport { computed } from 'vue';\r\n\r\nimport { pressItemsPropsOptions } from '../abstract/items';\r\nimport { deepEqual, getPropertyFromItem } from '../util/common';\r\nimport { propsFactory } from '../util/component';\r\n\r\nexport interface ListItem<T = any> {\r\n value: any;\r\n text: string;\r\n hide: boolean;\r\n disabled: boolean;\r\n props: {\r\n [key: string]: any;\r\n value: any;\r\n text: string;\r\n };\r\n children?: ListItem<T>[];\r\n raw: T;\r\n}\r\n\r\nconst listItemsPropsOptions = {\r\n ...pressItemsPropsOptions({\r\n itemKey: 'value',\r\n itemChildren: false,\r\n }),\r\n returnItem: Boolean,\r\n};\r\n\r\ntype ListItemProps = ExtractPropTypes<typeof listItemsPropsOptions>;\r\n\r\nexport const pressListItemsPropsOptions = propsFactory(\r\n listItemsPropsOptions,\r\n 'list-items',\r\n);\r\n\r\nexport function refineListItems(\r\n props: Omit<ListItemProps, 'items'>,\r\n items: any[],\r\n) {\r\n const ret: ListItem[] = [];\r\n for (const item of items) {\r\n ret.push(refineListItem(props, item));\r\n }\r\n return ret;\r\n}\r\n\r\nexport function refineListItem(\r\n props: Omit<ListItemProps, 'items'>,\r\n item: any,\r\n): ListItem {\r\n const hide = !!item?.hide;\r\n const disabled = !!item?.disabled;\r\n const text = getPropertyFromItem(item, props.itemText, item);\r\n const value = props.returnItem\r\n ? item\r\n : getPropertyFromItem(item, props.itemKey, text);\r\n const children = getPropertyFromItem(item, props.itemChildren);\r\n\r\n return {\r\n value,\r\n text,\r\n hide,\r\n disabled,\r\n props: {\r\n value,\r\n text,\r\n },\r\n children: Array.isArray(children)\r\n ? refineListItems(props, children)\r\n : undefined,\r\n raw: item,\r\n };\r\n}\r\n\r\nexport function useItems(props: ListItemProps) {\r\n const items = computed(() => refineListItems(props, props.items));\r\n\r\n function toRefineItems(values: any[]) {\r\n return values\r\n .filter(\r\n (v) => v !== null || items.value.some((item) => item.value === null),\r\n )\r\n .map((v) => {\r\n const found = items.value.find((item) => deepEqual(v, item.value));\r\n return found ?? refineListItem(props, v);\r\n });\r\n }\r\n\r\n function toEmitItems(items: any[]) {\r\n return props.returnItem\r\n ? items.map(({ raw }) => raw)\r\n : items.map(({ value }) => value);\r\n }\r\n\r\n return {\r\n items,\r\n toEmitItems,\r\n toRefineItems,\r\n };\r\n}\r\n"],"mappings":"AACA,SAASA,QAAQ,QAAQ,KAAK;AAAC,SAEtBC,sBAAsB;AAAA,SACtBC,SAAS,EAAEC,mBAAmB;AAAA,SAC9BC,YAAY;AAgBrB,MAAMC,qBAAqB,GAAG;EAC5B,GAAGJ,sBAAsB,CAAC;IACxBK,OAAO,EAAE,OAAO;IAChBC,YAAY,EAAE;EAChB,CAAC,CAAC;EACFC,UAAU,EAAEC;AACd,CAAC;AAID,OAAO,MAAMC,0BAA0B,GAAGN,YAAY,CACpDC,qBA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C,CAAC,IAAKA,CAAC,KAAK,IAAI,IAAInB,KAAK,CAACS,KAAK,CAACW,IAAI,CAAElB,IAAI,IAAKA,IAAI,CAACO,KAAK,KAAK,IAAI,CACrE,CAAC,CACAY,GAAG,CAAEF,CAAC,IAAK;MACV,MAAMG,KAAK,GAAGtB,KAAK,CAACS,KAAK,CAACc,IAAI,CAAErB,IAAI,IAAKb,SAAS,CAAC8B,CAAC,EAAEjB,IAAI,CAACO,KAAK,CAAC,CAAC;MAClE,OAAOa,KAAK,IAAIlB,cAAc,CAACL,KAAK,EAAEoB,CAAC,CAAC;IAC1C,CAAC,CAAC;EACN;EAEA,SAASK,WAAWA,CAACxB,KAAY,EAAE;IACjC,OAAOD,KAAK,CAACJ,UAAU,GACnBK,KAAK,CAACqB,GAAG,CAACI,IAAA;MAAA,IAAC;QAAEX;MAAI,CAAC,GAAAW,IAAA;MAAA,OAAKX,GAAG;IAAA,EAAC,GAC3Bd,KAAK,CAACqB,GAAG,CAACK,KAAA;MAAA,IAAC;QAAEjB;MAAM,CAAC,GAAAiB,KAAA;MAAA,OAAKjB,KAAK;IAAA,EAAC;EACrC;EAEA,OAAO;IACLT,KAAK;IACLwB,WAAW;IACXR;EACF,CAAC;AACH"}
@@ -1,7 +1,7 @@
1
1
  import { readonly, ref } from 'vue';
2
2
  import { onBeforeUnmount } from 'vue';
3
3
  import { watch } from 'vue';
4
- import { getHtmlElement } from "../util/vue-component.mjs";
4
+ import { getHtmlElement } from "../util/component/index.mjs";
5
5
  import Environments from "../util/environments.mjs";
6
6
  export function useResizeObserver(callback) {
7
7
  const resizeObservedRef = ref();
@@ -1 +1 @@
1
- {"version":3,"file":"resize-observer.mjs","names":["readonly","ref","onBeforeUnmount","watch","getHtmlElement","Environments","useResizeObserver","callback","resizeObservedRef","contentRect","canUseResizeObserver","observer","ResizeObserver","entries","length","value","disconnect","neo","old","unobserve","undefined","observe","flush"],"sources":["../../src/composables/resize-observer.ts"],"sourcesContent":["import { readonly, ref } from 'vue';\r\nimport { onBeforeUnmount } from 'vue';\r\nimport { watch } from 'vue';\r\n\r\nimport { getHtmlElement } from '../util/vue-component';\r\nimport Environments from '../util/environments';\r\n\r\nexport function useResizeObserver(callback?: ResizeObserverCallback) {\r\n const resizeObservedRef = ref<HTMLElement>();\r\n const contentRect = ref<DOMRectReadOnly>();\r\n if (Environments.canUseResizeObserver) {\r\n const observer = new ResizeObserver((entries, observer) => {\r\n callback?.(entries, observer);\r\n if (!entries.length) return;\r\n contentRect.value = entries[0].contentRect;\r\n });\r\n\r\n onBeforeUnmount(() => {\r\n observer.disconnect();\r\n });\r\n\r\n watch(\r\n resizeObservedRef,\r\n (neo, old) => {\r\n if (old) {\r\n observer.unobserve(getHtmlElement(old));\r\n contentRect.value = undefined;\r\n }\r\n if (neo) {\r\n observer.observe(getHtmlElement(neo));\r\n }\r\n },\r\n { flush: 'post' },\r\n );\r\n }\r\n\r\n return {\r\n resizeObservedRef,\r\n contentRect: readonly(contentRect),\r\n };\r\n}\r\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,GAAG,QAAQ,KAAK;AACnC,SAASC,eAAe,QAAQ,KAAK;AACrC,SAASC,KAAK,QAAQ,KAAK;AAAC,SAEnBC,cAAc;AAAA,OAChBC,YAAY;AAEnB,OAAO,SAASC,iBAAiBA,CAACC,QAAiC,EAAE;EACnE,MAAMC,iBAAiB,GAAGP,GAAG,CAAc,CAAC;EAC5C,MAAMQ,WAAW,GAAGR,GAAG,CAAkB,CAAC;EAC1C,IAAII,YAAY,CAACK,oBAAoB,EAAE;IACrC,MAAMC,QAAQ,GAAG,IAAIC,cAAc,CAAC,CAACC,OAAO,EAAEF,QAAQ,KAAK;MACzDJ,QAAQ,GAAGM,OAAO,EAAEF,QAAQ,CAAC;MAC7B,IAAI,CAACE,OAAO,CAACC,MAAM,EAAE;MACrBL,WAAW,CAACM,KAAK,GAAGF,OAAO,CAAC,CAAC,CAAC,CAACJ,WAAW;IAC5C,CAAC,CAAC;IAEFP,eAAe,CAAC,MAAM;MACpBS,QAAQ,CAACK,UAAU,CAAC,CAAC;IACvB,CAAC,CAAC;IAEFb,KAAK,CACDK,iBAAiB,EACjB,CAACS,GAAG,EAAEC,GAAG,KAAK;MACZ,IAAIA,GAAG,EAAE;QACPP,QAAQ,CAACQ,SAAS,CAACf,cAAc,CAACc,GAAG,CAAC,CAAC;QACvCT,WAAW,CAACM,KAAK,GAAGK,SAAS;MAC/B;MACA,IAAIH,GAAG,EAAE;QACPN,QAAQ,CAACU,OAAO,CAACjB,cAAc,CAACa,GAAG,CAAC,CAAC;MACvC;IACF,CAAC,EACD;MAAEK,KAAK,EAAE;IAAO,CACpB,CAAC;EACH;EAEA,OAAO;IACLd,iBAAiB;IACjBC,WAAW,EAAET,QAAQ,CAACS,WAAW;EACnC,CAAC;AACH"}
1
+ {"version":3,"file":"resize-observer.mjs","names":["readonly","ref","onBeforeUnmount","watch","getHtmlElement","Environments","useResizeObserver","callback","resizeObservedRef","contentRect","canUseResizeObserver","observer","ResizeObserver","entries","length","value","disconnect","neo","old","unobserve","undefined","observe","flush"],"sources":["../../src/composables/resize-observer.ts"],"sourcesContent":["import { readonly, ref } from 'vue';\r\nimport { onBeforeUnmount } from 'vue';\r\nimport { watch } from 'vue';\r\n\r\nimport { getHtmlElement } from '../util/component';\r\nimport Environments from '../util/environments';\r\n\r\nexport function useResizeObserver(callback?: ResizeObserverCallback) {\r\n const resizeObservedRef = ref<HTMLElement>();\r\n const contentRect = ref<DOMRectReadOnly>();\r\n if (Environments.canUseResizeObserver) {\r\n const observer = new ResizeObserver((entries, observer) => {\r\n callback?.(entries, observer);\r\n if (!entries.length) return;\r\n contentRect.value = entries[0].contentRect;\r\n });\r\n\r\n onBeforeUnmount(() => {\r\n observer.disconnect();\r\n });\r\n\r\n watch(\r\n resizeObservedRef,\r\n (neo, old) => {\r\n if (old) {\r\n observer.unobserve(getHtmlElement(old));\r\n contentRect.value = undefined;\r\n }\r\n if (neo) {\r\n observer.observe(getHtmlElement(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6 +1,6 @@
1
1
  import { computed, effectScope, getCurrentInstance, inject, provide, reactive, readonly, ref, unref, watch } from 'vue';
2
2
  import bindThemeClass from "../../directives/theme-class.mjs";
3
- import { propsFactory } from "../../util/vue-component.mjs";
3
+ import { propsFactory } from "../../util/component/index.mjs";
4
4
  import { createPalette, createThemes } from "./factory.mjs";
5
5
  import { cssClass, cssVariables } from "./helper.mjs";
6
6
  import { configureOptions } from "./setting.mjs";
@@ -181,7 +181,7 @@ export function useLocalTheme(props) {
181
181
  export function useTheme() {
182
182
  getCurrentInstance();
183
183
  const theme = inject(YUYEON_THEME_KEY, null);
184
- if (!theme) throw new Error('Not found provided "ThemeModule"');
184
+ if (!theme) throw new Error('【yuyeon】 Not found provided "ThemeModule"');
185
185
  return theme;
186
186
  }
187
187
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["computed","effectScope","getCurrentInstance","inject","provide","reactive","readonly","ref","unref","watch","bindThemeClass","propsFactory","createPalette","createThemes","cssClass","cssVariables","configureOptions","Y_THEME_PREFIX","YUYEON_THEME_KEY","Symbol","for","pressThemePropsOptions","theme","String","isDarkMode","window","matchMedia","matches","isSupportAutoScheme","media","createThemeModule","options","appMountedScope","config","scheme","themes","palette","supportedAutoMode","preferColorScheme","darkModeWatcher","mediaQueryList","value","currentColorScheme","currentThemeKey","computedThemes","Array","isArray","computedPalette","styles","separationId","separation","lines","push","themeKey","themeDefs","Object","entries","colors","variables","isDark","records","themeScheme","join","install","app","directive","styleEl","document","getElementById","updateStyleEl","immediate","el","createElement","type","id","cspNonce","setAttribute","head","appendChild","innerHTML","bindTheme","yuyeon","mql","addEventListener","neo","lightTheme","darkTheme","root","dataset","init","run","themeClasses","scope","instance","global","useLocalTheme","props","themeModule","Error","moduleTheme","newTheme","useTheme"],"sources":["../../../src/composables/theme/index.ts"],"sourcesContent":["import type { App, ComputedRef, PropType, Ref } from 'vue';\nimport {\n computed,\n effectScope,\n getCurrentInstance,\n inject,\n provide,\n reactive,\n readonly,\n ref,\n unref,\n watch,\n} from 'vue';\n\nimport bindThemeClass from '../../directives/theme-class';\nimport { propsFactory } from '../../util/vue-component';\nimport { createPalette, createThemes } from './factory';\nimport { cssClass, cssVariables } from './helper';\nimport { ThemeScheme, configureOptions } from './setting';\nimport type { ThemeOptions } from './types';\n\nexport type { ThemeOptions };\n\nexport const Y_THEME_PREFIX = 'y-theme';\n\nexport interface ThemeModuleInstance {\n scheme: Ref<keyof typeof ThemeScheme | 'auto'>;\n theme: Ref<[string, string?]>;\n // theme values(schemes) for colors & variables\n readonly themes: any;\n readonly global: {\n // currentThemeKeys: [lightThemeKey, darkThemeKey]\n // If used manually, fix the scheme to 'light' and have a [lightThemeKey] value.\n // Use the appropriate default theme scheme if it does not match the themeKey\n scheme: Ref<keyof typeof ThemeScheme | 'auto'>;\n theme: Ref<[string, string?]>;\n };\n /* computed */\n readonly currentThemeKey: Readonly<ComputedRef<string>>;\n readonly themeClasses: Readonly<ComputedRef<string | undefined>>;\n readonly computedThemes: Readonly<ComputedRef<any>>;\n readonly computedPalette: Readonly<ComputedRef<any>>;\n /* */\n readonly supportedAutoMode: Readonly<Ref<boolean>>;\n readonly preferColorScheme: Readonly<Ref<'light' | 'dark'>>;\n}\n\nexport const YUYEON_THEME_KEY = Symbol.for('yuyeon.theme');\n\nexport const pressThemePropsOptions = propsFactory(\n {\n theme: String as PropType<string>,\n },\n 'theme',\n);\n\nexport function isDarkMode() {\n return window.matchMedia('(prefers-color-scheme: dark)').matches;\n}\n\nexport function isSupportAutoScheme() {\n return window.matchMedia('(prefers-color-scheme)').media !== 'not all';\n}\n\nexport function createThemeModule(options: ThemeOptions) {\n const appMountedScope = effectScope();\n const config = reactive(configureOptions(options));\n const scheme = ref<string>(config.scheme);\n const theme = ref<[string, string]>(config.theme);\n const themes = ref(config.themes);\n const palette = ref(config.palette);\n const supportedAutoMode = ref(true);\n const preferColorScheme = ref('');\n\n function darkModeWatcher(\n mediaQueryList: MediaQueryListEvent | MediaQueryList,\n ) {\n preferColorScheme.value = mediaQueryList.matches ? 'dark' : 'light';\n }\n\n const currentColorScheme = computed<'light' | 'dark'>(() => {\n if (scheme.value === 'auto') {\n return preferColorScheme.value as 'light' | 'dark';\n }\n if (scheme.value === 'dark') {\n return 'dark';\n }\n return 'light';\n });\n\n const currentThemeKey = computed(() => {\n if (typeof theme.value === 'string') {\n if (theme.value in computedThemes) {\n return theme.value;\n }\n }\n if (Array.isArray(theme.value)) {\n return currentColorScheme.value === 'dark'\n ? theme.value?.[1] ?? 'dark'\n : theme.value?.[0] ?? 'light';\n }\n return currentColorScheme.value;\n });\n\n const computedPalette = computed(() => {\n return createPalette(palette.value);\n });\n\n const computedThemes = computed(() => {\n return createThemes(themes.value);\n });\n\n const styles = computed(() => {\n const separationId = config.separation ? `#${config.separation}` : '';\n const lines = [];\n lines.push(\n ...cssClass(':root', cssVariables(computedPalette.value, 'palette')),\n );\n for (const [themeKey, themeDefs] of Object.entries(computedThemes.value)) {\n const { colors, variables, isDark } = themeDefs;\n const records: Record<string, string> = {\n ...colors,\n ...variables,\n };\n // if (currentThemeKey.value === themeKey) {\n // lines.push(...cssClass(':root', cssVariables(records, 'theme')));\n // }\n const themeScheme = isDark ? 'dark' : 'light';\n if (scheme.value === 'auto') {\n lines.push(\n ...cssClass(\n `@media (prefers-color-scheme: ${themeScheme})`,\n cssClass(\n `${separationId}[data-theme-scheme='auto'][data-${themeScheme}-theme='${themeKey}']`,\n cssVariables(records, 'theme'),\n ),\n ),\n );\n } else {\n lines.push(\n ...cssClass(\n `${separationId}[data-theme-scheme='${themeScheme}'][data-${themeScheme}-theme='${themeKey}']`,\n cssVariables(records, 'theme'),\n ),\n );\n }\n\n lines.push(\n ...cssClass(`${separationId} .y-theme--${themeKey}`, cssVariables(records, 'theme')),\n );\n }\n return lines.join('');\n });\n\n function install(app: App) {\n app.directive('theme', bindThemeClass);\n\n let styleEl = document.getElementById('yuyeon-theme-palette' + `${config.separation ? '__' + config.separation : ''}`);\n\n watch(styles, updateStyleEl, { immediate: true });\n\n function updateStyleEl() {\n if (typeof document !== 'undefined' && !styleEl) {\n const el = document.createElement('style');\n el.type = 'text/css';\n el.id = 'yuyeon-theme-palette' + `${config.separation ? '__' + config.separation : ''}`;\n if (options?.cspNonce) el.setAttribute('nonce', options.cspNonce);\n styleEl = el;\n document.head.appendChild(styleEl);\n }\n if (styleEl) {\n styleEl.innerHTML = styles.value;\n }\n }\n }\n\n function bindTheme(yuyeon: any) {\n supportedAutoMode.value = isSupportAutoScheme();\n if (supportedAutoMode.value) {\n const mql = window.matchMedia('(prefers-color-scheme: dark)');\n darkModeWatcher(mql);\n mql.addEventListener('change' as 'change', darkModeWatcher);\n }\n watch(\n theme,\n (neo) => {\n const [lightTheme, darkTheme] = neo;\n yuyeon.root.dataset.lightTheme = lightTheme;\n yuyeon.root.dataset.darkTheme = darkTheme;\n },\n { immediate: true },\n );\n watch(\n scheme,\n (neo) => {\n yuyeon.root.setAttribute(\n 'data-theme-scheme',\n neo === 'auto' ? 'auto' : currentColorScheme.value,\n );\n },\n { immediate: true },\n );\n }\n\n function init(yuyeon: any) {\n appMountedScope.run(() => {\n bindTheme(yuyeon);\n });\n }\n\n const themeClasses = computed(() => `y-theme--${currentThemeKey.value}`);\n\n return {\n install,\n init,\n scope: appMountedScope,\n instance: {\n global: {\n scheme,\n theme,\n },\n themes,\n scheme,\n theme,\n currentThemeKey,\n themeClasses,\n computedThemes,\n computedPalette,\n supportedAutoMode: readonly(supportedAutoMode),\n preferColorScheme: readonly(preferColorScheme),\n },\n };\n}\n\nexport function useLocalTheme(props: { theme?: string }) {\n getCurrentInstance();\n\n const themeModule = inject<ThemeModuleInstance | null>(\n YUYEON_THEME_KEY,\n null,\n );\n\n if (!themeModule) throw new Error('Not found provided \"ThemeModule\"');\n\n const palette = themeModule.computedPalette;\n\n const currentThemeKey = computed<string>(() => {\n if (props.theme) {\n const moduleTheme = unref(themeModule.theme);\n switch (props.theme) {\n case 'light':\n return moduleTheme?.[0] ?? 'light';\n case 'dark':\n return moduleTheme?.[1] ?? 'dark';\n // TODO: props.theme(themeKey) validation in themes\n default:\n return props.theme;\n }\n }\n return unref(themeModule.currentThemeKey);\n });\n\n const themeClasses = computed(() => {\n return `y-theme--${currentThemeKey.value}`;\n });\n\n const newTheme: ThemeModuleInstance = {\n ...themeModule,\n currentThemeKey,\n themeClasses,\n };\n\n provide(YUYEON_THEME_KEY, newTheme);\n\n return newTheme;\n}\n\nexport function useTheme() {\n getCurrentInstance();\n\n const theme = inject<ThemeModuleInstance | null>(YUYEON_THEME_KEY, null);\n\n if (!theme) throw new Error('Not found provided \"ThemeModule\"');\n\n return theme;\n}\n"],"mappings":"AACA,SACEA,QAAQ,EACRC,WAAW,EACXC,kBAAkB,EAClBC,MAAM,EACNC,OAAO,EACPC,QAAQ,EACRC,QAAQ,EACRC,GAAG,EACHC,KAAK,EACLC,KAAK,QACA,KAAK;AAAC,OAENC,cAAc;AAAA,SACZC,YAAY;AAAA,SACZC,aAAa,EAAEC,YAAY;AAAA,SAC3BC,QAAQ,EAAEC,YAAY;AAAA,SACTC,gBAAgB;AAKtC,OAAO,MAAMC,cAAc,GAAG,SAAS;AAwBvC,OAAO,MAAMC,gBAAgB,GAAGC,MAAM,CAACC,GAAG,CAAC,cAAc,CAAC;AAE1D,OAAO,MAAMC,sBAAsB,GAAGV,YAAY,CAChD;EACEW,KAAK,EAAEC;AACT,CAAC,EACD,OACF,CAAC;AAED,OAAO,SAASC,UAAUA,CAAA,EAAG;EAC3B,OAAOC,MAAM,CAACC,UAAU,CAAC,8BAA8B,CAAC,CAACC,OAAO;AAClE;AAEA,OAAO,SAASC,mBAAmBA,CAAA,EAAG;EACpC,OAAOH,MAAM,CAACC,UAAU,CAAC,wBAAwB,CAAC,CAACG,KAAK,KAAK,SAAS;AACxE;AAEA,OAAO,SAASC,iBAAiBA,CAACC,OAAqB,EAAE;EACvD,MAAMC,eAAe,GAAG/B,WAAW,CAAC,CAAC;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C,OAAOA,QAAQ;AACjB;AAEA,OAAO,SAASC,QAAQA,CAAA,EAAG;EACzBnG,kBAAkB,CAAC,CAAC;EAEpB,MAAMoB,KAAK,GAAGnB,MAAM,CAA6Be,gBAAgB,EAAE,IAAI,CAAC;EAExE,IAAI,CAACI,KAAK,EAAE,MAAM,IAAI4E,KAAK,CAAC,kCAAkC,CAAC;EAE/D,OAAO5E,KAAK;AACd"}
1
+ {"version":3,"file":"index.mjs","names":["computed","effectScope","getCurrentInstance","inject","provide","reactive","readonly","ref","unref","watch","bindThemeClass","propsFactory","createPalette","createThemes","cssClass","cssVariables","configureOptions","Y_THEME_PREFIX","YUYEON_THEME_KEY","Symbol","for","pressThemePropsOptions","theme","String","isDarkMode","window","matchMedia","matches","isSupportAutoScheme","media","createThemeModule","options","appMountedScope","config","scheme","themes","palette","supportedAutoMode","preferColorScheme","darkModeWatcher","mediaQueryList","value","currentColorScheme","currentThemeKey","computedThemes","Array","isArray","computedPalette","styles","separationId","separation","lines","push","themeKey","themeDefs","Object","entries","colors","variables","isDark","records","themeScheme","join","install","app","directive","styleEl","document","getElementById","updateStyleEl","immediate","el","createElement","type","id","cspNonce","setAttribute","head","appendChild","innerHTML","bindTheme","yuyeon","mql","addEventListener","neo","lightTheme","darkTheme","root","dataset","init","run","themeClasses","scope","instance","global","useLocalTheme","props","themeModule","Error","moduleTheme","newTheme","useTheme"],"sources":["../../../src/composables/theme/index.ts"],"sourcesContent":["import type { App, ComputedRef, PropType, Ref } from 'vue';\r\nimport {\r\n computed,\r\n effectScope,\r\n getCurrentInstance,\r\n inject,\r\n provide,\r\n reactive,\r\n readonly,\r\n ref,\r\n unref,\r\n watch,\r\n} from 'vue';\r\n\r\nimport bindThemeClass from '../../directives/theme-class';\r\nimport { propsFactory } from '../../util/component';\r\nimport { createPalette, createThemes } from './factory';\r\nimport { cssClass, cssVariables } from './helper';\r\nimport { ThemeScheme, configureOptions } from './setting';\r\nimport type { ThemeOptions } from './types';\r\n\r\nexport type { ThemeOptions };\r\n\r\nexport const Y_THEME_PREFIX = 'y-theme';\r\n\r\nexport interface ThemeModuleInstance {\r\n scheme: Ref<keyof typeof ThemeScheme | 'auto'>;\r\n theme: Ref<[string, string?]>;\r\n // theme values(schemes) for colors & variables\r\n readonly themes: any;\r\n readonly global: {\r\n // currentThemeKeys: [lightThemeKey, darkThemeKey]\r\n // If used manually, fix the scheme to 'light' and have a [lightThemeKey] value.\r\n // Use the appropriate default theme scheme if it does not match the themeKey\r\n scheme: Ref<keyof typeof ThemeScheme | 'auto'>;\r\n theme: Ref<[string, string?]>;\r\n };\r\n /* computed */\r\n readonly currentThemeKey: Readonly<ComputedRef<string>>;\r\n readonly themeClasses: Readonly<ComputedRef<string | undefined>>;\r\n readonly computedThemes: Readonly<ComputedRef<any>>;\r\n readonly computedPalette: Readonly<ComputedRef<any>>;\r\n /* */\r\n readonly supportedAutoMode: Readonly<Ref<boolean>>;\r\n readonly preferColorScheme: Readonly<Ref<'light' | 'dark'>>;\r\n}\r\n\r\nexport const YUYEON_THEME_KEY = Symbol.for('yuyeon.theme');\r\n\r\nexport const pressThemePropsOptions = propsFactory(\r\n {\r\n theme: String as PropType<string>,\r\n },\r\n 'theme',\r\n);\r\n\r\nexport function isDarkMode() {\r\n return window.matchMedia('(prefers-color-scheme: dark)').matches;\r\n}\r\n\r\nexport function isSupportAutoScheme() {\r\n return window.matchMedia('(prefers-color-scheme)').media !== 'not all';\r\n}\r\n\r\nexport function createThemeModule(options: ThemeOptions) {\r\n const appMountedScope = effectScope();\r\n const config = reactive(configureOptions(options));\r\n const scheme = ref<string>(config.scheme);\r\n const theme = ref<[string, string]>(config.theme);\r\n const themes = ref(config.themes);\r\n const palette = ref(config.palette);\r\n const supportedAutoMode = ref(true);\r\n const preferColorScheme = ref('');\r\n\r\n function darkModeWatcher(\r\n mediaQueryList: MediaQueryListEvent | MediaQueryList,\r\n ) {\r\n preferColorScheme.value = mediaQueryList.matches ? 'dark' : 'light';\r\n }\r\n\r\n const currentColorScheme = computed<'light' | 'dark'>(() => {\r\n if (scheme.value === 'auto') {\r\n return preferColorScheme.value as 'light' | 'dark';\r\n }\r\n if (scheme.value === 'dark') {\r\n return 'dark';\r\n }\r\n return 'light';\r\n });\r\n\r\n const currentThemeKey = computed(() => {\r\n if (typeof theme.value === 'string') {\r\n if (theme.value in computedThemes) {\r\n return theme.value;\r\n }\r\n }\r\n if (Array.isArray(theme.value)) {\r\n return currentColorScheme.value === 'dark'\r\n ? theme.value?.[1] ?? 'dark'\r\n : theme.value?.[0] ?? 'light';\r\n }\r\n return currentColorScheme.value;\r\n });\r\n\r\n const computedPalette = computed(() => {\r\n return createPalette(palette.value);\r\n });\r\n\r\n const computedThemes = computed(() => {\r\n return createThemes(themes.value);\r\n });\r\n\r\n const styles = computed(() => {\r\n const separationId = config.separation ? `#${config.separation}` : '';\r\n const lines = [];\r\n lines.push(\r\n ...cssClass(':root', cssVariables(computedPalette.value, 'palette')),\r\n );\r\n for (const [themeKey, themeDefs] of Object.entries(computedThemes.value)) {\r\n const { colors, variables, isDark } = themeDefs;\r\n const records: Record<string, string> = {\r\n ...colors,\r\n ...variables,\r\n };\r\n // if (currentThemeKey.value === themeKey) {\r\n // lines.push(...cssClass(':root', cssVariables(records, 'theme')));\r\n // }\r\n const themeScheme = isDark ? 'dark' : 'light';\r\n if (scheme.value === 'auto') {\r\n lines.push(\r\n ...cssClass(\r\n `@media (prefers-color-scheme: ${themeScheme})`,\r\n cssClass(\r\n `${separationId}[data-theme-scheme='auto'][data-${themeScheme}-theme='${themeKey}']`,\r\n cssVariables(records, 'theme'),\r\n ),\r\n ),\r\n );\r\n } else {\r\n lines.push(\r\n ...cssClass(\r\n `${separationId}[data-theme-scheme='${themeScheme}'][data-${themeScheme}-theme='${themeKey}']`,\r\n cssVariables(records, 'theme'),\r\n ),\r\n );\r\n }\r\n\r\n lines.push(\r\n ...cssClass(`${separationId} .y-theme--${themeKey}`, cssVariables(records, 'theme')),\r\n );\r\n }\r\n return lines.join('');\r\n });\r\n\r\n function install(app: App) {\r\n app.directive('theme', bindThemeClass);\r\n\r\n let styleEl = document.getElementById('yuyeon-theme-palette' + `${config.separation ? '__' + config.separation : ''}`);\r\n\r\n watch(styles, updateStyleEl, { immediate: true });\r\n\r\n function updateStyleEl() {\r\n if (typeof document !== 'undefined' && !styleEl) {\r\n const el = document.createElement('style');\r\n el.type = 'text/css';\r\n el.id = 'yuyeon-theme-palette' + `${config.separation ? '__' + config.separation : ''}`;\r\n if (options?.cspNonce) el.setAttribute('nonce', options.cspNonce);\r\n styleEl = el;\r\n document.head.appendChild(styleEl);\r\n }\r\n if (styleEl) {\r\n styleEl.innerHTML = styles.value;\r\n }\r\n }\r\n }\r\n\r\n function bindTheme(yuyeon: any) {\r\n supportedAutoMode.value = isSupportAutoScheme();\r\n if (supportedAutoMode.value) {\r\n const mql = window.matchMedia('(prefers-color-scheme: dark)');\r\n darkModeWatcher(mql);\r\n mql.addEventListener('change' as 'change', darkModeWatcher);\r\n }\r\n watch(\r\n theme,\r\n (neo) => {\r\n const [lightTheme, darkTheme] = neo;\r\n yuyeon.root.dataset.lightTheme = lightTheme;\r\n yuyeon.root.dataset.darkTheme = darkTheme;\r\n },\r\n { immediate: true },\r\n );\r\n watch(\r\n scheme,\r\n (neo) => {\r\n yuyeon.root.setAttribute(\r\n 'data-theme-scheme',\r\n neo === 'auto' ? 'auto' : currentColorScheme.value,\r\n );\r\n },\r\n { immediate: true },\r\n );\r\n }\r\n\r\n function init(yuyeon: any) {\r\n appMountedScope.run(() => {\r\n bindTheme(yuyeon);\r\n });\r\n }\r\n\r\n const themeClasses = computed(() => `y-theme--${currentThemeKey.value}`);\r\n\r\n return {\r\n install,\r\n init,\r\n scope: appMountedScope,\r\n instance: {\r\n global: {\r\n scheme,\r\n theme,\r\n },\r\n themes,\r\n scheme,\r\n theme,\r\n currentThemeKey,\r\n themeClasses,\r\n computedThemes,\r\n computedPalette,\r\n supportedAutoMode: readonly(supportedAutoMode),\r\n preferColorScheme: readonly(preferColorScheme),\r\n },\r\n };\r\n}\r\n\r\nexport function useLocalTheme(props: { theme?: string }) {\r\n getCurrentInstance();\r\n\r\n const themeModule = inject<ThemeModuleInstance | null>(\r\n YUYEON_THEME_KEY,\r\n null,\r\n );\r\n\r\n if (!themeModule) throw new Error('Not found provided \"ThemeModule\"');\r\n\r\n const palette = themeModule.computedPalette;\r\n\r\n const currentThemeKey = computed<string>(() => {\r\n if (props.theme) {\r\n const moduleTheme = unref(themeModule.theme);\r\n switch (props.theme) {\r\n case 'light':\r\n return moduleTheme?.[0] ?? 'light';\r\n case 'dark':\r\n return moduleTheme?.[1] ?? 'dark';\r\n // TODO: props.theme(themeKey) validation in themes\r\n default:\r\n return props.theme;\r\n }\r\n }\r\n return unref(themeModule.currentThemeKey);\r\n });\r\n\r\n const themeClasses = computed(() => {\r\n return `y-theme--${currentThemeKey.value}`;\r\n });\r\n\r\n const newTheme: ThemeModuleInstance = {\r\n ...themeModule,\r\n currentThemeKey,\r\n themeClasses,\r\n };\r\n\r\n provide(YUYEON_THEME_KEY, newTheme);\r\n\r\n return newTheme;\r\n}\r\n\r\nexport function useTheme() {\r\n getCurrentInstance();\r\n\r\n const theme = inject<ThemeModuleInstance | null>(YUYEON_THEME_KEY, null);\r\n\r\n if (!theme) throw new Error('【yuyeon】 Not found provided \"ThemeModule\"');\r\n\r\n return theme;\r\n}\r\n"],"mappings":"AACA,SACEA,QAAQ,EACRC,WAAW,EACXC,kBAAkB,EAClBC,MAAM,EACNC,OAAO,EACPC,QAAQ,EACRC,QAAQ,EACRC,GAAG,EACHC,KAAK,EACLC,KAAK,QACA,KAAK;AAAC,OAENC,cAAc;AAAA,SACZC,YAAY;AAAA,SACZC,aAAa,EAAEC,YAAY;AAAA,SAC3BC,QAAQ,EAAEC,YAAY;AAAA,SACTC,gBAAgB;AAKtC,OAAO,MAAMC,cAAc,GAAG,SAAS;AAwBvC,OAAO,MAAMC,gBAAgB,GAAGC,MAAM,CAACC,GAAG,CAAC,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K,MAAM;UACT,OAAOA,WAAW,GAAG,CAAC,CAAC,IAAI,MAAM;QACnC;QACA;UACE,OAAOH,KAAK,CAAC1E,KAAK;MACtB;IACF;IACA,OAAOd,KAAK,CAACyF,WAAW,CAACtD,eAAe,CAAC;EAC3C,CAAC,CAAC;EAEF,MAAMgD,YAAY,GAAG3F,QAAQ,CAAC,MAAM;IAClC,OAAQ,YAAW2C,eAAe,CAACF,KAAM,EAAC;EAC5C,CAAC,CAAC;EAEF,MAAM2D,QAA6B,GAAG;IACpC,GAAGH,WAAW;IACdtD,eAAe;IACfgD;EACF,CAAC;EAEDvF,OAAO,CAACc,gBAAgB,EAAEkF,QAAQ,CAAC;EAEnC,OAAOA,QAAQ;AACjB;AAEA,OAAO,SAASC,QAAQA,CAAA,EAAG;EACzBnG,kBAAkB,CAAC,CAAC;EAEpB,MAAMoB,KAAK,GAAGnB,MAAM,CAA6Be,gBAAgB,EAAE,IAAI,CAAC;EAExE,IAAI,CAACI,KAAK,EAAE,MAAM,IAAI4E,KAAK,CAAC,2CAA2C,CAAC;EAExE,OAAO5E,KAAK;AACd"}
package/lib/index.mjs CHANGED
@@ -8,11 +8,14 @@ import { YUYEON_THEME_KEY, createThemeModule, useTheme } from "./composables/the
8
8
  import PlateWave from "./directives/plate-wave/index.mjs";
9
9
  import { YUYEON_LOGO } from "./etc/index.mjs"; //
10
10
  import "./styles/base.scss";
11
+ import { createDefaultsModule } from "./composables/defaults/index.mjs";
12
+ import { YUYEON_DEFAULTS_KEY } from "./composables/defaults/share.mjs";
11
13
  const defaultOptions = {
12
14
  credit: true
13
15
  };
14
16
  export function init() {
15
17
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultOptions;
18
+ const defaultsModule = createDefaultsModule(options?.defaults);
16
19
  const themeModule = createThemeModule(options?.theme);
17
20
  const i18nModule = createI18nModule(options?.i18n);
18
21
  const dateModule = createDateModule(options?.date, i18nModule.localeModule);
@@ -27,13 +30,15 @@ export function init() {
27
30
  ...i18nModule.localeModule,
28
31
  ...i18nModule.rtlModule
29
32
  },
30
- date: dateModule
33
+ date: dateModule,
34
+ defaults: defaultsModule
31
35
  });
32
36
  Object.keys(components).forEach(componentName => {
33
37
  const comp = components[componentName];
34
38
  if (typeof comp === 'object' && 'name' in comp) app.component(componentName, comp);
35
39
  });
36
40
  app.directive('plate-wave', PlateWave);
41
+ app.provide(YUYEON_DEFAULTS_KEY, defaultsModule);
37
42
  app.provide(YUYEON_THEME_KEY, themeModule.instance);
38
43
  app.provide(YUYEON_ICON_KEY, iconModule);
39
44
  app.provide(YUYEON_I18N_KEY, {
package/lib/index.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["getCurrentInstance","nextTick","reactive","components","YUYEON_DATE_KEY","YUYEON_DATE_OPTIONS_KEY","createDateModule","createI18nModule","YUYEON_I18N_KEY","YUYEON_ICON_KEY","createIconModule","YUYEON_THEME_KEY","createThemeModule","useTheme","PlateWave","YUYEON_LOGO","defaultOptions","credit","init","options","arguments","length","undefined","themeModule","theme","i18nModule","i18n","dateModule","date","localeModule","iconModule","icon","install","app","yuyeon","root","instance","rtlModule","Object","keys","forEach","componentName","comp","component","directive","provide","config","globalProperties","$yuyeon","_container","_instance","classList","add","setAttribute","console","log","unmount","mount","vm","scope","stop","useYuyeon","Error","appContext"],"sources":["../src/index.ts"],"sourcesContent":["import { Component, ComponentInternalInstance } from '@vue/runtime-core';\nimport type { App } from 'vue';\nimport { getCurrentInstance, nextTick, reactive } from 'vue';\n\nimport * as components from './components';\nimport {\n YUYEON_DATE_KEY,\n YUYEON_DATE_OPTIONS_KEY,\n createDateModule,\n} from './composables/date';\nimport { createI18nModule } from './composables/i18n';\nimport { YUYEON_I18N_KEY } from './composables/i18n/share';\nimport { YUYEON_ICON_KEY, createIconModule } from './composables/icon';\nimport {\n YUYEON_THEME_KEY,\n createThemeModule,\n useTheme,\n} from './composables/theme';\nimport PlateWave from './directives/plate-wave';\nimport { YUYEON_LOGO } from './etc';\n\n//\nimport './styles/base.scss';\n\nconst defaultOptions = {\n credit: true,\n};\n\ndeclare module 'vue' {\n interface ComponentCustomProperties {\n $yuyeon: any;\n }\n}\n\nexport function init(options: any = defaultOptions) {\n const themeModule = createThemeModule(options?.theme);\n const i18nModule = createI18nModule(options?.i18n);\n const dateModule = createDateModule(options?.date, i18nModule.localeModule);\n const iconModule = createIconModule(options?.icon);\n const install = (app: App): any => {\n themeModule.install(app);\n\n const yuyeon = reactive({\n app: null as ComponentInternalInstance | null,\n root: null as HTMLElement | null,\n theme: themeModule.instance,\n i18n: {\n ...i18nModule.localeModule,\n ...i18nModule.rtlModule,\n },\n date: dateModule,\n });\n\n Object.keys(components).forEach((componentName) => {\n const comp = components[componentName as keyof typeof components];\n if (typeof comp === 'object' && 'name' in comp)\n app.component(componentName, comp as Component);\n });\n\n app.directive('plate-wave', PlateWave);\n\n app.provide(YUYEON_THEME_KEY, themeModule.instance);\n app.provide(YUYEON_ICON_KEY, iconModule);\n app.provide(YUYEON_I18N_KEY, {\n ...i18nModule.localeModule,\n ...i18nModule.rtlModule,\n });\n app.provide(YUYEON_DATE_OPTIONS_KEY, dateModule.options);\n app.provide(YUYEON_DATE_KEY, dateModule.instance);\n\n app.config.globalProperties.$yuyeon = yuyeon;\n\n nextTick(() => {\n yuyeon.root = app._container;\n yuyeon.app = app._instance as any;\n if (yuyeon.root) {\n yuyeon.root.classList.add('y-root');\n yuyeon.root.setAttribute('data-y-root', '');\n themeModule.init(yuyeon);\n }\n });\n\n if (options?.credit) {\n console.log(YUYEON_LOGO);\n }\n const { unmount, mount } = app;\n app.mount = (...args) => {\n const vm = mount(...args);\n if (!yuyeon.app) {\n yuyeon.app = app._instance as any;\n }\n if (!yuyeon.root) {\n nextTick(() => {\n yuyeon.root = app._container;\n if (yuyeon.root) {\n yuyeon.root.classList.add('y-root');\n yuyeon.root.setAttribute('data-y-root', '');\n themeModule.init(yuyeon);\n }\n });\n }\n app.mount = mount;\n return vm;\n };\n app.unmount = () => {\n unmount();\n themeModule.scope.stop();\n app.unmount = unmount;\n };\n };\n\n return {\n install,\n };\n}\n\nexport function useYuyeon() {\n const vm = getCurrentInstance();\n if (!vm) throw new Error('[yuyeon] Called outside of setup context');\n\n return vm.appContext.config.globalProperties.$yuyeon;\n}\n\nexport { useTheme };\n"],"mappings":"AAEA,SAASA,kBAAkB,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,KAAK;AAAC,OAEtD,KAAKC,UAAU;AAAA,SAEpBC,eAAe,EACfC,uBAAuB,EACvBC,gBAAgB;AAAA,SAETC,gBAAgB;AAAA,SAChBC,eAAe;AAAA,SACfC,eAAe,EAAEC,gBAAgB;AAAA,SAExCC,gBAAgB,EAChBC,iBAAiB,EACjBC,QAAQ;AAAA,OAEHC,SAAS;AAAA,SACPC,WAAW,2BAEpB;AACA;AAEA,MAAMC,cAAc,GAAG;EACrBC,MAAM,EAAE;AACV,CAAC;AAQD,OAAO,SAASC,IAAIA,CAAA,EAAgC;EAAA,IAA/BC,OAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGJ,cAAc;EAChD,MAAMO,WAAW,GAAGX,iBAAiB,CAACO,OAAO,EAAEK,KAAK,CAAC;EACrD,MAAMC,UAAU,GAAGlB,gBAAgB,CAACY,OAAO,EAAEO,IAAI,CAAC;EAClD,MAAMC,UAAU,GAAGrB,gBAAgB,CAACa,OAAO,EAAES,IAAI,EAAEH,UAAU,CAACI,YAAY,CAAC;EAC3E,MAAMC,UAAU,GAAGpB,gBAAgB,CAACS,OAAO,EAAEY,IAAI,CAAC;EAClD,MAAMC,OAAO,GAAIC,GAAQ,IAAU;IACjCV,WAAW,CAACS,OAAO,CAACC,GAAG,CAAC;IAExB,MAAMC,MAAM,GAAGhC,QAAQ,CAAC;MACtB+B,GAAG,EAAE,IAAwC;MAC7CE,IAAI,EAAE,IAA0B;MAChCX,KAAK,EAAED,WAAW,CAACa,QAAQ;MAC3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C;EAEpE,OAAOJ,EAAE,CAACK,UAAU,CAACjB,MAAM,CAACC,gBAAgB,CAACC,OAAO;AACtD;AAEA,SAASnC,QAAQ"}
1
+ {"version":3,"file":"index.mjs","names":["getCurrentInstance","nextTick","reactive","components","YUYEON_DATE_KEY","YUYEON_DATE_OPTIONS_KEY","createDateModule","createI18nModule","YUYEON_I18N_KEY","YUYEON_ICON_KEY","createIconModule","YUYEON_THEME_KEY","createThemeModule","useTheme","PlateWave","YUYEON_LOGO","createDefaultsModule","YUYEON_DEFAULTS_KEY","defaultOptions","credit","init","options","arguments","length","undefined","defaultsModule","defaults","themeModule","theme","i18nModule","i18n","dateModule","date","localeModule","iconModule","icon","install","app","yuyeon","root","instance","rtlModule","Object","keys","forEach","componentName","comp","component","directive","provide","config","globalProperties","$yuyeon","_container","_instance","classList","add","setAttribute","console","log","unmount","mount","vm","scope","stop","useYuyeon","Error","appContext"],"sources":["../src/index.ts"],"sourcesContent":["import { Component, ComponentInternalInstance } from '@vue/runtime-core';\nimport type { App } from 'vue';\nimport { getCurrentInstance, nextTick, reactive } from 'vue';\n\nimport * as components from './components';\nimport {\n YUYEON_DATE_KEY,\n YUYEON_DATE_OPTIONS_KEY,\n createDateModule,\n} from './composables/date';\nimport { createI18nModule } from './composables/i18n';\nimport { YUYEON_I18N_KEY } from './composables/i18n/share';\nimport { YUYEON_ICON_KEY, createIconModule } from './composables/icon';\nimport {\n YUYEON_THEME_KEY,\n createThemeModule,\n useTheme,\n} from './composables/theme';\nimport PlateWave from './directives/plate-wave';\nimport { YUYEON_LOGO } from './etc';\n\n//\nimport './styles/base.scss';\nimport { createDefaultsModule } from './composables/defaults';\nimport { YUYEON_DEFAULTS_KEY } from './composables/defaults/share';\n\nconst defaultOptions = {\n credit: true,\n};\n\ndeclare module 'vue' {\n interface ComponentCustomProperties {\n $yuyeon: any;\n }\n}\n\nexport function init(options: any = defaultOptions) {\n const defaultsModule = createDefaultsModule(options?.defaults);\n const themeModule = createThemeModule(options?.theme);\n const i18nModule = createI18nModule(options?.i18n);\n const dateModule = createDateModule(options?.date, i18nModule.localeModule);\n const iconModule = createIconModule(options?.icon);\n const install = (app: App): any => {\n themeModule.install(app);\n\n const yuyeon = reactive({\n app: null as ComponentInternalInstance | null,\n root: null as HTMLElement | null,\n theme: themeModule.instance,\n i18n: {\n ...i18nModule.localeModule,\n ...i18nModule.rtlModule,\n },\n date: dateModule,\n defaults: defaultsModule,\n });\n\n Object.keys(components).forEach((componentName) => {\n const comp = components[componentName as keyof typeof components];\n if (typeof comp === 'object' && 'name' in comp)\n app.component(componentName, comp as Component);\n });\n\n app.directive('plate-wave', PlateWave);\n\n app.provide(YUYEON_DEFAULTS_KEY, defaultsModule);\n app.provide(YUYEON_THEME_KEY, themeModule.instance);\n app.provide(YUYEON_ICON_KEY, iconModule);\n app.provide(YUYEON_I18N_KEY, {\n ...i18nModule.localeModule,\n ...i18nModule.rtlModule,\n });\n app.provide(YUYEON_DATE_OPTIONS_KEY, dateModule.options);\n app.provide(YUYEON_DATE_KEY, dateModule.instance);\n\n app.config.globalProperties.$yuyeon = yuyeon;\n\n nextTick(() => {\n yuyeon.root = app._container;\n yuyeon.app = app._instance as any;\n if (yuyeon.root) {\n yuyeon.root.classList.add('y-root');\n yuyeon.root.setAttribute('data-y-root', '');\n themeModule.init(yuyeon);\n }\n });\n\n if (options?.credit) {\n console.log(YUYEON_LOGO);\n }\n const { unmount, mount } = app;\n app.mount = (...args) => {\n const vm = mount(...args);\n if (!yuyeon.app) {\n yuyeon.app = app._instance as any;\n }\n if (!yuyeon.root) {\n nextTick(() => {\n yuyeon.root = app._container;\n if (yuyeon.root) {\n yuyeon.root.classList.add('y-root');\n yuyeon.root.setAttribute('data-y-root', '');\n themeModule.init(yuyeon);\n }\n });\n }\n app.mount = mount;\n return vm;\n };\n app.unmount = () => {\n unmount();\n themeModule.scope.stop();\n app.unmount = unmount;\n };\n };\n\n return {\n install,\n };\n}\n\nexport function useYuyeon() {\n const vm = getCurrentInstance();\n if (!vm) throw new Error('[yuyeon] Called outside of setup context');\n\n return vm.appContext.config.globalProperties.$yuyeon;\n}\n\nexport { useTheme };\n"],"mappings":"AAEA,SAASA,kBAAkB,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,KAAK;AAAC,OAEtD,KAAKC,UAAU;AAAA,SAEpBC,eAAe,EACfC,uBAAuB,EACvBC,gBAAgB;AAAA,SAETC,gBAAgB;AAAA,SAChBC,eAAe;AAAA,SACfC,eAAe,EAAEC,gBAAgB;AAAA,SAExCC,gBAAgB,EAChBC,iBAAiB,EACjBC,QAAQ;AAAA,OAEHC,SAAS;AAAA,SACPC,WAAW,2BAEpB;AACA;AAA4B,SACnBC,oBAAoB;AAAA,SACpBC,mBAAmB;AAE5B,MAAMC,cAAc,GAAG;EACrBC,MAAM,EAAE;AACV,CAAC;AAQD,OAAO,SAASC,IAAIA,CAAA,EAAgC;EAAA,IAA/BC,OAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGJ,cAAc;EAChD,MAAMO,cAAc,GAAGT,oBAAoB,CAACK,OAAO,EAAEK,QAAQ,CAAC;EAC9D,MAAMC,WAAW,GAAGf,iBAAiB,CAACS,OAAO,EAAEO,KAAK,CAAC;EACrD,MAAMC,UAAU,GAAGtB,gBAAgB,CAACc,OAAO,EAAES,IAAI,CAAC;EAClD,MAAMC,UAAU,GAAGzB,gBAAgB,CAACe,OAAO,EAAEW,IAAI,EAAEH,UAAU,CAACI,YAAY,CAAC;EAC3E,MAAMC,UAAU,GAAGxB,gBAAgB,CAACW,OAAO,EAAEc,IAAI,CAAC;EAClD,MAAMC,OAAO,GAAIC,GAAQ,IAAU;IACjCV,WAAW,CAACS,OAAO,CAACC,GAAG,CAAC;IAExB,MAAMC,MAAM,GAAGpC,QAAQ,CAAC;MACtBmC,GAAG,EAAE,IAAwC;MAC7CE,IAAI,EAAE,IAA0B;MAChCX,KAAK,EAAED,WAAW,CAACa,QAAQ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H,EAAE,GAAG9D,kBAAkB,CAAC,CAAC;EAC/B,IAAI,CAAC8D,EAAE,EAAE,MAAM,IAAII,KAAK,CAAC,0CAA0C,CAAC;EAEpE,OAAOJ,EAAE,CAACK,UAAU,CAACjB,MAAM,CAACC,gBAAgB,CAACC,OAAO;AACtD;AAEA,SAASvC,QAAQ"}
@@ -0,0 +1,21 @@
1
+ import { useDefaultsModule, useSuperDefaults } from "../../composables/defaults/index.mjs"; // overload 2: defineComponent with options object, infer props from options
2
+ function redefineComponent(options) {
3
+ options._setup = options._setup ?? options.setup;
4
+ if (options._setup) {
5
+ options.setup = function (props, ctx) {
6
+ const defaults = useDefaultsModule();
7
+ // Skip props proxy if defaults are not provided
8
+ if (!defaults.value) return options._setup(props, ctx);
9
+ const {
10
+ props: _props,
11
+ provideSubDefaults
12
+ } = useSuperDefaults(props, options.name, defaults);
13
+ const setupBindings = options._setup(_props, ctx);
14
+ provideSubDefaults();
15
+ return setupBindings;
16
+ };
17
+ }
18
+ return options;
19
+ }
20
+ export { redefineComponent as defineComponent };
21
+ //# sourceMappingURL=component.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.mjs","names":["useDefaultsModule","useSuperDefaults","redefineComponent","options","_setup","setup","props","ctx","defaults","value","_props","provideSubDefaults","name","setupBindings","defineComponent"],"sources":["../../../src/util/component/component.ts"],"sourcesContent":["import { ComponentOptionsWithObjectProps, defineComponent } from 'vue';\nimport type {\n Component,\n ComponentInjectOptions,\n ComponentOptions,\n ComponentOptionsMixin,\n ComponentPropsOptions,\n ComponentProvideOptions,\n ComputedOptions,\n DefineComponent,\n Directive,\n EmitsOptions,\n MethodOptions,\n SlotsType,\n} from 'vue';\n\nimport {\n useDefaultsModule,\n useSuperDefaults,\n} from '../../composables/defaults';\nimport { ComponentTypeEmits, EmitsToProps, TypeEmitsToOptions } from './types';\n\ntype ToResolvedProps<Props, Emits extends EmitsOptions> = Readonly<Props> &\n Readonly<EmitsToProps<Emits>>;\n\n// overload 2: defineComponent with options object, infer props from options\nfunction redefineComponent<\n // props\n PropsOptions extends Readonly<ComponentPropsOptions>,\n //\n RawBindings,\n // emits\n E extends EmitsOptions = {},\n EE extends string = string,\n // other options\n Data = {},\n SetupBindings = {},\n Computed extends ComputedOptions = {},\n Methods extends MethodOptions = {},\n Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,\n Extends extends ComponentOptionsMixin = ComponentOptionsMixin,\n InjectOptions extends ComponentInjectOptions = {},\n InjectKeys extends string = string,\n Slots extends SlotsType = {},\n LocalComponents extends Record<string, Component> = {},\n Directives extends Record<string, Directive> = {},\n Exposed extends string = string,\n Provide extends ComponentProvideOptions = ComponentProvideOptions,\n>(\n options: ComponentOptionsWithObjectProps<\n PropsOptions,\n RawBindings,\n Data,\n Computed,\n Methods,\n Mixin,\n Extends,\n E,\n EE,\n InjectOptions,\n InjectKeys,\n Slots\n >,\n): DefineComponent<\n PropsOptions,\n RawBindings,\n Data,\n Computed,\n Methods,\n Mixin,\n Extends,\n E,\n EE\n>;\n\nfunction redefineComponent(options: ComponentOptions) {\n options._setup = options._setup ?? options.setup;\n\n if (options._setup) {\n options.setup = function (props, ctx) {\n const defaults = useDefaultsModule();\n // Skip props proxy if defaults are not provided\n if (!defaults.value) return options._setup(props, ctx);\n\n const { props: _props, provideSubDefaults } = useSuperDefaults(\n props,\n options.name,\n defaults,\n );\n\n const setupBindings = options._setup(_props, ctx);\n\n provideSubDefaults();\n\n return setupBindings;\n };\n }\n\n return options;\n}\n\nexport { redefineComponent as defineComponent };\n"],"mappings":"SAiBEA,iBAAiB,EACjBC,gBAAgB,gDAOlB;AAkDA,SAASC,iBAAiBA,CAACC,OAAyB,EAAE;EACpDA,OAAO,CAACC,MAAM,GAAGD,OAAO,CAACC,MAAM,IAAID,OAAO,CAACE,KAAK;EAEhD,IAAIF,OAAO,CAACC,MAAM,EAAE;IAClBD,OAAO,CAACE,KAAK,GAAG,UAAUC,KAAK,EAAEC,GAAG,EAAE;MACpC,MAAMC,QAAQ,GAAGR,iBAAiB,CAAC,CAAC;MACpC;MACA,IAAI,CAACQ,QAAQ,CAACC,KAAK,EAAE,OAAON,OAAO,CAACC,MAAM,CAACE,KAAK,EAAEC,GAAG,CAAC;MAEtD,MAAM;QAAED,KAAK,EAAEI,MAAM;QAAEC;MAAmB,CAAC,GAAGV,gBAAgB,CAC5DK,KAAK,EACLH,OAAO,CAACS,IAAI,EACZJ,QACF,CAAC;MAED,MAAMK,aAAa,GAAGV,OAAO,CAACC,MAAM,CAACM,MAAM,EAAEH,GAAG,CAAC;MAEjDI,kBAAkB,CAAC,CAAC;MAEpB,OAAOE,aAAa;IACtB,CAAC;EACH;EAEA,OAAOV,OAAO;AAChB;AAEA,SAASD,iBAAiB,IAAIY,eAAe"}
@@ -0,0 +1,64 @@
1
+ import { getCurrentInstance } from 'vue';
2
+ export * from "./props.mjs";
3
+ export * from "./component.mjs";
4
+ export function getSlot(vm) {
5
+ let name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
6
+ let data = arguments.length > 2 ? arguments[2] : undefined;
7
+ let optional = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
8
+ if (vm.$slots?.[name]) {
9
+ const slot = vm.$slots[name](data instanceof Function ? data() : data);
10
+ return slot.filter(node => {
11
+ return node.el?.nodeType !== 8;
12
+ });
13
+ }
14
+ return undefined;
15
+ }
16
+ export function getUid() {
17
+ const vm = getCurrentInstance();
18
+ return vm?.uid;
19
+ }
20
+ export function bindClasses(classes) {
21
+ const boundClasses = {};
22
+ if (typeof classes === 'string') {
23
+ boundClasses[classes] = true;
24
+ } else if (Array.isArray(classes)) {
25
+ classes.reduce((acc, clas) => {
26
+ acc[clas] = true;
27
+ return acc;
28
+ }, boundClasses);
29
+ } else if (typeof classes === 'object') {
30
+ Object.keys(classes).reduce((acc, clas) => {
31
+ acc[clas] = !!classes[clas];
32
+ return acc;
33
+ }, boundClasses);
34
+ }
35
+ return boundClasses;
36
+ }
37
+ export function getHtmlElement(node) {
38
+ if (node && '$el' in node) {
39
+ const el = node.$el;
40
+ if (el.nodeType === Node.TEXT_NODE) {
41
+ return el.nextElementSibling;
42
+ }
43
+ return el;
44
+ }
45
+ return node;
46
+ }
47
+ export function findChildrenWithProvide(key, vnode) {
48
+ if (!vnode || typeof vnode !== 'object') {
49
+ return [];
50
+ }
51
+ if (Array.isArray(vnode)) {
52
+ return vnode.map(child => findChildrenWithProvide(key, child)).flat(1);
53
+ } else if (Array.isArray(vnode.children)) {
54
+ return vnode.children.map(child => findChildrenWithProvide(key, child)).flat(1);
55
+ } else if (vnode.component) {
56
+ if (Object.getOwnPropertySymbols(vnode.component.provides).includes(key)) {
57
+ return [vnode.component];
58
+ } else if (vnode.component.subTree) {
59
+ return findChildrenWithProvide(key, vnode.component.subTree).flat(1);
60
+ }
61
+ }
62
+ return [];
63
+ }
64
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["getCurrentInstance","getSlot","vm","name","arguments","length","undefined","data","optional","$slots","slot","Function","filter","node","el","nodeType","getUid","uid","bindClasses","classes","boundClasses","Array","isArray","reduce","acc","clas","Object","keys","getHtmlElement","$el","Node","TEXT_NODE","nextElementSibling","findChildrenWithProvide","key","vnode","map","child","flat","children","component","getOwnPropertySymbols","provides","includes","subTree"],"sources":["../../../src/util/component/index.ts"],"sourcesContent":["import { ComponentInternalInstance } from '@vue/runtime-core';\r\nimport type {\r\n ComponentPublicInstance,\r\n InjectionKey,\r\n VNode,\r\n VNodeChild,\r\n} from 'vue';\r\nimport { getCurrentInstance } from 'vue';\r\n\r\nexport { type EventProp } from './types';\r\nexport * from './props';\r\nexport * from './component';\r\n\r\nexport function getSlot(\r\n vm: ComponentPublicInstance | any,\r\n // eslint-disable-next-line default-param-last\r\n name = 'default',\r\n data?: any | (() => any),\r\n optional = false,\r\n): VNode[] | undefined {\r\n if (vm.$slots?.[name]) {\r\n const slot = vm.$slots[name]!(data instanceof Function ? data() : data);\r\n return slot.filter((node: VNode) => {\r\n return node.el?.nodeType !== 8;\r\n });\r\n }\r\n return undefined;\r\n}\r\n\r\nexport function getUid() {\r\n const vm = getCurrentInstance();\r\n return vm?.uid;\r\n}\r\n\r\nexport function bindClasses(\r\n classes: string | string[] | Record<string, any> | undefined,\r\n) {\r\n const boundClasses = {} as Record<string, boolean>;\r\n if (typeof classes === 'string') {\r\n boundClasses[classes] = true;\r\n } else if (Array.isArray(classes)) {\r\n (classes as string[]).reduce((acc, clas) => {\r\n acc[clas] = true;\r\n return acc;\r\n }, boundClasses);\r\n } else if (typeof classes === 'object') {\r\n Object.keys(classes).reduce((acc, clas) => {\r\n acc[clas] = !!classes[clas];\r\n return acc;\r\n }, boundClasses);\r\n }\r\n return boundClasses;\r\n}\r\n\r\nexport function getHtmlElement<N extends object | undefined>(\r\n node: N,\r\n): Exclude<N, ComponentPublicInstance> | HTMLElement {\r\n if (node && '$el' in node) {\r\n const el = (node as ComponentPublicInstance).$el as HTMLElement;\r\n if (el.nodeType === Node.TEXT_NODE) {\r\n return el.nextElementSibling as HTMLElement;\r\n }\r\n return el;\r\n }\r\n return node as HTMLElement;\r\n}\r\n\r\nexport function findChildrenWithProvide(\r\n key: InjectionKey<any> | symbol,\r\n vnode?: VNodeChild,\r\n): ComponentInternalInstance[] {\r\n if (!vnode || typeof vnode !== 'object') {\r\n return [];\r\n }\r\n\r\n if (Array.isArray(vnode)) {\r\n return vnode.map((child) => findChildrenWithProvide(key, child)).flat(1);\r\n } else if (Array.isArray(vnode.children)) {\r\n return vnode.children\r\n .map((child) => findChildrenWithProvide(key, child))\r\n .flat(1);\r\n } else if (vnode.component) {\r\n if (\r\n Object.getOwnPropertySymbols((vnode.component as any).provides).includes(\r\n key as symbol,\r\n )\r\n ) {\r\n return [vnode.component];\r\n } else if (vnode.component.subTree) {\r\n return findChildrenWithProvide(key, vnode.component.subTree).flat(1);\r\n }\r\n }\r\n\r\n return [];\r\n}\r\n"],"mappings":"AAOA,SAASA,kBA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,CAACe,qBAAqB,CAAEN,KAAK,CAACK,SAAS,CAASE,QAAQ,CAAC,CAACC,QAAQ,CACtET,GACF,CAAC,EACD;MACA,OAAO,CAACC,KAAK,CAACK,SAAS,CAAC;IAC1B,CAAC,MAAM,IAAIL,KAAK,CAACK,SAAS,CAACI,OAAO,EAAE;MAClC,OAAOX,uBAAuB,CAACC,GAAG,EAAEC,KAAK,CAACK,SAAS,CAACI,OAAO,CAAC,CAACN,IAAI,CAAC,CAAC,CAAC;IACtE;EACF;EAEA,OAAO,EAAE;AACX"}
@@ -0,0 +1,10 @@
1
+ import { getCurrentInstance } from 'vue';
2
+ export function injectSelf(key) {
3
+ let vm = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getCurrentInstance();
4
+ const provides = vm?.provides;
5
+ if (provides && key in provides) {
6
+ return provides[key];
7
+ }
8
+ return undefined;
9
+ }
10
+ //# sourceMappingURL=inject-self.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inject-self.mjs","names":["getCurrentInstance","injectSelf","key","vm","arguments","length","undefined","provides"],"sources":["../../../src/util/component/inject-self.ts"],"sourcesContent":["import { getCurrentInstance, InjectionKey, ComponentInternalInstance } from 'vue';\r\n\r\nexport function injectSelf<T>(key: InjectionKey<T> | string, vm?: ComponentInternalInstance): T | undefined\r\nexport function injectSelf (key: InjectionKey<any> | string, vm = getCurrentInstance()) {\r\n const provides = vm?.provides;\r\n\r\n if (provides && (key as string | symbol) in provides) {\r\n return provides[key as string]\r\n }\r\n\r\n return undefined\r\n}\r\n"],"mappings":"AAAA,SAASA,kBAAkB,QAAiD,KAAK;AAGjF,OAAO,SAASC,UAAUA,CAAEC,GAA+B,EAA6B;EAAA,IAA3BC,EAAE,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGJ,kBAAkB,CAAC,CAAC;EACpF,MAAMO,QAAQ,GAAGJ,EAAE,EAAEI,QAAQ;EAE7B,IAAIA,QAAQ,IAAKL,GAAG,IAAwBK,QAAQ,EAAE;IACpD,OAAOA,QAAQ,CAACL,GAAG,CAAW;EAChC;EAEA,OAAOI,SAAS;AAClB"}
@@ -0,0 +1,41 @@
1
+ import { capitalize } from '@vue/runtime-core';
2
+ import { toKebabCase } from "../string.mjs";
3
+ export function propsFactory(props, source) {
4
+ return defaults => {
5
+ return Object.keys(props).reduce((options, prop) => {
6
+ const option = props[prop];
7
+ const isObjectOption = typeof option === 'object' && option != null && !Array.isArray(option);
8
+ const objectOption = isObjectOption ? option : {
9
+ type: option
10
+ };
11
+ if (defaults && prop in defaults) {
12
+ options[prop] = {
13
+ ...objectOption,
14
+ default: defaults[prop]
15
+ };
16
+ } else {
17
+ options[prop] = objectOption;
18
+ }
19
+ if (source && !options[prop].source) {
20
+ options[prop].source = source;
21
+ }
22
+ return options;
23
+ }, {});
24
+ };
25
+ }
26
+ export function chooseProps(props, target) {
27
+ return Object.keys(target).reduce((acc, prop) => {
28
+ if (props && prop in props) {
29
+ acc[prop] = props[prop];
30
+ }
31
+ return acc;
32
+ }, {});
33
+ }
34
+ export function hasEventProp(props, type) {
35
+ const onType = `on${capitalize(type)}`;
36
+ return !!(props[onType] || props[`${onType}Once`] || props[`${onType}Capture`] || props[`${onType}OnceCapture`] || props[`${onType}CaptureOnce`]);
37
+ }
38
+ export function propIsDefined(vnode, prop) {
39
+ return typeof vnode.props?.[prop] !== 'undefined' || typeof vnode.props?.[toKebabCase(prop)] !== 'undefined';
40
+ }
41
+ //# sourceMappingURL=props.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"props.mjs","names":["capitalize","toKebabCase","propsFactory","props","source","defaults","Object","keys","reduce","options","prop","option","isObjectOption","Array","isArray","objectOption","type","default","chooseProps","target","acc","hasEventProp","onType","propIsDefined","vnode"],"sources":["../../../src/util/component/props.ts"],"sourcesContent":["import { capitalize } from '@vue/runtime-core';\nimport type { IfAny } from '@vue/shared';\nimport type {\n ComponentObjectPropsOptions,\n ExtractPropTypes,\n Prop,\n PropType,\n VNode,\n} from 'vue';\n\nimport { toKebabCase } from '../string';\n\nexport function propsFactory<PropsOptions extends ComponentObjectPropsOptions>(\n props: PropsOptions,\n source: string,\n) {\n return <Defaults extends PartialKeys<PropsOptions> = {}>(\n defaults?: Defaults,\n ): OverwrittenPropOptions<PropsOptions, Defaults> => {\n return Object.keys(props).reduce<any>((options, prop) => {\n const option = props[prop];\n const isObjectOption =\n typeof option === 'object' && option != null && !Array.isArray(option);\n const objectOption = isObjectOption ? option : { type: option };\n if (defaults && prop in defaults) {\n options[prop] = {\n ...objectOption,\n default: defaults[prop],\n };\n } else {\n options[prop] = objectOption;\n }\n\n if (source && !options[prop].source) {\n options[prop].source = source;\n }\n return options;\n }, {} as PropsOptions);\n };\n}\n\nexport function chooseProps<PropsOptions extends ComponentObjectPropsOptions>(\n props: any,\n target: PropsOptions,\n): ExtractPropTypes<PropsOptions> {\n return Object.keys(target).reduce((acc, prop) => {\n if (props && prop in props) {\n acc[prop as keyof ExtractPropTypes<PropsOptions>] = props[prop];\n }\n return acc;\n }, {} as ExtractPropTypes<PropsOptions>);\n}\n\nexport function hasEventProp(props: Record<string, any>, type: string) {\n const onType = `on${capitalize(type)}`;\n return !!(\n props[onType] ||\n props[`${onType}Once`] ||\n props[`${onType}Capture`] ||\n props[`${onType}OnceCapture`] ||\n props[`${onType}CaptureOnce`]\n );\n}\n\nexport function propIsDefined(vnode: VNode, prop: string) {\n return (\n typeof vnode.props?.[prop] !== 'undefined' ||\n typeof vnode.props?.[toKebabCase(prop)] !== 'undefined'\n );\n}\n\ntype OverwrittenPropOptions<\n T extends ComponentObjectPropsOptions,\n D extends PartialKeys<T>,\n> = {\n [P in keyof T]-?: unknown extends D[P]\n ? T[P]\n : T[P] extends Record<string, unknown>\n ? Omit<T[P], 'type' | 'default'> & {\n type: PropType<MergeDefault<T[P], D[P]>>;\n default: MergeDefault<T[P], D[P]>;\n }\n : {\n type: PropType<MergeDefault<T[P], D[P]>>;\n default: MergeDefault<T[P], D[P]>;\n };\n};\n\ntype MergeDefault<T, D> = unknown extends D\n ? InferPropType<T>\n : NonNullable<InferPropType<T>> | D;\n\ntype FollowPropType<T, P, D> = [T] extends [PropType<unknown>]\n ? T\n : PropType<MergeDefault<P, D>>;\n\ntype PartialKeys<T> = { [P in keyof T]?: unknown };\n\ntype InferPropType<T> = [T] extends [null]\n ? any // null & true would fail to infer\n : [T] extends [{ type: null | true }]\n ? // As TS issue https://github.com/Microsoft/TypeScript/issues/14829\n // somehow `ObjectConstructor` when inferred from { (): T } becomes `any`\n // `BooleanConstructor` when inferred from PropConstructor(with PropMethod) becomes `Boolean`\n any\n : [T] extends [ObjectConstructor | { type: ObjectConstructor }]\n ? Record<string, any>\n : [T] extends [BooleanConstructor | { type: BooleanConstructor }]\n ? boolean\n : [T] extends [DateConstructor | { type: DateConstructor }]\n ? Date\n : [T] extends [(infer U)[] | { type: (infer U)[] }]\n ? U extends DateConstructor\n ? Date | InferPropType<U>\n : InferPropType<U>\n : [T] extends [Prop<infer V, infer D>]\n ? unknown extends V\n ? IfAny<V, V, D>\n : V\n : T;\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,mBAAmB;AAAC,SAUtCC,WAAW;AAEpB,OAAO,SAASC,YAAYA,CAC1BC,KAAmB,EACnBC,MAAc,EACd;EACA,OACEC,QAAmB,IACgC;IACnD,OAAOC,MAAM,CAACC,IAAI,CAACJ,KAAK,CAAC,CAACK,MAAM,CAAM,CAACC,OAAO,EAAEC,IAAI,KAAK;MACvD,MAAMC,MAAM,GAAGR,KAAK,CAACO,IAAI,CAAC;MAC1B,MAAME,cAAc,GAClB,OAAOD,MAAM,KAAK,QAAQ,IAAIA,MAAM,IAAI,IAAI,IAAI,CAACE,KAAK,CAACC,OAAO,CAACH,MAAM,CAAC;MACxE,MAAMI,YAAY,GAAGH,cAAc,GAAGD,MAAM,GAAG;QAAEK,IAAI,EAAEL;MAAO,CAAC;MAC/D,IAAIN,QAAQ,IAAIK,IAAI,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C,KAAK,WAAW,IAC1C,OAAOc,KAAK,CAACrB,KAAK,GAAGF,WAAW,CAACS,IAAI,CAAC,CAAC,KAAK,WAAW;AAE3D"}
@@ -0,0 +1,2 @@
1
+ export const EventPropOption = () => [Function, Array];
2
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.mjs","names":["EventPropOption","Function","Array"],"sources":["../../../src/util/component/types.ts"],"sourcesContent":["import type { EmitsOptions, ObjectEmitsOptions, PropType } from 'vue';\r\n\r\nexport type EventProp<T extends any[] = any[], F = (...args: T) => any> =\r\n | F\r\n | F[];\r\n\r\nexport const EventPropOption = <T extends any[] = any[]>() =>\r\n [Function, Array] as PropType<EventProp<T>>;\r\n\r\nexport type ComponentTypeEmits =\r\n | ((...args: any[]) => any)\r\n | Record<string, any[]>\r\n\r\nexport type EmitsToProps<T extends EmitsOptions | ComponentTypeEmits> =\r\n T extends string[]\r\n ? {\r\n [K in `on${Capitalize<T[number]>}`]?: (...args: any[]) => any\r\n }\r\n : T extends ObjectEmitsOptions\r\n ? {\r\n [K in string & keyof T as `on${Capitalize<K>}`]?: (\r\n ...args: T[K] extends (...args: infer P) => any\r\n ? P\r\n : T[K] extends null\r\n ? any[]\r\n : never\r\n ) => any\r\n }\r\n : {}\r\n\r\nexport type TypeEmitsToOptions<T extends ComponentTypeEmits> = {\r\n [K in keyof T & string]: T[K] extends [...args: infer Args]\r\n ? (...args: Args) => any\r\n : () => any\r\n} & (T extends (...args: any[]) => any\r\n ? ParametersToFns<OverloadParameters<T>>\r\n : {})\r\n\r\ntype ParametersToFns<T extends any[]> = {\r\n [K in T[0]]: K extends `${infer C}`\r\n ? (...args: T extends [C, ...infer Args] ? Args : never) => any\r\n : never\r\n}\r\n\r\nexport type OverloadParameters<T extends (...args: any[]) => any> = Parameters<\r\n OverloadUnion<T>\r\n>\r\n\r\ntype OverloadProps<TOverload> = Pick<TOverload, keyof TOverload>\r\n\r\ntype OverloadUnionRecursive<\r\n TOverload,\r\n TPartialOverload = unknown,\r\n> = TOverload extends (...args: infer TArgs) => infer TReturn\r\n ? TPartialOverload extends TOverload\r\n ? never\r\n :\r\n | OverloadUnionRecursive<\r\n TPartialOverload & TOverload,\r\n TPartialOverload &\r\n ((...args: TArgs) => TReturn) &\r\n OverloadProps<TOverload>\r\n >\r\n | ((...args: TArgs) => TReturn)\r\n : never\r\n\r\ntype OverloadUnion<TOverload extends (...args: any[]) => any> = Exclude<\r\n OverloadUnionRecursive<(() => never) & TOverload>,\r\n TOverload extends () => never ? never : () => never\r\n>\r\n"],"mappings":"AAMA,OAAO,MAAMA,eAAe,GAAGA,CAAA,KAC7B,CAACC,QAAQ,EAAEC,KAAK,CAA2B"}
@@ -10,7 +10,7 @@ export * from "./rect.mjs";
10
10
  export * from "./anchor.mjs";
11
11
  export * from "./scroll.mjs";
12
12
  export * from "./frame-scheduler.mjs";
13
- export * from "./vue-component.mjs";
13
+ export * from "./component/index.mjs";
14
14
  export * from "./reactivity.mjs";
15
15
  export * from "./color/index.mjs";
16
16
  export * from "./date/index.mjs";