yuyeon 0.0.41 → 0.0.42-rc10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/style.css +1 -1
- package/dist/yuyeon.js +5157 -3010
- package/dist/yuyeon.umd.cjs +8 -4
- package/lib/components/button/YButton.scss +2 -1
- package/lib/components/date-picker/YDateCalendar.mjs +235 -5
- package/lib/components/date-picker/YDateCalendar.mjs.map +1 -1
- package/lib/components/date-picker/YDateCalendar.scss +82 -0
- package/lib/components/date-picker/YDatePicker.mjs.map +1 -1
- package/lib/components/date-picker/YDatePickerControl.mjs +29 -0
- package/lib/components/date-picker/YDatePickerControl.mjs.map +1 -0
- package/lib/components/date-picker/YDatePickerControl.scss +3 -0
- package/lib/components/date-picker/index.mjs +1 -1
- package/lib/components/date-picker/index.mjs.map +1 -1
- package/lib/components/divider/YDivider.mjs +4 -2
- package/lib/components/divider/YDivider.mjs.map +1 -1
- package/lib/components/dropdown/YDropdown.mjs +11 -5
- package/lib/components/dropdown/YDropdown.mjs.map +1 -1
- package/lib/components/dropdown/YDropdown.scss +3 -8
- package/lib/components/field-input/YFieldInput.mjs +10 -10
- package/lib/components/field-input/YFieldInput.mjs.map +1 -1
- package/lib/components/icon/YIcon.mjs +62 -0
- package/lib/components/icon/YIcon.mjs.map +1 -0
- package/lib/components/icon/YIcon.scss +18 -0
- package/lib/components/icon/index.mjs +2 -0
- package/lib/components/icon/index.mjs.map +1 -0
- package/lib/components/icon/poly.mjs +57 -0
- package/lib/components/icon/poly.mjs.map +1 -0
- package/lib/components/icons/index.mjs +14 -0
- package/lib/components/icons/index.mjs.map +1 -1
- package/lib/components/index.mjs +3 -0
- package/lib/components/index.mjs.map +1 -1
- package/lib/components/input/YInput.mjs +1 -0
- package/lib/components/input/YInput.mjs.map +1 -1
- package/lib/components/input/index.mjs.map +1 -1
- package/lib/components/layer/YLayer.mjs +2 -0
- package/lib/components/layer/YLayer.mjs.map +1 -1
- package/lib/components/layer/active-stack.mjs.map +1 -1
- package/lib/components/list/YList.mjs.map +1 -1
- package/lib/components/menu/YMenu.mjs +14 -2
- package/lib/components/menu/YMenu.mjs.map +1 -1
- package/lib/components/select/YSelect.mjs +9 -6
- package/lib/components/select/YSelect.mjs.map +1 -1
- package/lib/components/select/YSelect.scss +3 -8
- package/lib/components/switch/YSwitch.mjs +2 -0
- package/lib/components/switch/YSwitch.mjs.map +1 -1
- package/lib/components/tab/types.mjs.map +1 -1
- package/lib/components/table/composibles/pagination.mjs.map +1 -1
- package/lib/components/textarea/YTextarea.mjs +159 -0
- package/lib/components/textarea/YTextarea.mjs.map +1 -0
- package/lib/components/textarea/YTextarea.scss +25 -0
- package/lib/components/textarea/index.mjs +2 -0
- package/lib/components/textarea/index.mjs.map +1 -0
- package/lib/components/tooltip/YTooltip.mjs +2 -2
- package/lib/components/tooltip/YTooltip.mjs.map +1 -1
- package/lib/components/tree-view/YTreeView.mjs +5 -0
- package/lib/components/tree-view/YTreeView.mjs.map +1 -1
- package/lib/components/tree-view/YTreeViewNode.mjs +1 -0
- package/lib/components/tree-view/YTreeViewNode.mjs.map +1 -1
- package/lib/composables/communication.mjs +9 -0
- package/lib/composables/communication.mjs.map +1 -1
- package/lib/composables/date/factory.mjs +12 -0
- package/lib/composables/date/factory.mjs.map +1 -0
- package/lib/composables/date/index.mjs +19 -1
- package/lib/composables/date/index.mjs.map +1 -1
- package/lib/composables/date/setting.mjs +11 -0
- package/lib/composables/date/setting.mjs.map +1 -0
- package/lib/composables/date/types.mjs +1 -1
- package/lib/composables/date/types.mjs.map +1 -1
- package/lib/composables/i18n/index.mjs +30 -0
- package/lib/composables/i18n/index.mjs.map +1 -0
- package/lib/composables/i18n/locale.mjs +5 -0
- package/lib/composables/i18n/locale.mjs.map +1 -0
- package/lib/composables/i18n/rtl.mjs +34 -0
- package/lib/composables/i18n/rtl.mjs.map +1 -0
- package/lib/composables/i18n/share.mjs +2 -0
- package/lib/composables/i18n/share.mjs.map +1 -0
- package/lib/composables/icon.mjs +141 -0
- package/lib/composables/icon.mjs.map +1 -1
- package/lib/composables/index.mjs +1 -0
- package/lib/composables/index.mjs.map +1 -1
- package/lib/composables/theme/index.mjs.map +1 -1
- package/lib/composables/transition.mjs.map +1 -1
- package/lib/i18n/built-in.mjs +77 -0
- package/lib/i18n/built-in.mjs.map +1 -0
- package/lib/i18n/config.mjs +82 -0
- package/lib/i18n/config.mjs.map +1 -0
- package/lib/i18n/types.mjs +2 -0
- package/lib/i18n/types.mjs.map +1 -0
- package/lib/index.mjs +24 -5
- package/lib/index.mjs.map +1 -1
- package/lib/locales/en.mjs +4 -0
- package/lib/locales/en.mjs.map +1 -0
- package/lib/locales/index.mjs +3 -0
- package/lib/locales/index.mjs.map +1 -0
- package/lib/locales/ko.mjs +4 -0
- package/lib/locales/ko.mjs.map +1 -0
- package/lib/styles/util/_mixin.scss +34 -0
- package/lib/types/index.mjs.map +1 -1
- package/lib/util/date/adapters/yuyeon-date-adapter.mjs +99 -0
- package/lib/util/date/adapters/yuyeon-date-adapter.mjs.map +1 -0
- package/lib/util/date/built-in.mjs +18 -104
- package/lib/util/date/built-in.mjs.map +1 -1
- package/lib/util/date/index.mjs +1 -0
- package/lib/util/date/index.mjs.map +1 -1
- package/lib/util/date/types.mjs.map +1 -1
- package/lib/util/index.mjs +1 -0
- package/lib/util/index.mjs.map +1 -1
- package/package.json +7 -5
- package/types/abstract/items.d.ts +4 -4
- package/types/components/button/YButton.d.ts +10 -10
- package/types/components/checkbox/YInputCheckbox.d.ts +2 -2
- package/types/components/date-picker/YDateCalendar.d.ts +136 -0
- package/types/components/date-picker/index.d.ts +1 -0
- package/types/components/dialog/YDialog.d.ts +3 -2
- package/types/components/dropdown/YDropdown.d.ts +34 -13
- package/types/components/field-input/YFieldInput.d.ts +10 -10
- package/types/components/form/YForm.d.ts +1 -1
- package/types/components/icon/YIcon.d.ts +81 -0
- package/types/components/icon/index.d.ts +1 -0
- package/types/components/icons/YIconCheckbox.d.ts +2 -2
- package/types/components/icons/YIconSort.d.ts +2 -2
- package/types/components/icons/index.d.ts +48 -0
- package/types/components/index.d.ts +3 -0
- package/types/components/input/YInput.d.ts +28 -11
- package/types/components/layer/YLayer.d.ts +23 -22
- package/types/components/layer/active-stack.d.ts +1 -2
- package/types/components/list/YList.d.ts +3 -3
- package/types/components/list/YListItem.d.ts +5 -5
- package/types/components/menu/YMenu.d.ts +13 -8
- package/types/components/pagination/YPagination.d.ts +5 -5
- package/types/components/progress-bar/YProgressBar.d.ts +1 -1
- package/types/components/select/YSelect.d.ts +80 -64
- package/types/components/switch/YSwitch.d.ts +1 -1
- package/types/components/tab/YTab.d.ts +15 -15
- package/types/components/tab/YTabs.d.ts +5 -5
- package/types/components/tab/types.d.ts +1 -0
- package/types/components/table/YDataTable.d.ts +18 -18
- package/types/components/table/YDataTableBody.d.ts +5 -5
- package/types/components/table/YDataTableControl.d.ts +2 -2
- package/types/components/table/YDataTableHead.d.ts +2 -2
- package/types/components/table/YDataTableServer.d.ts +21 -21
- package/types/components/table/YTable.d.ts +4 -4
- package/types/components/table/composibles/header.d.ts +1 -1
- package/types/components/table/composibles/items.d.ts +3 -3
- package/types/components/table/composibles/pagination.d.ts +2 -2
- package/types/components/table/composibles/selection.d.ts +2 -2
- package/types/components/table/composibles/sorting.d.ts +1 -1
- package/types/components/textarea/YTextarea.d.ts +737 -0
- package/types/components/textarea/index.d.ts +1 -0
- package/types/components/tooltip/YTooltip.d.ts +13 -12
- package/types/components/tree-view/YTreeView.d.ts +7 -4
- package/types/components/tree-view/YTreeViewNode.d.ts +17 -9
- package/types/composables/choice.d.ts +1 -1
- package/types/composables/communication.d.ts +2 -0
- package/types/composables/coordinate/index.d.ts +6 -6
- package/types/composables/date/factory.d.ts +2 -0
- package/types/composables/date/index.d.ts +11 -0
- package/types/composables/date/setting.d.ts +4 -0
- package/types/composables/date/types.d.ts +12 -0
- package/types/composables/i18n/index.d.ts +8 -0
- package/types/composables/i18n/locale.d.ts +2 -0
- package/types/composables/i18n/rtl.d.ts +20 -0
- package/types/composables/i18n/share.d.ts +1 -0
- package/types/composables/icon.d.ts +96 -0
- package/types/composables/index.d.ts +2 -0
- package/types/composables/list-items.d.ts +10 -10
- package/types/composables/theme/index.d.ts +5 -5
- package/types/globals.d.ts +12 -7
- package/types/i18n/built-in.d.ts +2 -0
- package/types/i18n/config.d.ts +81 -0
- package/types/i18n/types.d.ts +19 -0
- package/types/locales/en.d.ts +4 -0
- package/types/shims.d.ts +88 -83
- package/types/types/index.d.ts +5 -0
- package/types/util/date/adapters/yuyeon-date-adapter.d.ts +38 -0
- package/types/util/date/built-in.d.ts +35 -0
- package/types/util/date/index.d.ts +3 -0
- package/types/util/date/types.d.ts +163 -0
- package/types/util/index.d.ts +1 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { createVNode as _createVNode, mergeProps as _mergeProps } from "vue";
|
|
2
|
+
import { defineComponent, getCurrentInstance, nextTick, ref, watch } from 'vue';
|
|
3
|
+
import { useRender } from "../../composables/component.mjs";
|
|
4
|
+
import { useFocus } from "../../composables/focus.mjs";
|
|
5
|
+
import { chooseProps, getUid, propsFactory } from "../../util/index.mjs";
|
|
6
|
+
import { YInput, pressYInputPropsOptions } from "../input/index.mjs";
|
|
7
|
+
import "./YTextarea.scss";
|
|
8
|
+
export const pressYTextareaPropsOptions = propsFactory({
|
|
9
|
+
displayText: [String, Function],
|
|
10
|
+
whenInputValid: [Boolean, Number],
|
|
11
|
+
...pressYInputPropsOptions({
|
|
12
|
+
variation: 'filled'
|
|
13
|
+
})
|
|
14
|
+
}, 'YTextarea');
|
|
15
|
+
const CLASS_NAME = 'y-textarea';
|
|
16
|
+
export const YTextarea = defineComponent({
|
|
17
|
+
name: 'YTextarea',
|
|
18
|
+
props: pressYTextareaPropsOptions(),
|
|
19
|
+
emits: {
|
|
20
|
+
'update:modelValue': v => true,
|
|
21
|
+
'update:focused': v => true,
|
|
22
|
+
'mousedown:display': e => true,
|
|
23
|
+
input: v => true,
|
|
24
|
+
change: (v, e) => true,
|
|
25
|
+
focus: e => true,
|
|
26
|
+
blur: e => true,
|
|
27
|
+
click: e => true,
|
|
28
|
+
keydown: e => true,
|
|
29
|
+
keyup: e => true
|
|
30
|
+
},
|
|
31
|
+
slots: Object,
|
|
32
|
+
setup(props, _ref) {
|
|
33
|
+
let {
|
|
34
|
+
attrs,
|
|
35
|
+
emit,
|
|
36
|
+
slots,
|
|
37
|
+
expose
|
|
38
|
+
} = _ref;
|
|
39
|
+
const UID = getUid();
|
|
40
|
+
const el$ = ref();
|
|
41
|
+
const input$ = ref();
|
|
42
|
+
const inValue = ref('');
|
|
43
|
+
const displayValue = ref('');
|
|
44
|
+
const {
|
|
45
|
+
focused,
|
|
46
|
+
whenFocus,
|
|
47
|
+
whenBlur
|
|
48
|
+
} = useFocus(props, 'y-field-input');
|
|
49
|
+
function onUpdateModel(value) {
|
|
50
|
+
emit('update:modelValue', value);
|
|
51
|
+
}
|
|
52
|
+
function changeDisplay() {
|
|
53
|
+
const vm = getCurrentInstance();
|
|
54
|
+
const {
|
|
55
|
+
displayText
|
|
56
|
+
} = props;
|
|
57
|
+
if (displayText !== undefined) {
|
|
58
|
+
let text = inValue.value;
|
|
59
|
+
if (typeof displayText === 'string') {
|
|
60
|
+
text = displayText;
|
|
61
|
+
}
|
|
62
|
+
if (displayText && typeof displayText === 'function') {
|
|
63
|
+
text = displayText.call(vm, text);
|
|
64
|
+
}
|
|
65
|
+
nextTick(() => {
|
|
66
|
+
displayValue.value = text;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function invokeValidators() {
|
|
71
|
+
//
|
|
72
|
+
}
|
|
73
|
+
function onInput(event) {
|
|
74
|
+
emit('input', event);
|
|
75
|
+
const target = event.target;
|
|
76
|
+
inValue.value = target?.value;
|
|
77
|
+
displayValue.value = target?.value;
|
|
78
|
+
if (props.whenInputValid) {
|
|
79
|
+
invokeValidators();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function onChange(event) {
|
|
83
|
+
emit('change', inValue.value, event);
|
|
84
|
+
}
|
|
85
|
+
function onFocus(event) {
|
|
86
|
+
whenFocus();
|
|
87
|
+
displayValue.value = inValue.value;
|
|
88
|
+
emit('focus', event);
|
|
89
|
+
}
|
|
90
|
+
function onBlur(event) {
|
|
91
|
+
whenBlur();
|
|
92
|
+
invokeValidators();
|
|
93
|
+
emit('blur', event);
|
|
94
|
+
changeDisplay();
|
|
95
|
+
}
|
|
96
|
+
function onKeydown(event) {
|
|
97
|
+
emit('keydown', event);
|
|
98
|
+
}
|
|
99
|
+
function onKeyup(event) {
|
|
100
|
+
emit('keyup', event);
|
|
101
|
+
}
|
|
102
|
+
function onClick(event) {
|
|
103
|
+
emit('click', event);
|
|
104
|
+
}
|
|
105
|
+
watch(() => props.modelValue, neo => {
|
|
106
|
+
inValue.value = neo;
|
|
107
|
+
displayValue.value = neo;
|
|
108
|
+
}, {
|
|
109
|
+
immediate: true
|
|
110
|
+
});
|
|
111
|
+
watch(inValue, neo => {
|
|
112
|
+
if (!focused.value) {
|
|
113
|
+
changeDisplay();
|
|
114
|
+
} else {
|
|
115
|
+
displayValue.value = neo;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
expose({
|
|
119
|
+
el$,
|
|
120
|
+
input$
|
|
121
|
+
});
|
|
122
|
+
useRender(() => {
|
|
123
|
+
const yInputProps = chooseProps(props, YInput.props);
|
|
124
|
+
return _createVNode(YInput, _mergeProps({
|
|
125
|
+
"class": [CLASS_NAME]
|
|
126
|
+
}, yInputProps, {
|
|
127
|
+
"modelValue": inValue.value,
|
|
128
|
+
"onUpdate:modelValue": onUpdateModel,
|
|
129
|
+
"focused": focused.value,
|
|
130
|
+
"onClick": onClick,
|
|
131
|
+
"onMousedown:display": $event => emit('mousedown:display', $event)
|
|
132
|
+
}), {
|
|
133
|
+
default: defaultProps => _createVNode("div", {
|
|
134
|
+
"class": [`${CLASS_NAME}__field`],
|
|
135
|
+
"data-id": defaultProps.attrId,
|
|
136
|
+
"ref": 'field'
|
|
137
|
+
}, [props.floating ? el$.value && YInput.methods.createLabel.call(el$.value) : undefined, slots.default ? () => slots.default(defaultProps) : undefined, _createVNode("textarea", _mergeProps({
|
|
138
|
+
"ref": input$,
|
|
139
|
+
"value": displayValue.value,
|
|
140
|
+
"id": `y-input--${UID}`
|
|
141
|
+
}, attrs, {
|
|
142
|
+
"onInput": onInput,
|
|
143
|
+
"onFocus": onFocus,
|
|
144
|
+
"onBlur": onBlur,
|
|
145
|
+
"onChange": onChange,
|
|
146
|
+
"onKeydown": onKeydown,
|
|
147
|
+
"onKeyup": onKeyup
|
|
148
|
+
}), null)]),
|
|
149
|
+
label: slots.label ? () => slots.label?.() : undefined,
|
|
150
|
+
'helper-text': slots['helper-text'] ? () => slots['helper-text']?.() : undefined
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
return {
|
|
154
|
+
el$,
|
|
155
|
+
input$
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
//# sourceMappingURL=YTextarea.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"YTextarea.mjs","names":["defineComponent","getCurrentInstance","nextTick","ref","watch","useRender","useFocus","chooseProps","getUid","propsFactory","YInput","pressYInputPropsOptions","pressYTextareaPropsOptions","displayText","String","Function","whenInputValid","Boolean","Number","variation","CLASS_NAME","YTextarea","name","props","emits","v","e","input","change","focus","blur","click","keydown","keyup","slots","Object","setup","_ref","attrs","emit","expose","UID","el$","input$","inValue","displayValue","focused","whenFocus","whenBlur","onUpdateModel","value","changeDisplay","vm","undefined","text","call","invokeValidators","onInput","event","target","onChange","onFocus","onBlur","onKeydown","onKeyup","onClick","modelValue","neo","immediate","yInputProps","_createVNode","_mergeProps","$event","default","defaultProps","attrId","floating","methods","createLabel","label"],"sources":["../../../src/components/textarea/YTextarea.tsx"],"sourcesContent":["import {\r\n SlotsType,\r\n defineComponent,\r\n getCurrentInstance,\r\n nextTick,\r\n ref,\r\n watch,\r\n} from 'vue';\r\nimport type { PropType } from 'vue';\r\n\r\nimport { useRender } from '../../composables/component';\r\nimport { useFocus } from '../../composables/focus';\r\nimport { chooseProps, getUid, propsFactory } from '../../util';\r\nimport { YInput, pressYInputPropsOptions } from '../input';\r\n\r\nimport './YTextarea.scss';\r\n\r\nexport const pressYTextareaPropsOptions = propsFactory(\r\n {\r\n displayText: [String, Function] as PropType<\r\n string | ((value: any) => string)\r\n >,\r\n whenInputValid: [Boolean, Number] as PropType<boolean | number>,\r\n ...pressYInputPropsOptions({\r\n variation: 'filled',\r\n }),\r\n },\r\n 'YTextarea',\r\n);\r\n\r\nconst CLASS_NAME = 'y-textarea';\r\n\r\nexport const YTextarea = defineComponent({\r\n name: 'YTextarea',\r\n props: pressYTextareaPropsOptions(),\r\n emits: {\r\n 'update:modelValue': (v: any) => true,\r\n 'update:focused': (v: boolean) => true,\r\n 'mousedown:display': (e: MouseEvent) => true,\r\n input: (v: any) => true,\r\n change: (v: any, e: Event) => true,\r\n focus: (e: FocusEvent) => true,\r\n blur: (e: FocusEvent) => true,\r\n click: (e: MouseEvent) => true,\r\n keydown: (e: KeyboardEvent) => true,\r\n keyup: (e: KeyboardEvent) => true,\r\n },\r\n slots: Object as SlotsType<{\r\n default: any;\r\n label: any;\r\n 'helper-text': any;\r\n }>,\r\n setup(props, { attrs, emit, slots, expose }) {\r\n const UID = getUid();\r\n const el$ = ref<YInput>();\r\n const input$ = ref();\r\n const inValue = ref<any>('');\r\n const displayValue = ref('');\r\n const { focused, whenFocus, whenBlur } = useFocus(props, 'y-field-input');\r\n\r\n function onUpdateModel(value: any) {\r\n emit('update:modelValue', value);\r\n }\r\n\r\n function changeDisplay() {\r\n const vm = getCurrentInstance();\r\n const { displayText } = props;\r\n if (displayText !== undefined) {\r\n let text = inValue.value;\r\n if (typeof displayText === 'string') {\r\n text = displayText;\r\n }\r\n if (displayText && typeof displayText === 'function') {\r\n text = (displayText as any).call(vm, text);\r\n }\r\n nextTick(() => {\r\n displayValue.value = text as string;\r\n });\r\n }\r\n }\r\n\r\n function invokeValidators() {\r\n //\r\n }\r\n\r\n function onInput(event: Event) {\r\n emit('input', event);\r\n const target = event.target as HTMLInputElement | null;\r\n inValue.value = target?.value;\r\n displayValue.value = target?.value as string;\r\n if (props.whenInputValid) {\r\n invokeValidators();\r\n }\r\n }\r\n\r\n function onChange(event: Event) {\r\n emit('change', inValue.value, event);\r\n }\r\n\r\n function onFocus(event: FocusEvent) {\r\n whenFocus();\r\n displayValue.value = inValue.value as string;\r\n emit('focus', event);\r\n }\r\n\r\n function onBlur(event: FocusEvent) {\r\n whenBlur();\r\n invokeValidators();\r\n emit('blur', event);\r\n changeDisplay();\r\n }\r\n\r\n function onKeydown(event: KeyboardEvent) {\r\n emit('keydown', event);\r\n }\r\n\r\n function onKeyup(event: KeyboardEvent) {\r\n emit('keyup', event);\r\n }\r\n\r\n function onClick(event: MouseEvent) {\r\n emit('click', event);\r\n }\r\n\r\n watch(\r\n () => props.modelValue,\r\n (neo: any) => {\r\n inValue.value = neo;\r\n displayValue.value = neo;\r\n },\r\n {\r\n immediate: true,\r\n },\r\n );\r\n\r\n watch(inValue, (neo: string) => {\r\n if (!focused.value) {\r\n changeDisplay();\r\n } else {\r\n displayValue.value = neo;\r\n }\r\n });\r\n\r\n expose({\r\n el$,\r\n input$,\r\n });\r\n\r\n useRender(() => {\r\n const yInputProps = chooseProps(props, YInput.props);\r\n return (\r\n <YInput\r\n class={[CLASS_NAME]}\r\n {...yInputProps}\r\n modelValue={inValue.value}\r\n onUpdate:modelValue={onUpdateModel}\r\n focused={focused.value}\r\n onClick={onClick}\r\n onMousedown:display={($event) => emit('mousedown:display', $event)}\r\n >\r\n {{\r\n default: (defaultProps: any) => (\r\n <div\r\n class={[`${CLASS_NAME}__field`]}\r\n data-id={defaultProps.attrId}\r\n ref={'field'}\r\n >\r\n {props.floating\r\n ? el$.value &&\r\n YInput.methods!.createLabel.call(el$.value)\r\n : undefined}\r\n {slots.default ? () => slots.default(defaultProps) : undefined}\r\n {\r\n <textarea\r\n ref={input$}\r\n value={displayValue.value}\r\n id={`y-input--${UID}`}\r\n {...attrs}\r\n onInput={onInput}\r\n onFocus={onFocus}\r\n onBlur={onBlur}\r\n onChange={onChange}\r\n onKeydown={onKeydown}\r\n onKeyup={onKeyup}\r\n ></textarea>\r\n }\r\n </div>\r\n ),\r\n label: slots.label ? () => slots.label?.() : undefined,\r\n 'helper-text': slots['helper-text']\r\n ? () => slots['helper-text']?.()\r\n : undefined,\r\n }}\r\n </YInput>\r\n );\r\n });\r\n\r\n return {\r\n el$,\r\n input$,\r\n };\r\n },\r\n});\r\n\r\nexport type YTextarea = InstanceType<typeof YTextarea>;\r\n"],"mappings":";AAAA,SAEEA,eAAe,EACfC,kBAAkB,EAClBC,QAAQ,EACRC,GAAG,EACHC,KAAK,QACA,KAAK;AAAC,SAGJC,SAAS;AAAA,SACTC,QAAQ;AAAA,SACRC,WAAW,EAAEC,MAAM,EAAEC,YAAY;AAAA,SACjCC,MAAM,EAAEC,uBAAuB;AAExC;AAEA,OAAO,MAAMC,0BAA0B,GAAGH,YAAY,CACpD;EACEI,WAAW,EAAE,CAACC,MAAM,EAAEC,QAAQ,CAE7B;EACDC,cAAc,EAAE,CAACC,OAAO,EAAEC,MAAM,CAA+B;EAC/D,GAAGP,uBAAuB,CAAC;IACzBQ,SAAS,EAAE;EACb,CAAC;AACH,CAAC,EACD,WACF,CAAC;AAED,MAAMC,UAAU,GAAG,YAAY;AAE/B,OAAO,MAAMC,SAAS,GAAGrB,eAAe,CAAC;EACvCsB,IAAI,EAAE,WAAW;EACjBC,KAAK,EAAEX,0BAA0B,CAAC,CAAC;EACnCY,KAAK,EAAE;IACL,mBAAmB,EAAGC,CAAM,IAAK,IAAI;IACrC,gBAAgB,EAAGA,CAAU,IAAK,IAAI;IACtC,mBAAmB,EAAGC,CAAa,IAAK,IAAI;IAC5CC,KAAK,EAAGF,CAAM,IA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AS,EAAAiB,YAAA,aAAAC,WAAA;UAAA,OAGrD5B,MAAM;UAAA,SACJE,YAAY,CAACK,KAAK;UAAA,MACpB,YAAWT,GAAI;QAAC,GACjBH,KAAK;UAAA,WACAmB,OAAO;UAAA,WACPI,OAAO;UAAA,UACRC,MAAM;UAAA,YACJF,QAAQ;UAAA,aACPG,SAAS;UAAA,WACXC;QAAO,WAIvB;QACDe,KAAK,EAAE7C,KAAK,CAAC6C,KAAK,GAAG,MAAM7C,KAAK,CAAC6C,KAAK,GAAG,CAAC,GAAG1B,SAAS;QACtD,aAAa,EAAEnB,KAAK,CAAC,aAAa,CAAC,GAC7B,MAAMA,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,GAC9BmB;MAAS;IAIvB,CAAC,CAAC;IAEF,OAAO;MACLX,GAAG;MACHC;IACF,CAAC;EACH;AACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
.y-textarea {
|
|
2
|
+
--y-textarea-horizon-padding: 10px;
|
|
3
|
+
|
|
4
|
+
&__field {
|
|
5
|
+
position: relative;
|
|
6
|
+
flex: 1 1 auto;
|
|
7
|
+
min-height: 36px;
|
|
8
|
+
min-width: 0.000000001px;
|
|
9
|
+
padding: 1px 0;
|
|
10
|
+
border-radius: inherit;
|
|
11
|
+
|
|
12
|
+
> textarea {
|
|
13
|
+
position: relative;
|
|
14
|
+
outline: none;
|
|
15
|
+
padding: 8px var(--y-textarea-horizon-padding, 10px);
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 100%;
|
|
18
|
+
line-height: 1.2;
|
|
19
|
+
font-size: 0.875rem;
|
|
20
|
+
color: inherit;
|
|
21
|
+
border-radius: inherit;
|
|
22
|
+
margin: 1px;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/components/textarea/index.ts"],"sourcesContent":["export * from './YTextarea';\r\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YTooltip.mjs","names":["computed","defineComponent","nextTick","ref","watch","watchEffect","useModelDuplex","useRender","polyTransitionPropOptions","omit","bindClasses","chooseProps","YLayer","pressYLayerProps","useDelay","YPlate","NAME","YTooltipPropOptions","tooltipClasses","type","Array","String","Object","preventClip","Boolean","default","YTooltip","name","props","coordinateStrategy","openOnHover","align","offset","transition","emits","setup","_ref","slots","emit","expose","layer$","base$","baseSlot","baseEl","contentEl","classes","boundClasses","model","active","get","value","set","v","disabled","hovered","baseFromSlotEl","el","nodeType","base","$el","neo","$content","content$","startOpenDelay","startCloseDelay","changeActive","onMouseenter","e","onMouseleave","bindHover","addEventListener","unbindHover","removeEventListener","old","_createVNode","_Fragment","_mergeProps","$event","_len","arguments","length","args","_key","_len2","_key2","el$"],"sources":["../../../src/components/tooltip/YTooltip.tsx"],"sourcesContent":["import type { PropType } from 'vue';\nimport {\n computed,\n defineComponent,\n nextTick,\n ref,\n watch,\n watchEffect,\n} from 'vue';\n\nimport { useModelDuplex } from '../../composables/communication';\nimport { useRender } from '../../composables/component';\nimport { polyTransitionPropOptions } from '../../composables/transition';\nimport { omit } from '../../util';\nimport { bindClasses, chooseProps } from '../../util/vue-component';\nimport { YLayer, pressYLayerProps } from '../layer';\nimport { useDelay } from '../layer/active-delay';\nimport { YPlate } from '../plate';\n\nimport './YTooltip.scss';\n\nconst NAME = 'YTooltip';\n\nconst YTooltipPropOptions = {\n tooltipClasses: {\n type: [Array, String, Object] as PropType<\n string[] | string | Record<string, any>\n >,\n },\n preventClip: {\n type: Boolean as PropType<boolean>,\n default: true,\n },\n};\n\n/**\n * # Component\n */\nexport const YTooltip = defineComponent({\n name: NAME,\n props: {\n ...YTooltipPropOptions,\n ...pressYLayerProps({\n coordinateStrategy: 'levitation',\n openOnHover: true,\n align: 'center',\n offset: 8,\n }),\n transition: {\n ...polyTransitionPropOptions.transition,\n default: 'fade',\n },\n },\n emits: ['update:modelValue'],\n setup(props, { slots, emit, expose }) {\n const layer$ = ref<typeof YLayer>();\n const base$ = ref();\n const baseSlot = ref();\n const baseEl = ref<HTMLElement>();\n const contentEl = ref<HTMLElement>();\n\n const classes = computed(() => {\n const boundClasses = bindClasses(props.tooltipClasses);\n return {\n ...boundClasses,\n 'y-tooltip': true,\n };\n });\n\n const model = useModelDuplex(props);\n\n const active = computed({\n get: (): boolean => {\n return !!model.value;\n },\n set: (v: boolean) => {\n if (!(v && props.disabled)) model.value = v;\n },\n });\n\n const hovered = computed(() => !!layer$.value?.hovered);\n\n const baseFromSlotEl = computed(() => {\n return baseSlot.value?.[0]?.el;\n });\n\n watchEffect(() => {\n if (!base$.value) {\n if (baseFromSlotEl.value?.nodeType !== 3) {\n baseEl.value = baseFromSlotEl.value;\n }\n return;\n }\n const base = base$.value;\n baseEl.value = base$.value?.$el ? base$.value?.$el : base;\n });\n\n watch(active, (neo) => {\n if (neo) {\n nextTick(() => {\n const $content = layer$.value?.content$;\n contentEl.value = $content;\n });\n }\n });\n\n const { startOpenDelay, startCloseDelay } = useDelay(\n props,\n (changeActive) => {\n if (!changeActive && props.openOnHover && !hovered.value) {\n active.value = false;\n } else if (changeActive) {\n active.value = true;\n }\n },\n );\n\n function onMouseenter(e: MouseEvent) {\n if (props.openOnHover) {\n startOpenDelay();\n }\n }\n\n function onMouseleave(e: MouseEvent) {\n if (props.openOnHover) {\n startCloseDelay();\n }\n }\n\n watch(hovered, (value) => {\n if (!value) {\n startCloseDelay();\n }\n });\n\n function bindHover(el: HTMLElement) {\n el.addEventListener('mouseenter', onMouseenter);\n el.addEventListener('mouseleave', onMouseleave);\n }\n\n function unbindHover(el: HTMLElement) {\n el.removeEventListener('mouseenter', onMouseenter);\n el.removeEventListener('mouseleave', onMouseleave);\n }\n\n watch(\n () => layer$.value?.baseEl,\n (neo, old) => {\n if (neo) {\n bindHover(neo);\n } else if (old) {\n unbindHover(old);\n }\n },\n );\n\n useRender(() => {\n return (\n <>\n <YLayer\n ref={layer$}\n {...omit(chooseProps(props, YLayer.props), ['scrim'])}\n classes={classes.value}\n scrim={false}\n transition={props.transition}\n v-model={active.value}\n >\n {{\n default: (...args: any) => {\n return (\n <>\n <YPlate></YPlate>\n <div class=\"y-tooltip__content\">\n {slots.default?.(...args) ?? ''}\n </div>\n </>\n );\n },\n base: (...args: any[]) => slots.base?.(...args),\n }}\n </YLayer>\n </>\n );\n });\n\n return {\n base$,\n el$: layer$,\n baseEl,\n baseSlot,\n active,\n };\n },\n});\n"],"mappings":";AACA,SACEA,QAAQ,EACRC,eAAe,EACfC,QAAQ,EACRC,GAAG,EACHC,KAAK,EACLC,WAAW,QACN,KAAK;AAAC,SAEJC,cAAc;AAAA,SACdC,SAAS;AAAA,SACTC,yBAAyB;AAAA,SACzBC,IAAI;AAAA,SACJC,WAAW,EAAEC,WAAW;AAAA,SACxBC,MAAM,EAAEC,gBAAgB;AAAA,SACxBC,QAAQ;AAAA,SACRC,MAAM;AAEf;AAEA,MAAMC,IAAI,GAAG,UAAU;AAEvB,MAAMC,mBAAmB,GAAG;EAC1BC,cAAc,EAAE;IACdC,IAAI,EAAE,CAACC,KAAK,EAAEC,MAAM,EAAEC,MAAM;EAG9B,CAAC;EACDC,WAAW,EAAE;IACXJ,IAAI,EAAEK,OAA4B;IAClCC,OAAO,EAAE;EACX;AACF,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMC,QAAQ,GAAGzB,eAAe,CAAC;EACtC0B,IAAI,EAAEX,IAAI;EACVY,KAAK,EAAE;IACL,GAAGX,mBAAmB;IACtB,GAAGJ,gBAAgB,CAAC;MAClBgB,kBAAkB,EAAE,YAAY;MAChCC,WAAW,EAAE,IAAI;MACjBC,KAAK,EAAE,QAAQ;MACfC,MAAM,EAAE;IACV,CAAC,CAAC;IACFC,UAAU,EAAE;MACV,GAAGzB,yBAAyB,CAACyB,UAAU;MACvCR,OAAO,EAAE;IACX;EACF,CAAC;EACDS,KAAK,EAAE,CAAC,mBAAmB,C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AAA;YAAA,SAGe;UAAoB,IAC5BrC,KAAK,CAACZ,OAAO,GAAG,GAAGwD,IAAI,CAAC,IAAI,EAAE;QAIvC,CAAC;QACDvB,IAAI,EAAE,SAAAA,CAAA;UAAA,SAAAyB,KAAA,GAAAJ,SAAA,CAAAC,MAAA,EAAIC,IAAI,OAAA7D,KAAA,CAAA+D,KAAA,GAAAC,KAAA,MAAAA,KAAA,GAAAD,KAAA,EAAAC,KAAA;YAAJH,IAAI,CAAAG,KAAA,IAAAL,SAAA,CAAAK,KAAA;UAAA;UAAA,OAAY/C,KAAK,CAACqB,IAAI,GAAG,GAAGuB,IAAI,CAAC;QAAA;MAAA;IAKzD,CAAC,CAAC;IAEF,OAAO;MACLxC,KAAK;MACL4C,GAAG,EAAE7C,MAAM;MACXG,MAAM;MACND,QAAQ;MACRM;IACF,CAAC;EACH;AACF,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"YTooltip.mjs","names":["computed","defineComponent","nextTick","ref","watch","watchEffect","useModelDuplex","useRender","polyTransitionPropOptions","omit","bindClasses","chooseProps","YLayer","pressYLayerProps","useDelay","YPlate","NAME","YTooltipPropOptions","tooltipClasses","type","Array","String","Object","preventClip","Boolean","default","YTooltip","name","props","coordinateStrategy","openOnHover","align","offset","transition","emits","setup","_ref","slots","emit","expose","layer$","base$","baseSlot","baseEl","contentEl","classes","boundClasses","model","active","get","value","set","v","disabled","hovered","baseFromSlotEl","el","nodeType","base","$el","neo","$content","content$","startOpenDelay","startCloseDelay","changeActive","onMouseenter","e","onMouseleave","bindHover","addEventListener","unbindHover","removeEventListener","old","_createVNode","_Fragment","_mergeProps","$event","_len","arguments","length","args","_key","_len2","_key2","el$"],"sources":["../../../src/components/tooltip/YTooltip.tsx"],"sourcesContent":["import type { PropType } from 'vue';\r\nimport {\r\n computed,\r\n defineComponent,\r\n nextTick,\r\n ref,\r\n watch,\r\n watchEffect,\r\n} from 'vue';\r\n\r\nimport { useModelDuplex } from '../../composables/communication';\r\nimport { useRender } from '../../composables/component';\r\nimport { polyTransitionPropOptions } from '../../composables/transition';\r\nimport { omit } from '../../util';\r\nimport { bindClasses, chooseProps } from '../../util/vue-component';\r\nimport { YLayer, pressYLayerProps } from '../layer';\r\nimport { useDelay } from '../layer/active-delay';\r\nimport { YPlate } from '../plate';\r\n\r\nimport './YTooltip.scss';\r\n\r\nconst NAME = 'YTooltip';\r\n\r\nconst YTooltipPropOptions = {\r\n tooltipClasses: {\r\n type: [Array, String, Object] as PropType<\r\n string[] | string | Record<string, any>\r\n >,\r\n },\r\n preventClip: {\r\n type: Boolean as PropType<boolean>,\r\n default: true,\r\n },\r\n};\r\n\r\n/**\r\n * # Component\r\n */\r\nexport const YTooltip = defineComponent({\r\n name: NAME,\r\n props: {\r\n ...YTooltipPropOptions,\r\n ...pressYLayerProps({\r\n coordinateStrategy: 'levitation',\r\n openOnHover: true,\r\n align: 'center',\r\n offset: 8,\r\n }),\r\n transition: {\r\n ...polyTransitionPropOptions.transition,\r\n default: 'fade',\r\n },\r\n },\r\n emits: ['update:modelValue'],\r\n setup(props, { slots, emit, expose }) {\r\n const layer$ = ref<typeof YLayer>();\r\n const base$ = ref();\r\n const baseSlot = ref();\r\n const baseEl = ref<HTMLElement>();\r\n const contentEl = ref<HTMLElement>();\r\n\r\n const classes = computed(() => {\r\n const boundClasses = bindClasses(props.tooltipClasses);\r\n return {\r\n ...boundClasses,\r\n 'y-tooltip': true,\r\n };\r\n });\r\n\r\n const model = useModelDuplex(props);\r\n\r\n const active = computed({\r\n get: (): boolean => {\r\n return !!model.value;\r\n },\r\n set: (v: boolean) => {\r\n if (!(v && props.disabled)) model.value = v;\r\n },\r\n });\r\n\r\n const hovered = computed(() => !!layer$.value?.hovered);\r\n\r\n const baseFromSlotEl = computed(() => {\r\n return baseSlot.value?.[0]?.el;\r\n });\r\n\r\n watchEffect(() => {\r\n if (!base$.value) {\r\n if (baseFromSlotEl.value?.nodeType !== 3) {\r\n baseEl.value = baseFromSlotEl.value;\r\n }\r\n return;\r\n }\r\n const base = base$.value;\r\n baseEl.value = base$.value?.$el ? base$.value?.$el : base;\r\n });\r\n\r\n watch(active, (neo) => {\r\n if (neo) {\r\n nextTick(() => {\r\n const $content = layer$.value?.content$;\r\n contentEl.value = $content;\r\n });\r\n }\r\n });\r\n\r\n const { startOpenDelay, startCloseDelay } = useDelay(\r\n props,\r\n (changeActive) => {\r\n if (!changeActive && props.openOnHover && !hovered.value) {\r\n active.value = false;\r\n } else if (changeActive) {\r\n active.value = true;\r\n }\r\n },\r\n );\r\n\r\n function onMouseenter(e: MouseEvent) {\r\n if (props.openOnHover) {\r\n startOpenDelay();\r\n }\r\n }\r\n\r\n function onMouseleave(e: MouseEvent) {\r\n if (props.openOnHover) {\r\n startCloseDelay();\r\n }\r\n }\r\n\r\n watch(hovered, (value) => {\r\n if (!value) {\r\n startCloseDelay();\r\n }\r\n });\r\n\r\n function bindHover(el: HTMLElement) {\r\n el.addEventListener('mouseenter', onMouseenter);\r\n el.addEventListener('mouseleave', onMouseleave);\r\n }\r\n\r\n function unbindHover(el: HTMLElement) {\r\n el.removeEventListener('mouseenter', onMouseenter);\r\n el.removeEventListener('mouseleave', onMouseleave);\r\n }\r\n\r\n watch(\r\n () => layer$.value?.baseEl,\r\n (neo, old) => {\r\n if (neo) {\r\n bindHover(neo);\r\n } else if (old) {\r\n unbindHover(old);\r\n }\r\n },\r\n );\r\n\r\n useRender(() => {\r\n return (\r\n <>\r\n <YLayer\r\n ref={layer$}\r\n {...omit(chooseProps(props, YLayer.props), ['scrim'])}\r\n classes={classes.value}\r\n scrim={false}\r\n transition={props.transition}\r\n v-model={active.value}\r\n >\r\n {{\r\n default: (...args: any) => {\r\n return (\r\n <>\r\n <YPlate></YPlate>\r\n <div class=\"y-tooltip__content\">\r\n {slots.default?.(...args) ?? ''}\r\n </div>\r\n </>\r\n );\r\n },\r\n base: (...args: any[]) => slots.base?.(...args),\r\n }}\r\n </YLayer>\r\n </>\r\n );\r\n });\r\n\r\n return {\r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KAAA,GAAAD,KAAA,EAAAC,KAAA;YAAJH,IAAI,CAAAG,KAAA,IAAAL,SAAA,CAAAK,KAAA;UAAA;UAAA,OAAY/C,KAAK,CAACqB,IAAI,GAAG,GAAGuB,IAAI,CAAC;QAAA;MAAA;IAKzD,CAAC,CAAC;IAEF,OAAO;MACLxC,KAAK;MACL4C,GAAG,EAAE7C,MAAM;MACXG,MAAM;MACND,QAAQ;MACRM;IACF,CAAC;EACH;AACF,CAAC,CAAC"}
|
|
@@ -187,6 +187,11 @@ export const YTreeView = defineComponent({
|
|
|
187
187
|
if (to) {
|
|
188
188
|
activeSet.value.add(key);
|
|
189
189
|
node.active = true;
|
|
190
|
+
} else {
|
|
191
|
+
if (props.requiredActive && activeSet.value.size === 1 && key === inactiveKey) {
|
|
192
|
+
issueVnodeState(key);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
190
195
|
}
|
|
191
196
|
if (inactiveKey && inactiveKey in nodes.value) {
|
|
192
197
|
activeSet.value.delete(inactiveKey);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YTreeView.mjs","names":["computed","defineComponent","onMounted","provide","ref","shallowRef","watch","watchEffect","useModelDuplex","useRender","differenceBetween","isColorValue","deepEqual","getObjectValueByPath","hasOwnProperty","debounce","chooseProps","YProgressBar","YTreeViewNode","pressYTreeViewNodeProps","filterTreeItem","filterTreeItems","getKeys","treeViewNodeProps","YTreeView","name","props","expanded","type","Array","default","active","multipleActive","Boolean","activeStrategy","String","selected","selectStrategy","returnItem","defaultExpand","Number","filter","Function","searchDebounceWait","emits","setup","_ref","slots","emit","expose","nodes","expandedSet","Set","selectedSet","activeSet","excludedSet","filterItemsFn","excludeItem","expandedCache","searchLoading","items","search","arguments","length","undefined","excluded","value","diff","forEach","key","updateExpanded","item","itemKey","itemText","itemChildren","expand","getDescendants","descendants","childKeys","push","childKey","getNodeKey","itemOrKey","updateNodes","parentKey","level","children","exist","existNode","vnode","indeterminate","node","map","child","add","issueVnodeState","to","isArray","delete","neo","deep","until","Object","entries","_ref2","emitExpanded","updateActive","event","inactiveKey","keys","activeSingleModifier","getModifierState","descendant","updateSelected","arr","emitActive","emitSelected","stateWatcher","stateSet","updater","emitter","valuesOfKey","v","old","oldKeys","nodeKey","neoKeys","k","oldSelected","clear","isExcluded","has","register","activeValue","selectedValue","renderLeaves","leaf","classes","styles","color","activeColor","_createVNode","_Fragment","_mergeProps","_createTextVNode"],"sources":["../../../src/components/tree-view/YTreeView.tsx"],"sourcesContent":["import {\r\n PropType,\r\n Ref,\r\n VNode,\r\n computed,\r\n defineComponent,\r\n onMounted,\r\n provide,\r\n ref,\r\n shallowRef,\r\n watch,\r\n watchEffect,\r\n} from 'vue';\r\n\r\nimport { useModelDuplex } from '../../composables/communication';\r\nimport { useRender } from '../../composables/component';\r\nimport { CandidateKey } from '../../types';\r\nimport { differenceBetween } from '../../util/array';\r\nimport { isColorValue } from '../../util/color';\r\nimport {\r\n deepEqual,\r\n getObjectValueByPath,\r\n hasOwnProperty,\r\n} from '../../util/common';\r\nimport { debounce } from '../../util/debounce';\r\nimport { chooseProps } from '../../util/vue-component';\r\nimport { YProgressBar } from '../progress-bar';\r\nimport { YTreeViewNode, pressYTreeViewNodeProps } from './YTreeViewNode';\r\nimport { NodeState, TreeviewFilterFn } from './types';\r\nimport { filterTreeItem, filterTreeItems, getKeys } from './util';\r\n\r\nimport './YTreeView.scss';\r\n\r\nconst treeViewNodeProps = pressYTreeViewNodeProps();\r\n\r\nexport const YTreeView = defineComponent({\r\n name: 'YTreeView',\r\n props: {\r\n expanded: {\r\n type: [Array] as PropType<CandidateKey[]>,\r\n default: () => [],\r\n },\r\n active: {\r\n type: [Array] as PropType<CandidateKey[]>,\r\n default: () => [],\r\n },\r\n multipleActive: Boolean,\r\n activeStrategy: {\r\n type: String as PropType<'independent' | 'cascade'>, // TODO: 'leaf'\r\n default: 'independent',\r\n },\r\n selected: {\r\n type: [Array] as PropType<CandidateKey[]>,\r\n default: () => [],\r\n },\r\n selectStrategy: {\r\n type: String as PropType<'independent' | 'cascade'>, // TODO: 'leaf'\r\n default: 'leaf',\r\n },\r\n returnItem: Boolean,\r\n defaultExpand: [Boolean, String, Number],\r\n filter: Function as PropType<TreeviewFilterFn>,\r\n searchDebounceWait: {\r\n type: Number as PropType<number>,\r\n default: 700,\r\n },\r\n ...treeViewNodeProps,\r\n },\r\n emits: ['update:expanded', 'update:active', 'update:selected'],\r\n setup(props, { slots, emit, expose }) {\r\n const nodes = ref<Record<CandidateKey, any>>({});\r\n\r\n const expanded = useModelDuplex(props, 'expanded');\r\n const active = useModelDuplex(props, 'active');\r\n const selected = useModelDuplex(props, 'selected');\r\n\r\n const expandedSet = ref(new Set<CandidateKey>());\r\n const selectedSet = ref(new Set<CandidateKey>());\r\n const activeSet = ref(new Set<CandidateKey>());\r\n const excludedSet = ref(new Set<CandidateKey>());\r\n const filterItemsFn = shallowRef(\r\n debounce(excludeItem, props.searchDebounceWait),\r\n );\r\n const expandedCache = ref<CandidateKey[]>([]);\r\n const searchLoading = shallowRef(false);\r\n\r\n function excludeItem(items: any[], search = '', filter = filterTreeItem) {\r\n const excluded = new Set<CandidateKey>();\r\n if (!search) {\r\n searchLoading.value = false;\r\n excludedSet.value = excluded;\r\n const diff = differenceBetween(expandedCache.value, [\r\n ...expandedSet.value,\r\n ]);\r\n diff.forEach((key) => {\r\n updateExpanded(key, false);\r\n });\r\n expandedCache.value.forEach((key) => {\r\n updateExpanded(key, true);\r\n });\r\n return;\r\n }\r\n for (const item of items) {\r\n filterTreeItems(\r\n filter,\r\n item,\r\n search ?? '',\r\n props.itemKey,\r\n props.itemText,\r\n props.itemChildren as string,\r\n excluded,\r\n );\r\n }\r\n excludedSet.value = excluded;\r\n searchLoading.value = false;\r\n expand();\r\n }\r\n\r\n watchEffect(() => {\r\n searchLoading.value = true;\r\n filterItemsFn.value(props.items, props.search, props.filter);\r\n });\r\n\r\n // Util Methods\r\n function getDescendants(\r\n key: CandidateKey,\r\n descendants: CandidateKey[] = [],\r\n ) {\r\n const { childKeys } = nodes.value[key];\r\n descendants.push(...childKeys);\r\n for (const childKey of childKeys) {\r\n descendants = getDescendants(childKey, descendants);\r\n }\r\n return descendants;\r\n }\r\n\r\n function getNodeKey(itemOrKey: any) {\r\n return props.returnItem\r\n ? getObjectValueByPath(itemOrKey, props.itemKey)\r\n : itemOrKey;\r\n }\r\n\r\n // State Methods\r\n function updateNodes(\r\n items: any[],\r\n parentKey: CandidateKey | null = null,\r\n level = 0,\r\n ) {\r\n for (const item of items) {\r\n const key = getObjectValueByPath(item, props.itemKey);\r\n const children =\r\n getObjectValueByPath(item, props.itemChildren as string) ?? [];\r\n const exist = hasOwnProperty(nodes.value, key);\r\n const existNode = exist\r\n ? nodes.value[key]\r\n : {\r\n vnode: null,\r\n selected: false,\r\n indeterminate: false,\r\n active: false,\r\n expanded: false,\r\n };\r\n const node: NodeState = {\r\n vnode: existNode.vnode,\r\n item,\r\n level,\r\n parentKey,\r\n childKeys: children.map((child: any) =>\r\n getObjectValueByPath(child, props.itemKey),\r\n ),\r\n expanded: children.length > 0 && existNode.expanded,\r\n active: existNode.active,\r\n indeterminate: existNode.indeterminate,\r\n selected: existNode.selected,\r\n };\r\n\r\n updateNodes(children, key, level + 1);\r\n\r\n nodes.value[key] = node;\r\n if (nodes.value[key].expanded) {\r\n expandedSet.value.add(key);\r\n }\r\n if (nodes.value[key].selected) {\r\n expandedSet.value.add(key);\r\n }\r\n if (nodes.value[key].active) {\r\n activeSet.value.add(key);\r\n }\r\n\r\n issueVnodeState(key);\r\n }\r\n }\r\n\r\n function updateExpanded(key: CandidateKey, to: boolean) {\r\n if (!(key in nodes.value)) return;\r\n const node = nodes.value[key];\r\n const children = getObjectValueByPath(\r\n node.item,\r\n props.itemChildren as string,\r\n );\r\n if (Array.isArray(children) && children.length > 0) {\r\n to ? expandedSet.value.add(key) : expandedSet.value.delete(key);\r\n node.expanded = to;\r\n issueVnodeState(key);\r\n }\r\n }\r\n\r\n watch(\r\n expandedSet,\r\n (neo) => {\r\n if (!props.search) {\r\n expandedCache.value = [...neo];\r\n }\r\n },\r\n { deep: true },\r\n );\r\n\r\n function expand(until: boolean | string | number = true) {\r\n Object.entries(nodes.value).forEach(([key, node]) => {\r\n if (until === true || until >= node.level) {\r\n updateExpanded(key, true);\r\n }\r\n });\r\n emitExpanded();\r\n return expandedSet.value;\r\n }\r\n\r\n function updateActive(key: CandidateKey, to: boolean, event?: MouseEvent) {\r\n if (!(key in nodes.value)) return;\r\n const node = nodes.value[key];\r\n let inactiveKey = !to ? key : '';\r\n if (!props.multipleActive) {\r\n [inactiveKey] = activeSet.value.keys();\r\n }\r\n if (to) {\r\n activeSet.value.add(key);\r\n node.active = true;\r\n }\r\n if (inactiveKey && inactiveKey in nodes.value) {\r\n activeSet.value.delete(inactiveKey);\r\n nodes.value[inactiveKey].active = false;\r\n issueVnodeState(inactiveKey);\r\n }\r\n\r\n if (\r\n props.activeSingleModifier &&\r\n event?.getModifierState(props.activeSingleModifier)\r\n ) {\r\n return;\r\n }\r\n\r\n if (props.multipleActive && props.activeStrategy === 'cascade') {\r\n for (const descendant of getDescendants(key)) {\r\n if (descendant in nodes.value) {\r\n to\r\n ? activeSet.value.add(descendant)\r\n : activeSet.value.delete(descendant);\r\n nodes.value[descendant].active = to;\r\n issueVnodeState(descendant);\r\n }\r\n }\r\n }\r\n }\r\n\r\n function updateSelected(key: CandidateKey, to: boolean) {\r\n if (!(key in nodes.value)) return;\r\n const node = nodes.value[key];\r\n\r\n if (to) {\r\n selectedSet.value.add(key);\r\n node.selected = true;\r\n }\r\n\r\n if (!to && key in nodes.value) {\r\n selectedSet.value.delete(key);\r\n nodes.value[key].selected = false;\r\n issueVnodeState(key);\r\n }\r\n\r\n if (props.selectStrategy === 'cascade') {\r\n for (const descendant of getDescendants(key)) {\r\n if (descendant in nodes.value) {\r\n to\r\n ? selectedSet.value.add(descendant)\r\n : selectedSet.value.delete(descendant);\r\n nodes.value[descendant].selected = to;\r\n issueVnodeState(descendant);\r\n }\r\n }\r\n }\r\n }\r\n\r\n function emitExpanded() {\r\n const arr = [...expandedSet.value];\r\n expanded.value = props.returnItem\r\n ? arr.map((key) => nodes.value[key].item)\r\n : arr;\r\n }\r\n\r\n function emitActive() {\r\n const arr = [...activeSet.value];\r\n active.value = props.returnItem\r\n ? arr.map((key) => nodes.value[key].item)\r\n : arr;\r\n }\r\n\r\n function emitSelected() {\r\n const arr = [...selectedSet.value];\r\n selected.value = props.returnItem\r\n ? arr.map((key) => nodes.value[key].item)\r\n : arr;\r\n }\r\n\r\n function stateWatcher(\r\n value: any[],\r\n stateSet: Ref<Set<CandidateKey>>,\r\n updater: (key: CandidateKey, to: boolean) => void,\r\n emitter: () => void,\r\n ) {\r\n const valuesOfKey = props.returnItem\r\n ? value.map((v) => getObjectValueByPath(v, props.itemKey))\r\n : value;\r\n const old = [...stateSet.value];\r\n if (deepEqual(old, valuesOfKey)) {\r\n return;\r\n }\r\n old.forEach((key) => updater(key, false));\r\n valuesOfKey.forEach((key) => updater(key, true));\r\n emitter();\r\n }\r\n\r\n watch(expanded, (neo) => {\r\n stateWatcher(neo, expandedSet, updateExpanded, emitExpanded);\r\n });\r\n\r\n watch(active, (neo) => {\r\n stateWatcher(neo, activeSet, updateActive, emitActive);\r\n });\r\n\r\n watch(selected, (neo) => {\r\n stateWatcher(neo, selectedSet, updateSelected, emitSelected);\r\n });\r\n\r\n watch(\r\n () => props.items,\r\n (neo: any[]) => {\r\n const oldKeys = Object.keys(nodes.value).map((nodeKey) =>\r\n getObjectValueByPath(nodes.value[nodeKey].item, props.itemKey),\r\n );\r\n const neoKeys = getKeys(\r\n neo,\r\n props.itemKey,\r\n props.itemChildren as string,\r\n );\r\n const diff = differenceBetween(oldKeys, neoKeys);\r\n if (diff.length < 1 && neoKeys.length < oldKeys.length) {\r\n return;\r\n }\r\n diff.forEach((k) => delete nodes.value[k]);\r\n\r\n // init\r\n const oldSelected = [...selectedSet.value];\r\n selectedSet.value.clear();\r\n expandedSet.value.clear();\r\n activeSet.value.clear();\r\n updateNodes(neo);\r\n if (!deepEqual(oldSelected, [...selectedSet.value])) {\r\n emitSelected();\r\n }\r\n },\r\n { deep: true },\r\n );\r\n\r\n // Search\r\n function isExcluded(key: CandidateKey) {\r\n return !!props.search && excludedSet.value.has(key);\r\n }\r\n\r\n // Provide & Issue\r\n function issueVnodeState(key: CandidateKey) {\r\n const node = nodes.value[key];\r\n if (node && node.vnode) {\r\n node.vnode.active = node.active;\r\n node.vnode.selected = node.selected;\r\n node.vnode.indeterminate = node.indeterminate;\r\n node.vnode.expanded = node.expanded;\r\n }\r\n }\r\n\r\n function register(key: CandidateKey, vnode: VNode) {\r\n if (nodes.value[key]) {\r\n nodes.value[key].vnode = vnode;\r\n }\r\n\r\n issueVnodeState(key);\r\n }\r\n\r\n updateNodes(props.items);\r\n\r\n for (const activeValue of props.active.map(getNodeKey)) {\r\n updateActive(activeValue, true);\r\n }\r\n\r\n for (const selectedValue of props.selected.map(getNodeKey)) {\r\n updateSelected(selectedValue, true);\r\n }\r\n\r\n provide('tree-view', {\r\n register,\r\n updateExpanded,\r\n updateActive,\r\n updateSelected,\r\n emitExpanded,\r\n emitActive,\r\n emitSelected,\r\n isExcluded,\r\n searchLoading,\r\n });\r\n\r\n const renderLeaves = computed(() => {\r\n return props.items.filter((leaf) => {\r\n return !isExcluded(getObjectValueByPath(leaf, props.itemKey));\r\n });\r\n });\r\n\r\n const classes = computed(() => {\r\n return {\r\n 'y-tree-view': true,\r\n };\r\n });\r\n\r\n const styles = computed(() => {\r\n let color = props.activeColor;\r\n if (props.activeColor && !isColorValue(props.activeColor)) {\r\n color = `var(--y-theme-${props.activeColor})`;\r\n }\r\n return {\r\n [`--y-tree-view__active-color`]: color,\r\n };\r\n });\r\n\r\n onMounted(() => {\r\n if (props.defaultExpand !== undefined) {\r\n expandedCache.value = [...expand(props.defaultExpand)];\r\n } else {\r\n expanded.value.forEach((v: any) => updateExpanded(getNodeKey(v), true));\r\n emitExpanded();\r\n }\r\n });\r\n\r\n expose({\r\n expand,\r\n });\r\n\r\n useRender(() => {\r\n return (\r\n <>\r\n <div class={classes.value} style={styles.value} role=\"tree\">\r\n {searchLoading.value && <YProgressBar indeterminate />}\r\n {renderLeaves.value.length > 0 ? (\r\n renderLeaves.value.map((leaf) => {\r\n return (\r\n <YTreeViewNode\r\n v-slots={slots}\r\n key={getObjectValueByPath(leaf, props.itemKey)}\r\n {...{\r\n ...chooseProps(props, treeViewNodeProps),\r\n item: leaf,\r\n level: 0,\r\n }}\r\n ></YTreeViewNode>\r\n );\r\n })\r\n ) : (\r\n <div class=\"y-tree-view__no-data\">\r\n {slots['no-data'] ? slots['no-data']() : <span>No Data</span>}\r\n </div>\r\n )}\r\n </div>\r\n </>\r\n );\r\n });\r\n\r\n return {\r\n nodes,\r\n expandedSet,\r\n selectedSet,\r\n activeSet,\r\n excludedSet,\r\n searchLoading,\r\n expandedCache,\r\n };\r\n },\r\n});\r\n\r\nexport type YTreeView = InstanceType<typeof YTreeView>;\r\n"],"mappings":";AAAA,SAIEA,QAAQ,EACRC,eAAe,EACfC,SAAS,EACTC,OAAO,EACPC,GAAG,EACHC,UAAU,EACVC,KAAK,EACLC,WAAW,QACN,KAAK;AAAC,SAEJC,cAAc;AAAA,SACdC,SAAS;AAAA,SAETC,iBAAiB;AAAA,SACjBC,YAAY;AAAA,SAEnBC,SAAS,EACTC,oBAAoB,EACpBC,cAAc;AAAA,SAEPC,QAAQ;AAAA,SACRC,WAAW;AAAA,SACXC,YAAY;AAAA,SACZC,aAAa,EAAEC,uBAAuB;AAAA,SAEtCC,cAAc,EAAEC,eAAe,EAAEC,OAAO;AAEjD;AAEA,MAAMC,iBAAiB,GAAGJ,uBAAuB,CAAC,CAAC;AAEnD,OAAO,MAAMK,SAAS,GAAGvB,eAAe,CAAC;EACvCwB,IAAI,EAAE,WAAW;EACjBC,KAAK,EAAE;IACLC,QAAQ,EAAE;MACRC,IAAI,EAAE,CAACC,KAAK,CAA6B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QAAC;UAE5C,GAAGxD,WAAW,CAACU,KAAK,EAAEH,iBAAiB,CAAC;UACxCgD,IAAI,EAAEiE,IAAI;UACVnD,KAAK,EAAE;QAAC,IALDtC,KAAK;MASpB,CAAC,CAAC,GAAA8F,YAAA;QAAA,SAES;MAAsB,IAC9B9F,KAAK,CAAC,SAAS,CAAC,GAAGA,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,GAAA8F,YAAA,gBAAAG,gBAAA,aAAuB,EAEhE;IAIT,CAAC,CAAC;IAEF,OAAO;MACL9F,KAAK;MACLC,WAAW;MACXE,WAAW;MACXC,SAAS;MACTC,WAAW;MACXI,aAAa;MACbD;IACF,CAAC;EACH;AACF,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"YTreeView.mjs","names":["computed","defineComponent","onMounted","provide","ref","shallowRef","watch","watchEffect","useModelDuplex","useRender","differenceBetween","isColorValue","deepEqual","getObjectValueByPath","hasOwnProperty","debounce","chooseProps","YProgressBar","YTreeViewNode","pressYTreeViewNodeProps","filterTreeItem","filterTreeItems","getKeys","treeViewNodeProps","YTreeView","name","props","expanded","type","Array","default","active","multipleActive","Boolean","activeStrategy","String","selected","selectStrategy","returnItem","defaultExpand","Number","filter","Function","searchDebounceWait","emits","setup","_ref","slots","emit","expose","nodes","expandedSet","Set","selectedSet","activeSet","excludedSet","filterItemsFn","excludeItem","expandedCache","searchLoading","items","search","arguments","length","undefined","excluded","value","diff","forEach","key","updateExpanded","item","itemKey","itemText","itemChildren","expand","getDescendants","descendants","childKeys","push","childKey","getNodeKey","itemOrKey","updateNodes","parentKey","level","children","exist","existNode","vnode","indeterminate","node","map","child","add","issueVnodeState","to","isArray","delete","neo","deep","until","Object","entries","_ref2","emitExpanded","updateActive","event","inactiveKey","keys","requiredActive","size","activeSingleModifier","getModifierState","descendant","updateSelected","arr","emitActive","emitSelected","stateWatcher","stateSet","updater","emitter","valuesOfKey","v","old","oldKeys","nodeKey","neoKeys","k","oldSelected","clear","isExcluded","has","register","activeValue","selectedValue","renderLeaves","leaf","classes","styles","color","activeColor","_createVNode","_Fragment","_mergeProps","_createTextVNode"],"sources":["../../../src/components/tree-view/YTreeView.tsx"],"sourcesContent":["import {\r\n PropType,\r\n Ref,\r\n VNode,\r\n computed,\r\n defineComponent,\r\n onMounted,\r\n provide,\r\n ref,\r\n shallowRef,\r\n watch,\r\n watchEffect,\r\n} from 'vue';\r\n\r\nimport { useModelDuplex } from '../../composables/communication';\r\nimport { useRender } from '../../composables/component';\r\nimport { CandidateKey } from '../../types';\r\nimport { differenceBetween } from '../../util/array';\r\nimport { isColorValue } from '../../util/color';\r\nimport {\r\n deepEqual,\r\n getObjectValueByPath,\r\n hasOwnProperty,\r\n} from '../../util/common';\r\nimport { debounce } from '../../util/debounce';\r\nimport { chooseProps } from '../../util/vue-component';\r\nimport { YProgressBar } from '../progress-bar';\r\nimport { YTreeViewNode, pressYTreeViewNodeProps } from './YTreeViewNode';\r\nimport { NodeState, TreeviewFilterFn } from './types';\r\nimport { filterTreeItem, filterTreeItems, getKeys } from './util';\r\n\r\nimport './YTreeView.scss';\r\n\r\nconst treeViewNodeProps = pressYTreeViewNodeProps();\r\n\r\nexport const YTreeView = defineComponent({\r\n name: 'YTreeView',\r\n props: {\r\n expanded: {\r\n type: [Array] as PropType<CandidateKey[]>,\r\n default: () => [],\r\n },\r\n active: {\r\n type: [Array] as PropType<CandidateKey[]>,\r\n default: () => [],\r\n },\r\n multipleActive: Boolean,\r\n activeStrategy: {\r\n type: String as PropType<'independent' | 'cascade'>, // TODO: 'leaf'\r\n default: 'independent',\r\n },\r\n selected: {\r\n type: [Array] as PropType<CandidateKey[]>,\r\n default: () => [],\r\n },\r\n selectStrategy: {\r\n type: String as PropType<'independent' | 'cascade'>, // TODO: 'leaf'\r\n default: 'leaf',\r\n },\r\n returnItem: Boolean,\r\n defaultExpand: [Boolean, String, Number],\r\n filter: Function as PropType<TreeviewFilterFn>,\r\n searchDebounceWait: {\r\n type: Number as PropType<number>,\r\n default: 700,\r\n },\r\n ...treeViewNodeProps,\r\n },\r\n emits: ['update:expanded', 'update:active', 'update:selected'],\r\n setup(props, { slots, emit, expose }) {\r\n const nodes = ref<Record<CandidateKey, any>>({});\r\n\r\n const expanded = useModelDuplex(props, 'expanded');\r\n const active = useModelDuplex(props, 'active');\r\n const selected = useModelDuplex(props, 'selected');\r\n\r\n const expandedSet = ref(new Set<CandidateKey>());\r\n const selectedSet = ref(new Set<CandidateKey>());\r\n const activeSet = ref(new Set<CandidateKey>());\r\n const excludedSet = ref(new Set<CandidateKey>());\r\n const filterItemsFn = shallowRef(\r\n debounce(excludeItem, props.searchDebounceWait),\r\n );\r\n const expandedCache = ref<CandidateKey[]>([]);\r\n const searchLoading = shallowRef(false);\r\n\r\n function excludeItem(items: any[], search = '', filter = filterTreeItem) {\r\n const excluded = new Set<CandidateKey>();\r\n if (!search) {\r\n searchLoading.value = false;\r\n excludedSet.value = excluded;\r\n const diff = differenceBetween(expandedCache.value, [\r\n ...expandedSet.value,\r\n ]);\r\n diff.forEach((key) => {\r\n updateExpanded(key, false);\r\n });\r\n expandedCache.value.forEach((key) => {\r\n updateExpanded(key, true);\r\n });\r\n return;\r\n }\r\n for (const item of items) {\r\n filterTreeItems(\r\n filter,\r\n item,\r\n search ?? '',\r\n props.itemKey,\r\n props.itemText,\r\n props.itemChildren as string,\r\n excluded,\r\n );\r\n }\r\n excludedSet.value = excluded;\r\n searchLoading.value = false;\r\n expand();\r\n }\r\n\r\n watchEffect(() => {\r\n searchLoading.value = true;\r\n filterItemsFn.value(props.items, props.search, props.filter);\r\n });\r\n\r\n // Util Methods\r\n function getDescendants(\r\n key: CandidateKey,\r\n descendants: CandidateKey[] = [],\r\n ) {\r\n const { childKeys } = nodes.value[key];\r\n descendants.push(...childKeys);\r\n for (const childKey of childKeys) {\r\n descendants = getDescendants(childKey, descendants);\r\n }\r\n return descendants;\r\n }\r\n\r\n function getNodeKey(itemOrKey: any) {\r\n return props.returnItem\r\n ? getObjectValueByPath(itemOrKey, props.itemKey)\r\n : itemOrKey;\r\n }\r\n\r\n // State Methods\r\n function updateNodes(\r\n items: any[],\r\n parentKey: CandidateKey | null = null,\r\n level = 0,\r\n ) {\r\n for (const item of items) {\r\n const key = getObjectValueByPath(item, props.itemKey);\r\n const children =\r\n getObjectValueByPath(item, props.itemChildren as string) ?? [];\r\n const exist = hasOwnProperty(nodes.value, key);\r\n const existNode = exist\r\n ? nodes.value[key]\r\n : {\r\n vnode: null,\r\n selected: false,\r\n indeterminate: false,\r\n active: false,\r\n expanded: false,\r\n };\r\n const node: NodeState = {\r\n vnode: existNode.vnode,\r\n item,\r\n level,\r\n parentKey,\r\n childKeys: children.map((child: any) =>\r\n getObjectValueByPath(child, props.itemKey),\r\n ),\r\n expanded: children.length > 0 && existNode.expanded,\r\n active: existNode.active,\r\n indeterminate: existNode.indeterminate,\r\n selected: existNode.selected,\r\n };\r\n\r\n updateNodes(children, key, level + 1);\r\n\r\n nodes.value[key] = node;\r\n if (nodes.value[key].expanded) {\r\n expandedSet.value.add(key);\r\n }\r\n if (nodes.value[key].selected) {\r\n expandedSet.value.add(key);\r\n }\r\n if (nodes.value[key].active) {\r\n activeSet.value.add(key);\r\n }\r\n\r\n issueVnodeState(key);\r\n }\r\n }\r\n\r\n function updateExpanded(key: CandidateKey, to: boolean) {\r\n if (!(key in nodes.value)) return;\r\n const node = nodes.value[key];\r\n const children = getObjectValueByPath(\r\n node.item,\r\n props.itemChildren as string,\r\n );\r\n if (Array.isArray(children) && children.length > 0) {\r\n to ? expandedSet.value.add(key) : expandedSet.value.delete(key);\r\n node.expanded = to;\r\n issueVnodeState(key);\r\n }\r\n }\r\n\r\n watch(\r\n expandedSet,\r\n (neo) => {\r\n if (!props.search) {\r\n expandedCache.value = [...neo];\r\n }\r\n },\r\n { deep: true },\r\n );\r\n\r\n function expand(until: boolean | string | number = true) {\r\n Object.entries(nodes.value).forEach(([key, node]) => {\r\n if (until === true || until >= node.level) {\r\n updateExpanded(key, true);\r\n }\r\n });\r\n emitExpanded();\r\n return expandedSet.value;\r\n }\r\n\r\n function updateActive(key: CandidateKey, to: boolean, event?: MouseEvent) {\r\n if (!(key in nodes.value)) return;\r\n const node = nodes.value[key];\r\n let inactiveKey = !to ? key : '';\r\n if (!props.multipleActive) {\r\n [inactiveKey] = activeSet.value.keys();\r\n }\r\n if (to) {\r\n activeSet.value.add(key);\r\n node.active = true;\r\n } else {\r\n if (\r\n props.requiredActive &&\r\n activeSet.value.size === 1 &&\r\n key === inactiveKey\r\n ) {\r\n issueVnodeState(key);\r\n return;\r\n }\r\n }\r\n if (inactiveKey && inactiveKey in nodes.value) {\r\n activeSet.value.delete(inactiveKey);\r\n nodes.value[inactiveKey].active = false;\r\n issueVnodeState(inactiveKey);\r\n }\r\n\r\n if (\r\n props.activeSingleModifier &&\r\n event?.getModifierState(props.activeSingleModifier)\r\n ) {\r\n return;\r\n }\r\n\r\n if (props.multipleActive && props.activeStrategy === 'cascade') {\r\n for (const descendant of getDescendants(key)) {\r\n if (descendant in nodes.value) {\r\n to\r\n ? activeSet.value.add(descendant)\r\n : activeSet.value.delete(descendant);\r\n nodes.value[descendant].active = to;\r\n issueVnodeState(descendant);\r\n }\r\n }\r\n }\r\n }\r\n\r\n function updateSelected(key: CandidateKey, to: boolean) {\r\n if (!(key in nodes.value)) return;\r\n const node = nodes.value[key];\r\n\r\n if (to) {\r\n selectedSet.value.add(key);\r\n node.selected = true;\r\n }\r\n\r\n if (!to && key in nodes.value) {\r\n selectedSet.value.delete(key);\r\n nodes.value[key].selected = false;\r\n issueVnodeState(key);\r\n }\r\n\r\n if (props.selectStrategy === 'cascade') {\r\n for (const descendant of getDescendants(key)) {\r\n if (descendant in nodes.value) {\r\n to\r\n ? selectedSet.value.add(descendant)\r\n : selectedSet.value.delete(descendant);\r\n nodes.value[descendant].selected = to;\r\n issueVnodeState(descendant);\r\n }\r\n }\r\n }\r\n }\r\n\r\n function emitExpanded() {\r\n const arr = [...expandedSet.value];\r\n expanded.value = props.returnItem\r\n ? arr.map((key) => nodes.value[key].item)\r\n : arr;\r\n }\r\n\r\n function emitActive() {\r\n const arr = [...activeSet.value];\r\n active.value = props.returnItem\r\n ? arr.map((key) => nodes.value[key].item)\r\n : arr;\r\n }\r\n\r\n function emitSelected() {\r\n const arr = [...selectedSet.value];\r\n selected.value = props.returnItem\r\n ? arr.map((key) => nodes.value[key].item)\r\n : arr;\r\n }\r\n\r\n function stateWatcher(\r\n value: any[],\r\n stateSet: Ref<Set<CandidateKey>>,\r\n updater: (key: CandidateKey, to: boolean) => void,\r\n emitter: () => void,\r\n ) {\r\n const valuesOfKey = props.returnItem\r\n ? value.map((v) => getObjectValueByPath(v, props.itemKey))\r\n : value;\r\n const old = [...stateSet.value];\r\n if (deepEqual(old, valuesOfKey)) {\r\n return;\r\n }\r\n old.forEach((key) => updater(key, false));\r\n valuesOfKey.forEach((key) => updater(key, true));\r\n emitter();\r\n }\r\n\r\n watch(expanded, (neo) => {\r\n stateWatcher(neo, expandedSet, updateExpanded, emitExpanded);\r\n });\r\n\r\n watch(active, (neo) => {\r\n stateWatcher(neo, activeSet, updateActive, emitActive);\r\n });\r\n\r\n watch(selected, (neo) => {\r\n stateWatcher(neo, selectedSet, updateSelected, emitSelected);\r\n });\r\n\r\n watch(\r\n () => props.items,\r\n (neo: any[]) => {\r\n const oldKeys = Object.keys(nodes.value).map((nodeKey) =>\r\n getObjectValueByPath(nodes.value[nodeKey].item, props.itemKey),\r\n );\r\n const neoKeys = getKeys(\r\n neo,\r\n props.itemKey,\r\n props.itemChildren as string,\r\n );\r\n const diff = differenceBetween(oldKeys, neoKeys);\r\n if (diff.length < 1 && neoKeys.length < oldKeys.length) {\r\n return;\r\n }\r\n diff.forEach((k) => delete nodes.value[k]);\r\n\r\n // init\r\n const oldSelected = [...selectedSet.value];\r\n selectedSet.value.clear();\r\n expandedSet.value.clear();\r\n activeSet.value.clear();\r\n updateNodes(neo);\r\n if (!deepEqual(oldSelected, [...selectedSet.value])) {\r\n emitSelected();\r\n }\r\n },\r\n { deep: true },\r\n );\r\n\r\n // Search\r\n function isExcluded(key: CandidateKey) {\r\n return !!props.search && excludedSet.value.has(key);\r\n }\r\n\r\n // Provide & Issue\r\n function issueVnodeState(key: CandidateKey) {\r\n const node = nodes.value[key];\r\n if (node && node.vnode) {\r\n node.vnode.active = node.active;\r\n node.vnode.selected = node.selected;\r\n node.vnode.indeterminate = node.indeterminate;\r\n node.vnode.expanded = node.expanded;\r\n }\r\n }\r\n\r\n function register(key: CandidateKey, vnode: VNode) {\r\n if (nodes.value[key]) {\r\n nodes.value[key].vnode = vnode;\r\n }\r\n\r\n issueVnodeState(key);\r\n }\r\n\r\n updateNodes(props.items);\r\n\r\n for (const activeValue of props.active.map(getNodeKey)) {\r\n updateActive(activeValue, true);\r\n }\r\n\r\n for (const selectedValue of props.selected.map(getNodeKey)) {\r\n updateSelected(selectedValue, true);\r\n }\r\n\r\n provide('tree-view', {\r\n register,\r\n updateExpanded,\r\n updateActive,\r\n updateSelected,\r\n emitExpanded,\r\n emitActive,\r\n emitSelected,\r\n isExcluded,\r\n searchLoading,\r\n });\r\n\r\n const renderLeaves = computed(() => {\r\n return props.items.filter((leaf) => {\r\n return !isExcluded(getObjectValueByPath(leaf, props.itemKey));\r\n });\r\n });\r\n\r\n const classes = computed(() => {\r\n return {\r\n 'y-tree-view': true,\r\n };\r\n });\r\n\r\n const styles = computed(() => {\r\n let color = props.activeColor;\r\n if (props.activeColor && !isColorValue(props.activeColor)) {\r\n color = `var(--y-theme-${props.activeColor})`;\r\n }\r\n return {\r\n [`--y-tree-view__active-color`]: color,\r\n };\r\n });\r\n\r\n onMounted(() => {\r\n if (props.defaultExpand !== undefined) {\r\n expandedCache.value = [...expand(props.defaultExpand)];\r\n } else {\r\n expanded.value.forEach((v: any) => updateExpanded(getNodeKey(v), true));\r\n emitExpanded();\r\n }\r\n });\r\n\r\n expose({\r\n expand,\r\n });\r\n\r\n useRender(() => {\r\n return (\r\n <>\r\n <div class={classes.value} style={styles.value} role=\"tree\">\r\n {searchLoading.value && <YProgressBar indeterminate />}\r\n {renderLeaves.value.length > 0 ? (\r\n renderLeaves.value.map((leaf) => {\r\n return (\r\n <YTreeViewNode\r\n v-slots={slots}\r\n key={getObjectValueByPath(leaf, props.itemKey)}\r\n {...{\r\n ...chooseProps(props, treeViewNodeProps),\r\n item: leaf,\r\n level: 0,\r\n }}\r\n ></YTreeViewNode>\r\n );\r\n })\r\n ) : (\r\n <div class=\"y-tree-view__no-data\">\r\n {slots['no-data'] ? slots['no-data']() : <span>No Data</span>}\r\n </div>\r\n )}\r\n </div>\r\n </>\r\n );\r\n });\r\n\r\n return {\r\n nodes,\r\n expandedSet,\r\n selectedSet,\r\n activeSet,\r\n excludedSet,\r\n searchLoading,\r\n expandedCache,\r\n };\r\n },\r\n});\r\n\r\nexport type YTreeView = InstanceType<typeof YTreeView>;\r\n"],"mappings":";AAAA,SAIEA,QAAQ,EACRC,eAAe,EACfC,SAAS,EACTC,OAAO,EACPC,GAAG,EACHC,UAAU,EACVC,KAAK,EACLC,WAAW,QACN,KAAK;AAAC,SAEJC,cAAc;AAAA,SACdC,SAAS;AAAA,SAETC,iBAAiB;AAAA,SACjBC,YAAY;AAAA,SAEnBC,SAAS,EACTC,oBAAoB,EACpBC,cAAc;AAAA,SAEPC,QAAQ;AAAA,SACRC,WAAW;AAAA,SACXC,YAAY;AAAA,SACZC,aAAa,EAAEC,uBAAuB;AAAA,SAEtCC,cAAc,EAAEC,eAAe,EAAEC,OAAO;AAEjD;AAEA,MAAMC,iBAAiB,GAAGJ,uBAAuB,CAAC,CAAC;AAEnD,OAAO,MAAMK,SAAS,GAAGvB,eAAe,CAAC;EACvCwB,IAAI,EAAE,WAAW;EACjBC,KAAK,EAAE;IACLC,QAAQ,EAAE;MACRC,IAAI,EAAE,CAACC,KAAK,CAA6B;MACzCC,OAAO,EAAEA,CAAA,KAAM;IACjB,CAAC;IACDC,MAAM,EAAE;MACNH,IAAI,EAAE,CAACC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AA+H,WAAA;UAAA,OAGSpI,oBAAoB,CAAC6H,IAAI,EAAEhH,KAAK,CAAC8C,OAAO;QAAC;UAE5C,GAAGxD,WAAW,CAACU,KAAK,EAAEH,iBAAiB,CAAC;UACxCgD,IAAI,EAAEmE,IAAI;UACVrD,KAAK,EAAE;QAAC,IALDtC,KAAK;MASpB,CAAC,CAAC,GAAAgG,YAAA;QAAA,SAES;MAAsB,IAC9BhG,KAAK,CAAC,SAAS,CAAC,GAAGA,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,GAAAgG,YAAA,gBAAAG,gBAAA,aAAuB,EAEhE;IAIT,CAAC,CAAC;IAEF,OAAO;MACLhG,KAAK;MACLC,WAAW;MACXE,WAAW;MACXC,SAAS;MACTC,WAAW;MACXI,aAAa;MACbD;IACF,CAAC;EACH;AACF,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YTreeViewNode.mjs","names":["computed","defineComponent","h","inject","ref","pressItemsPropsOptions","useRender","getObjectValueByPath","propsFactory","YButton","YIconCheckbox","YIconExpand","YPlate","YTextHighlighter","YExpandVTransition","pressYTreeViewNodeProps","search","String","disableTransition","Boolean","enableActive","activeClass","Array","activeSingleModifier","activeColor","type","default","enableSelect","itemKey","YTreeViewNode","name","components","props","item","Object","level","Number","setup","_ref","slots","expose","treeView","expanded","active","selected","immediate","onClick","e","to","value","updateActive","myKey","emitActive","onClickExpand","stopPropagation","updateExpanded","emitExpanded","onClickSelect","updateSelected","emitSelected","children","itemChildren","imLeaf","length","classes","styles","contentText","itemText","slotProps","searchLoading","leaves","filter","leaf","isExcluded","map","key","indentSpacer","i","push","class","style","variation","checked","leading","text","keyword","trailing","disabled","role","undefined","created","register"],"sources":["../../../src/components/tree-view/YTreeViewNode.ts"],"sourcesContent":["import {\n PropType,\n VNodeArrayChildren,\n computed,\n defineComponent,\n h,\n inject,\n ref,\n} from 'vue';\n\nimport { pressItemsPropsOptions } from '../../abstract/items';\nimport { useRender } from '../../composables/component';\nimport { getObjectValueByPath } from '../../util/common';\nimport { propsFactory } from '../../util/vue-component';\nimport { YButton } from '../button';\nimport { YIconCheckbox, YIconExpand } from '../icons';\nimport { YPlate } from '../plate';\nimport YTextHighlighter from '../text-highlighter/YTextHighlighter';\nimport { YExpandVTransition } from '../transitions';\n\nexport const pressYTreeViewNodeProps = propsFactory(\n {\n search: String,\n disableTransition: Boolean,\n enableActive: Boolean,\n activeClass: [String, Array],\n activeSingleModifier: String,\n activeColor: {\n type: String,\n default: 'primary',\n },\n enableSelect: Boolean,\n ...pressItemsPropsOptions({\n itemKey: 'id',\n }),\n },\n 'YTreeViewNode',\n);\n\nexport const YTreeViewNode = defineComponent({\n name: 'YTreeNode',\n components: {\n YButton,\n YIconExpand,\n YPlate,\n YIconCheckbox,\n },\n props: {\n item: {\n type: Object as PropType<any>,\n },\n level: {\n type: Number as PropType<number>,\n default: 0,\n },\n ...pressYTreeViewNodeProps(),\n },\n setup(props, { slots, expose }) {\n const treeView = inject<any>('tree-view');\n\n const expanded = ref(false);\n const active = ref(false);\n const selected = ref(false);\n const immediate = ref(false);\n\n function onClick(e: MouseEvent) {\n const to = !active.value;\n active.value = to;\n treeView.updateActive(myKey.value, to, e);\n treeView.emitActive();\n }\n\n function onClickExpand(e: MouseEvent) {\n e.stopPropagation();\n const to = !expanded.value;\n expanded.value = to;\n treeView.updateExpanded(myKey.value, to);\n treeView.emitExpanded();\n }\n\n function onClickSelect(e: MouseEvent) {\n e.stopPropagation();\n const to = !selected.value;\n selected.value = to;\n treeView.updateSelected(myKey.value, to);\n treeView.emitSelected();\n }\n\n const children = computed(() => {\n return props.item?.[props.itemChildren as string] ?? [];\n });\n\n const imLeaf = computed(() => children.value.length < 1);\n\n const classes = computed(() => {\n return {\n 'y-tree-view-node': true,\n 'y-tree-view-node--leaf': imLeaf.value,\n 'y-tree-view-node--expanded': expanded.value,\n 'y-tree-view-node--active': active.value,\n };\n });\n\n const styles = computed(() => {\n return {\n '--tree-view-node--level': props.level,\n };\n });\n\n const contentText = computed(() => {\n return getObjectValueByPath(props.item, props.itemText) ?? '';\n });\n\n const slotProps = computed(() => {\n return {\n level: props.level,\n imLeaf: imLeaf.value,\n };\n });\n\n const searchLoading = computed(() => {\n return treeView.searchLoading.value;\n });\n\n useRender(() => {\n const leaves = children.value\n .filter((leaf: any) => {\n return !treeView.isExcluded(\n getObjectValueByPath(leaf, props.itemKey),\n );\n })\n .map((item: any) => {\n return h(\n YTreeViewNode,\n {\n ...props,\n level: (props.level ?? 0) + 1,\n item,\n key: getObjectValueByPath(item, props.itemKey),\n },\n slots,\n );\n });\n const indentSpacer: VNodeArrayChildren = [];\n for (let i = 0; i < props.level; i += 1) {\n indentSpacer.push(\n h('div', { class: 'y-tree-view-node__indent-spacer' }),\n );\n }\n return h(\n 'div',\n {\n class: classes.value,\n style: styles.value,\n '.role': 'treeitem',\n 'data-level': props.level,\n },\n [\n h(\n 'div',\n {\n class: 'y-tree-view-node__container',\n onClick: (e: MouseEvent) =>\n props.enableActive ? onClick(e) : void 0,\n },\n [\n h(YPlate),\n h('div', { class: 'y-tree-view-node__indents' }, indentSpacer),\n /* EXPAND */\n !imLeaf.value && leaves.length > 0\n ? h(\n YButton,\n {\n class: 'y-tree-view-node__expand-icon',\n variation: 'icon',\n onClick: (e: MouseEvent) => onClickExpand(e),\n },\n () => [\n slots['expand-icon']\n ? slots['expand-icon']()\n : h(YIconExpand),\n ],\n )\n : h('i', { class: 'y-tree-view-node__no-expand-icon' }),\n props.enableSelect &&\n h(\n 'div',\n {\n class: ['y-tree-view-node__select'],\n onClick: (e: MouseEvent) => onClickSelect(e),\n },\n [h(YIconCheckbox, { checked: selected.value })],\n ),\n /* CONTENT */\n h('div', { class: 'y-tree-view-node__content' }, [\n slots.leading &&\n h(\n 'div',\n { class: 'y-tree-view-node__leading' },\n slots.leading(slotProps.value),\n ),\n h(\n 'div',\n { class: 'y-tree-view-node__text' },\n slots.default\n ? slots.default?.({\n text: contentText.value,\n item: props.item,\n ...slotProps.value,\n })\n : props.search && !searchLoading.value\n ? h(YTextHighlighter, {\n text: contentText.value,\n keyword: props.search,\n })\n : contentText.value,\n ),\n slots.trailing &&\n h(\n 'div',\n { class: 'y-tree-view-node__trailing' },\n slots.trailing(),\n ),\n ]),\n ],\n ),\n /* CHILDREN */\n children.value.length > 0\n ? h(\n YExpandVTransition,\n { disabled: props.disableTransition },\n expanded.value\n ? () =>\n h(\n 'div',\n {\n class: { 'y-tree-view-node__leaves': true },\n role: 'tree',\n },\n leaves,\n )\n : undefined,\n )\n : undefined,\n ],\n );\n });\n\n const myKey = computed(() => {\n return getObjectValueByPath(props.item, props.itemKey);\n });\n\n expose({\n myKey,\n expanded,\n active,\n selected,\n immediate,\n });\n\n return {\n treeView,\n myKey,\n expanded,\n active,\n selected,\n immediate,\n };\n },\n created() {\n this.treeView?.register?.(this.myKey, this);\n },\n});\n\nexport type YTreeNode = InstanceType<typeof YTreeViewNode>;\n"],"mappings":"AAAA,SAGEA,QAAQ,EACRC,eAAe,EACfC,CAAC,EACDC,MAAM,EACNC,GAAG,QACE,KAAK;AAAC,SAEJC,sBAAsB;AAAA,SACtBC,SAAS;AAAA,SACTC,oBAAoB;AAAA,SACpBC,YAAY;AAAA,SACZC,OAAO;AAAA,SACPC,aAAa,EAAEC,WAAW;AAAA,SAC1BC,MAAM;AAAA,OACRC,gBAAgB;AAAA,SACdC,kBAAkB;AAE3B,OAAO,MAAMC,uBAAuB,GAAGP,YAAY,CACjD;EACEQ,MAAM,EAAEC,MAAM;EACdC,iBAAiB,EAAEC,OAAO;EAC1BC,YAAY,EAAED,OAAO;EACrBE,WAAW,EAAE,CAACJ,MAAM,EAAEK,KAAK,CAAC;EAC5BC,oBAAoB,EAAEN,MAAM;EAC5BO,WAAW,EAAE;IACXC,IAAI,EAAER,MAAM;IACZS,OAAO,EAAE;EACX,CAAC;EACDC,YAAY,EAAER,OAAO;EACrB,GAAGd,sBAAsB,CAAC;IACxBuB,OAAO,EAAE;EAC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QAAQ,GAAG,IAAI,CAACxC,KAAK,EAAE,IAAI,CAAC;EAC7C;AACF,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"YTreeViewNode.mjs","names":["computed","defineComponent","h","inject","ref","pressItemsPropsOptions","useRender","getObjectValueByPath","propsFactory","YButton","YIconCheckbox","YIconExpand","YPlate","YTextHighlighter","YExpandVTransition","pressYTreeViewNodeProps","search","String","disableTransition","Boolean","enableActive","activeClass","Array","activeSingleModifier","requiredActive","activeColor","type","default","enableSelect","itemKey","YTreeViewNode","name","components","props","item","Object","level","Number","setup","_ref","slots","expose","treeView","expanded","active","selected","immediate","onClick","e","to","value","updateActive","myKey","emitActive","onClickExpand","stopPropagation","updateExpanded","emitExpanded","onClickSelect","updateSelected","emitSelected","children","itemChildren","imLeaf","length","classes","styles","contentText","itemText","slotProps","searchLoading","leaves","filter","leaf","isExcluded","map","key","indentSpacer","i","push","class","style","variation","checked","leading","text","keyword","trailing","disabled","role","undefined","created","register"],"sources":["../../../src/components/tree-view/YTreeViewNode.ts"],"sourcesContent":["import {\r\n PropType,\r\n VNodeArrayChildren,\r\n computed,\r\n defineComponent,\r\n h,\r\n inject,\r\n ref,\r\n} from 'vue';\r\n\r\nimport { pressItemsPropsOptions } from '../../abstract/items';\r\nimport { useRender } from '../../composables/component';\r\nimport { getObjectValueByPath } from '../../util/common';\r\nimport { propsFactory } from '../../util/vue-component';\r\nimport { YButton } from '../button';\r\nimport { YIconCheckbox, YIconExpand } from '../icons';\r\nimport { YPlate } from '../plate';\r\nimport YTextHighlighter from '../text-highlighter/YTextHighlighter';\r\nimport { YExpandVTransition } from '../transitions';\r\n\r\nexport const pressYTreeViewNodeProps = propsFactory(\r\n {\r\n search: String,\r\n disableTransition: Boolean,\r\n enableActive: Boolean,\r\n activeClass: [String, Array],\r\n activeSingleModifier: String,\r\n requiredActive: Boolean,\r\n activeColor: {\r\n type: String,\r\n default: 'primary',\r\n },\r\n enableSelect: Boolean,\r\n ...pressItemsPropsOptions({\r\n itemKey: 'id',\r\n }),\r\n },\r\n 'YTreeViewNode',\r\n);\r\n\r\nexport const YTreeViewNode = defineComponent({\r\n name: 'YTreeNode',\r\n components: {\r\n YButton,\r\n YIconExpand,\r\n YPlate,\r\n YIconCheckbox,\r\n },\r\n props: {\r\n item: {\r\n type: Object as PropType<any>,\r\n },\r\n level: {\r\n type: Number as PropType<number>,\r\n default: 0,\r\n },\r\n ...pressYTreeViewNodeProps(),\r\n },\r\n setup(props, { slots, expose }) {\r\n const treeView = inject<any>('tree-view');\r\n\r\n const expanded = ref(false);\r\n const active = ref(false);\r\n const selected = ref(false);\r\n const immediate = ref(false);\r\n\r\n function onClick(e: MouseEvent) {\r\n const to = !active.value;\r\n active.value = to;\r\n treeView.updateActive(myKey.value, to, e);\r\n treeView.emitActive();\r\n }\r\n\r\n function onClickExpand(e: MouseEvent) {\r\n e.stopPropagation();\r\n const to = !expanded.value;\r\n expanded.value = to;\r\n treeView.updateExpanded(myKey.value, to);\r\n treeView.emitExpanded();\r\n }\r\n\r\n function onClickSelect(e: MouseEvent) {\r\n e.stopPropagation();\r\n const to = !selected.value;\r\n selected.value = to;\r\n treeView.updateSelected(myKey.value, to);\r\n treeView.emitSelected();\r\n }\r\n\r\n const children = computed(() => {\r\n return props.item?.[props.itemChildren as string] ?? [];\r\n });\r\n\r\n const imLeaf = computed(() => children.value.length < 1);\r\n\r\n const classes = computed(() => {\r\n return {\r\n 'y-tree-view-node': true,\r\n 'y-tree-view-node--leaf': imLeaf.value,\r\n 'y-tree-view-node--expanded': expanded.value,\r\n 'y-tree-view-node--active': active.value,\r\n };\r\n });\r\n\r\n const styles = computed(() => {\r\n return {\r\n '--tree-view-node--level': props.level,\r\n };\r\n });\r\n\r\n const contentText = computed(() => {\r\n return getObjectValueByPath(props.item, props.itemText) ?? '';\r\n });\r\n\r\n const slotProps = computed(() => {\r\n return {\r\n level: props.level,\r\n imLeaf: imLeaf.value,\r\n };\r\n });\r\n\r\n const searchLoading = computed(() => {\r\n return treeView.searchLoading.value;\r\n });\r\n\r\n useRender(() => {\r\n const leaves = children.value\r\n .filter((leaf: any) => {\r\n return !treeView.isExcluded(\r\n getObjectValueByPath(leaf, props.itemKey),\r\n );\r\n })\r\n .map((item: any) => {\r\n return h(\r\n YTreeViewNode,\r\n {\r\n ...props,\r\n level: (props.level ?? 0) + 1,\r\n item,\r\n key: getObjectValueByPath(item, props.itemKey),\r\n },\r\n slots,\r\n );\r\n });\r\n const indentSpacer: VNodeArrayChildren = [];\r\n for (let i = 0; i < props.level; i += 1) {\r\n indentSpacer.push(\r\n h('div', { class: 'y-tree-view-node__indent-spacer' }),\r\n );\r\n }\r\n return h(\r\n 'div',\r\n {\r\n class: classes.value,\r\n style: styles.value,\r\n '.role': 'treeitem',\r\n 'data-level': props.level,\r\n },\r\n [\r\n h(\r\n 'div',\r\n {\r\n class: 'y-tree-view-node__container',\r\n onClick: (e: MouseEvent) =>\r\n props.enableActive ? onClick(e) : void 0,\r\n },\r\n [\r\n h(YPlate),\r\n h('div', { class: 'y-tree-view-node__indents' }, indentSpacer),\r\n /* EXPAND */\r\n !imLeaf.value && leaves.length > 0\r\n ? h(\r\n YButton,\r\n {\r\n class: 'y-tree-view-node__expand-icon',\r\n variation: 'icon',\r\n onClick: (e: MouseEvent) => onClickExpand(e),\r\n },\r\n () => [\r\n slots['expand-icon']\r\n ? slots['expand-icon']()\r\n : h(YIconExpand),\r\n ],\r\n )\r\n : h('i', { class: 'y-tree-view-node__no-expand-icon' }),\r\n props.enableSelect &&\r\n h(\r\n 'div',\r\n {\r\n class: ['y-tree-view-node__select'],\r\n onClick: (e: MouseEvent) => onClickSelect(e),\r\n },\r\n [h(YIconCheckbox, { checked: selected.value })],\r\n ),\r\n /* CONTENT */\r\n h('div', { class: 'y-tree-view-node__content' }, [\r\n slots.leading &&\r\n h(\r\n 'div',\r\n { class: 'y-tree-view-node__leading' },\r\n slots.leading(slotProps.value),\r\n ),\r\n h(\r\n 'div',\r\n { class: 'y-tree-view-node__text' },\r\n slots.default\r\n ? slots.default?.({\r\n text: contentText.value,\r\n item: props.item,\r\n ...slotProps.value,\r\n })\r\n : props.search && !searchLoading.value\r\n ? h(YTextHighlighter, {\r\n text: contentText.value,\r\n keyword: props.search,\r\n })\r\n : contentText.value,\r\n ),\r\n slots.trailing &&\r\n h(\r\n 'div',\r\n { class: 'y-tree-view-node__trailing' },\r\n slots.trailing(),\r\n ),\r\n ]),\r\n ],\r\n ),\r\n /* CHILDREN */\r\n children.value.length > 0\r\n ? h(\r\n YExpandVTransition,\r\n { disabled: props.disableTransition },\r\n expanded.value\r\n ? () =>\r\n h(\r\n 'div',\r\n {\r\n class: { 'y-tree-view-node__leaves': true },\r\n role: 'tree',\r\n },\r\n leaves,\r\n )\r\n : undefined,\r\n )\r\n : undefined,\r\n ],\r\n );\r\n });\r\n\r\n const myKey = computed(() => {\r\n return getObjectValueByPath(props.item, props.itemKey);\r\n });\r\n\r\n expose({\r\n myKey,\r\n expanded,\r\n active,\r\n selected,\r\n immediate,\r\n });\r\n\r\n return {\r\n treeView,\r\n myKey,\r\n expanded,\r\n active,\r\n selected,\r\n immediate,\r\n };\r\n },\r\n created() {\r\n this.treeView?.register?.(this.myKey, this);\r\n },\r\n});\r\n\r\nexport type YTreeNode = InstanceType<typeof YTreeViewNode>;\r\n"],"mappings":"AAAA,SAGEA,QAAQ,EACRC,eAAe,EACfC,CAAC,EACDC,MAAM,EACNC,GAAG,QACE,KAAK;AAAC,SAEJC,sBAAsB;AAAA,SACtBC,SAAS;AAAA,SACTC,oBAAoB;AAAA,SACpBC,YAAY;AAAA,SACZC,OAAO;AAAA,SACPC,aAAa,EAAEC,WAAW;AAAA,SAC1BC,MAAM;AAAA,OACRC,gBAAgB;AAAA,SACdC,kBAAkB;AAE3B,OAAO,MAAMC,uBAAuB,GAAGP,YAAY,CACjD;EACEQ,MAAM,EAAEC,MAAM;EACdC,iBAAiB,EAAEC,OAAO;EAC1BC,YAAY,EAAED,OAAO;EACrBE,WAA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CAAC;MACLW,KAAK;MACLT,QAAQ;MACRC,MAAM;MACNC,QAAQ;MACRC;IACF,CAAC,CAAC;IAEF,OAAO;MACLJ,QAAQ;MACRU,KAAK;MACLT,QAAQ;MACRC,MAAM;MACNC,QAAQ;MACRC;IACF,CAAC;EACH,CAAC;EACD6C,OAAOA,CAAA,EAAG;IACR,IAAI,CAACjD,QAAQ,EAAEkD,QAAQ,GAAG,IAAI,CAACxC,KAAK,EAAE,IAAI,CAAC;EAC7C;AACF,CAAC,CAAC"}
|
|
@@ -43,4 +43,13 @@ export function useModelDuplex(props) {
|
|
|
43
43
|
});
|
|
44
44
|
return model;
|
|
45
45
|
}
|
|
46
|
+
export function useProvided(props, prop, provided) {
|
|
47
|
+
const internal = useModelDuplex(props, prop, props[prop] ?? provided.value);
|
|
48
|
+
watch(provided, value => {
|
|
49
|
+
if (props[prop] == null) {
|
|
50
|
+
internal.value = value;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return internal;
|
|
54
|
+
}
|
|
46
55
|
//# sourceMappingURL=communication.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"communication.mjs","names":["computed","getCurrentInstance","ref","toRaw","watch","hasOwnProperty","kebabToCamel","toKebabCase","useToggleScope","useModelDuplex","props","prop","arguments","length","undefined","defaultValue","getIn","v","setOut","vm","kebabProp","property","txValue","getProp","isDefinedProp","registeredProps","vnode","value","model","get","set","neo","current","emit","Object","defineProperty"],"sources":["../../src/composables/communication.ts"],"sourcesContent":["import { computed, getCurrentInstance, ref, toRaw, watch } from 'vue';\n\nimport { hasOwnProperty } from '../util/common';\nimport { kebabToCamel, toKebabCase } from '../util/string';\nimport { useToggleScope } from './scope';\n\nexport function useModelDuplex(\n props: any,\n prop: string = 'modelValue',\n defaultValue?: any,\n getIn: (value?: any) => any = (v: any) => v,\n setOut: (value: any) => any = (v: any) => v,\n) {\n const vm = getCurrentInstance()!;\n const kebabProp = toKebabCase(prop);\n const property = kebabProp === prop ? kebabToCamel(prop) : prop;\n const txValue = ref(\n props[property] !== undefined ? props[property] : defaultValue,\n );\n\n function getProp() {\n return props[property];\n }\n\n const isDefinedProp = computed(() => {\n getProp();\n const registeredProps = vm.vnode.props;\n return (\n (hasOwnProperty(registeredProps, kebabProp) ||\n hasOwnProperty(registeredProps, property)) &&\n (hasOwnProperty(registeredProps, `onUpdate:${kebabProp}`) ||\n hasOwnProperty(registeredProps, `onUpdate:${property}`))\n );\n });\n\n useToggleScope(\n () => !isDefinedProp.value,\n () => {\n watch(\n () => getProp(),\n (value) => {\n txValue.value = value;\n },\n );\n },\n );\n\n const model = computed({\n get(): any {\n return getIn(isDefinedProp.value ? getProp() : txValue.value);\n },\n set(value) {\n const neo = setOut(value);\n const current = toRaw(isDefinedProp.value ? getProp() : txValue.value);\n if (current === neo || getIn(current) === value) {\n return;\n }\n txValue.value = neo;\n vm?.emit(`update:${property}`, neo);\n },\n });\n\n Object.defineProperty(model, 'rxValue', {\n get: () => (isDefinedProp.value ? getProp() : txValue.value),\n });\n\n return model;\n}\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,kBAAkB,EAAEC,GAAG,EAAEC,KAAK,EAAEC,KAAK,QAAQ,KAAK;AAAC,
|
|
1
|
+
{"version":3,"file":"communication.mjs","names":["computed","getCurrentInstance","ref","toRaw","watch","hasOwnProperty","kebabToCamel","toKebabCase","useToggleScope","useModelDuplex","props","prop","arguments","length","undefined","defaultValue","getIn","v","setOut","vm","kebabProp","property","txValue","getProp","isDefinedProp","registeredProps","vnode","value","model","get","set","neo","current","emit","Object","defineProperty","useProvided","provided","internal"],"sources":["../../src/composables/communication.ts"],"sourcesContent":["import { computed, getCurrentInstance, ref, toRaw, watch } from 'vue';\r\nimport type { Ref } from 'vue';\r\n\r\nimport { hasOwnProperty } from '../util/common';\r\nimport { kebabToCamel, toKebabCase } from '../util/string';\r\nimport { useToggleScope } from './scope';\r\n\r\nexport function useModelDuplex(\r\n props: any,\r\n prop: string = 'modelValue',\r\n defaultValue?: any,\r\n getIn: (value?: any) => any = (v: any) => v,\r\n setOut: (value: any) => any = (v: any) => v,\r\n) {\r\n const vm = getCurrentInstance()!;\r\n const kebabProp = toKebabCase(prop);\r\n const property = kebabProp === prop ? kebabToCamel(prop) : prop;\r\n const txValue = ref(\r\n props[property] !== undefined ? props[property] : defaultValue,\r\n );\r\n\r\n function getProp() {\r\n return props[property];\r\n }\r\n\r\n const isDefinedProp = computed(() => {\r\n getProp();\r\n const registeredProps = vm.vnode.props;\r\n return (\r\n (hasOwnProperty(registeredProps, kebabProp) ||\r\n hasOwnProperty(registeredProps, property)) &&\r\n (hasOwnProperty(registeredProps, `onUpdate:${kebabProp}`) ||\r\n hasOwnProperty(registeredProps, `onUpdate:${property}`))\r\n );\r\n });\r\n\r\n useToggleScope(\r\n () => !isDefinedProp.value,\r\n () => {\r\n watch(\r\n () => getProp(),\r\n (value) => {\r\n txValue.value = value;\r\n },\r\n );\r\n },\r\n );\r\n\r\n const model = computed({\r\n get(): any {\r\n return getIn(isDefinedProp.value ? getProp() : txValue.value);\r\n },\r\n set(value) {\r\n const neo = setOut(value);\r\n const current = toRaw(isDefinedProp.value ? getProp() : txValue.value);\r\n if (current === neo || getIn(current) === value) {\r\n return;\r\n }\r\n txValue.value = neo;\r\n vm?.emit(`update:${property}`, neo);\r\n },\r\n });\r\n\r\n Object.defineProperty(model, 'rxValue', {\r\n get: () => (isDefinedProp.value ? getProp() : txValue.value),\r\n });\r\n\r\n return model;\r\n}\r\n\r\nexport function useProvided<T>(props: any, prop: string, provided: Ref<T>) {\r\n const internal = useModelDuplex(props, prop, props[prop] ?? provided.value);\r\n\r\n watch(provided, (value) => {\r\n if (props[prop] == null) {\r\n internal.value = value;\r\n }\r\n });\r\n return internal;\r\n}\r\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,kBAAkB,EAAEC,GAAG,EAAEC,KAAK,EAAEC,KAAK,QAAQ,KAAK;AAAC,SAG7DC,cAAc;AAAA,SACdC,YAA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3EvB,KAAK,CAACiC,QAAQ,EAAGV,KAAK,IAAK;IACzB,IAAIjB,KAAK,CAACC,IAAI,CAAC,IAAI,IAAI,EAAE;MACvB2B,QAAQ,CAACX,KAAK,GAAGA,KAAK;IACxB;EACF,CAAC,CAAC;EACF,OAAOW,QAAQ;AACjB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { reactive, watch } from 'vue';
|
|
2
|
+
export function constructAdapter(options, locale) {
|
|
3
|
+
const instance = reactive(typeof options.adapter === 'function' ? new options.adapter({
|
|
4
|
+
locale: options.locale[locale.locale.value] ?? locale.locale.value,
|
|
5
|
+
formats: options.formats
|
|
6
|
+
}) : options.adapter);
|
|
7
|
+
watch(locale.locale, value => {
|
|
8
|
+
instance.locale = options.locale[value] ?? value ?? instance.locale;
|
|
9
|
+
});
|
|
10
|
+
return instance;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=factory.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.mjs","names":["reactive","watch","constructAdapter","options","locale","instance","adapter","value","formats"],"sources":["../../../src/composables/date/factory.ts"],"sourcesContent":["import { reactive, watch } from 'vue';\r\n\r\nimport { LocaleModule } from '../../i18n/types';\r\n\r\nexport function constructAdapter(options: any, locale: LocaleModule) {\r\n const instance = reactive(\r\n typeof options.adapter === 'function'\r\n ? new options.adapter({\r\n locale: options.locale[locale.locale.value] ?? locale.locale.value,\r\n formats: options.formats,\r\n })\r\n : options.adapter,\r\n );\r\n\r\n watch(locale.locale, (value) => {\r\n instance.locale = options.locale[value] ?? value ?? instance.locale;\r\n });\r\n\r\n return instance;\r\n}\r\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,KAAK,QAAQ,KAAK;AAIrC,OAAO,SAASC,gBAAgBA,CAACC,OAAY,EAAEC,MAAoB,EAAE;EACnE,MAAMC,QAAQ,GAAGL,QAAQ,CACvB,OAAOG,OAAO,CAACG,OAAO,KAAK,UAAU,GACjC,IAAIH,OAAO,CAACG,OAAO,CAAC;IAClBF,MAAM,EAAED,OAAO,CAACC,MAAM,CAACA,MAAM,CAACA,MAAM,CAACG,KAAK,CAAC,IAAIH,MAAM,CAACA,MAAM,CAACG,KAAK;IAClEC,OAAO,EAAEL,OAAO,CAACK;EACnB,CAAC,CAAC,GACFL,OAAO,CAACG,OACd,CAAC;EAEDL,KAAK,CAACG,MAAM,CAACA,MAAM,EAAGG,KAAK,IAAK;IAC9BF,QAAQ,CAACD,MAAM,GAAGD,OAAO,CAACC,MAAM,CAACG,KAAK,CAAC,IAAIA,KAAK,IAAIF,QAAQ,CAACD,MAAM;EACrE,CAAC,CAAC;EAEF,OAAOC,QAAQ;AACjB"}
|