init component
This commit is contained in:
1
node_modules/buetify/lib/composables/model/index.d.ts
generated
vendored
Executable file
1
node_modules/buetify/lib/composables/model/index.d.ts
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
export * from './useModel';
|
||||
2
node_modules/buetify/lib/composables/model/index.js
generated
vendored
Executable file
2
node_modules/buetify/lib/composables/model/index.js
generated
vendored
Executable file
@@ -0,0 +1,2 @@
|
||||
export * from './useModel';
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/buetify/lib/composables/model/index.js.map
generated
vendored
Executable file
1
node_modules/buetify/lib/composables/model/index.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/composables/model/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAd","sourcesContent":["export * from './useModel';\n"],"sourceRoot":"","file":"index.js"}
|
||||
35
node_modules/buetify/lib/composables/model/useModel.d.ts
generated
vendored
Executable file
35
node_modules/buetify/lib/composables/model/useModel.d.ts
generated
vendored
Executable file
@@ -0,0 +1,35 @@
|
||||
import { FunctionN, Lazy } from 'fp-ts/lib/function';
|
||||
import { PropType, Ref } from 'vue';
|
||||
export declare function getUseModelPropsDefinition<T>(): {
|
||||
modelValue: {
|
||||
type: PropType<T>;
|
||||
required: false;
|
||||
};
|
||||
'onUpdate:modelValue': {
|
||||
type: PropType<FunctionN<[T], void>>;
|
||||
default: Lazy<FunctionN<[T], void>>;
|
||||
};
|
||||
};
|
||||
export declare function getUseModelPropsDefinition<T, ValueKey extends string, UpdateKey extends string>(valueKey: ValueKey, updateKey: UpdateKey): {
|
||||
[K in ValueKey]: {
|
||||
type: PropType<T>;
|
||||
required: false;
|
||||
};
|
||||
} & {
|
||||
[K in UpdateKey]: {
|
||||
type: PropType<FunctionN<[T], void>>;
|
||||
default: Lazy<FunctionN<[T], void>>;
|
||||
};
|
||||
};
|
||||
export declare type UseModelProps<T, ValueKey extends string = 'modelValue', UpdateKey extends string = 'onUpdate:modelValue'> = {
|
||||
[K in ValueKey]?: T | undefined;
|
||||
} & {
|
||||
[K in UpdateKey]: FunctionN<[T], void>;
|
||||
};
|
||||
export declare function useModel<T>(props: UseModelProps<T>): Model<T>;
|
||||
export declare function useModel<T, ValueKey extends string, UpdateKey extends string>(props: UseModelProps<T, ValueKey, UpdateKey>, valueKey: ValueKey, updateKey: UpdateKey): Model<T>;
|
||||
export declare type Model<T> = {
|
||||
set: FunctionN<[T], void>;
|
||||
modelValue: Ref<T | undefined>;
|
||||
onNativeInput: FunctionN<[Event], void>;
|
||||
};
|
||||
53
node_modules/buetify/lib/composables/model/useModel.js
generated
vendored
Executable file
53
node_modules/buetify/lib/composables/model/useModel.js
generated
vendored
Executable file
@@ -0,0 +1,53 @@
|
||||
import { constant, constVoid } from 'fp-ts/lib/function';
|
||||
import { shallowRef, watch, toRef, computed } from 'vue';
|
||||
import { exists, isObject } from '../../utils/helpers';
|
||||
export function getUseModelPropsDefinition(valueKey = 'modelValue', updateKey = 'onUpdate:modelValue') {
|
||||
return {
|
||||
[valueKey]: null,
|
||||
[updateKey]: {
|
||||
type: Function,
|
||||
default: constant(constVoid)
|
||||
}
|
||||
};
|
||||
}
|
||||
export function useModel(props, valueKey = 'modelValue', updateKey = 'onUpdate:modelValue') {
|
||||
const internalValue = shallowRef(props[valueKey]);
|
||||
watch(toRef(props, valueKey), newVal => {
|
||||
internalValue.value = newVal;
|
||||
});
|
||||
const value = computed({
|
||||
get() {
|
||||
return internalValue.value;
|
||||
},
|
||||
|
||||
set(val) {
|
||||
internalValue.value = val;
|
||||
|
||||
if (val !== undefined) {
|
||||
props[updateKey](val);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
function onUpdate(e) {
|
||||
// eslint-disable-next-line
|
||||
// @ts-ignore-next-line
|
||||
if (isObject(e.target) && exists(e.target.value)) {
|
||||
// eslint-disable-next-line
|
||||
// @ts-ignore-next-line
|
||||
value.value = e.target.value;
|
||||
}
|
||||
}
|
||||
|
||||
function set(val) {
|
||||
value.value = val;
|
||||
}
|
||||
|
||||
return {
|
||||
set,
|
||||
modelValue: value,
|
||||
onNativeInput: onUpdate
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=useModel.js.map
|
||||
1
node_modules/buetify/lib/composables/model/useModel.js.map
generated
vendored
Executable file
1
node_modules/buetify/lib/composables/model/useModel.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/composables/model/useModel.ts"],"names":[],"mappings":"AAAA,SAAS,QAAT,EAAmB,SAAnB,QAAqD,oBAArD;AACA,SAAmB,UAAnB,EAA+B,KAA/B,EAAsC,KAAtC,EAAkD,QAAlD,QAAkE,KAAlE;AACA,SAAS,MAAT,EAAiB,QAAjB,QAAiC,qBAAjC;AA2BA,OAAM,SAAU,0BAAV,CAKJ,QAAA,GAAqB,YALjB,EAK2C,SAAA,GAAuB,qBALlE,EAKoG;AACxG,SAAO;AACL,KAAC,QAAD,GAAY,IADP;AAEL,KAAC,SAAD,GAAa;AACX,MAAA,IAAI,EAAE,QADK;AAEX,MAAA,OAAO,EAAE,QAAQ,CAAC,SAAD;AAFN;AAFR,GAAP;AAOD;AAcD,OAAM,SAAU,QAAV,CACJ,KADI,EAEJ,QAAA,GAAqB,YAFjB,EAGJ,SAAA,GAAuB,qBAHnB,EAGqD;AAEzD,QAAM,aAAa,GAAuB,UAAU,CAAC,KAAK,CAAC,QAAD,CAAN,CAApD;AAEA,EAAA,KAAK,CAAC,KAAK,CAAC,KAAD,EAAQ,QAAR,CAAN,EAAyB,MAAM,IAAG;AACrC,IAAA,aAAa,CAAC,KAAd,GAAsB,MAAtB;AACD,GAFI,CAAL;AAIA,QAAM,KAAK,GAAG,QAAQ,CAAC;AACrB,IAAA,GAAG,GAAA;AACD,aAAO,aAAa,CAAC,KAArB;AACD,KAHoB;;AAIrB,IAAA,GAAG,CAAC,GAAD,EAAmB;AACpB,MAAA,aAAa,CAAC,KAAd,GAAsB,GAAtB;;AACA,UAAI,GAAG,KAAK,SAAZ,EAAuB;AACrB,QAAA,KAAK,CAAC,SAAD,CAAL,CAAiB,GAAjB;AACD;AACF;;AAToB,GAAD,CAAtB;;AAYA,WAAS,QAAT,CAAkB,CAAlB,EAA0B;AACxB;AACA;AACA,QAAI,QAAQ,CAAC,CAAC,CAAC,MAAH,CAAR,IAAsB,MAAM,CAAC,CAAC,CAAC,MAAF,CAAS,KAAV,CAAhC,EAAkD;AAChD;AACA;AACA,MAAA,KAAK,CAAC,KAAN,GAAc,CAAC,CAAC,MAAF,CAAS,KAAvB;AACD;AACF;;AAED,WAAS,GAAT,CAAa,GAAb,EAAmB;AACjB,IAAA,KAAK,CAAC,KAAN,GAAc,GAAd;AACD;;AAED,SAAO;AACL,IAAA,GADK;AAEL,IAAA,UAAU,EAAE,KAFP;AAGL,IAAA,aAAa,EAAE;AAHV,GAAP;AAKD","sourcesContent":["import { constant, constVoid, FunctionN, Lazy } from 'fp-ts/lib/function';\nimport { PropType, shallowRef, watch, toRef, Ref, computed } from 'vue';\nimport { exists, isObject } from '../../utils/helpers';\n\nexport function getUseModelPropsDefinition<T>(): {\n modelValue: {\n type: PropType<T>;\n required: false;\n };\n 'onUpdate:modelValue': {\n type: PropType<FunctionN<[T], void>>;\n default: Lazy<FunctionN<[T], void>>;\n };\n};\nexport function getUseModelPropsDefinition<T, ValueKey extends string, UpdateKey extends string>(\n valueKey: ValueKey,\n updateKey: UpdateKey\n): {\n [K in ValueKey]: {\n type: PropType<T>;\n required: false;\n };\n} &\n {\n [K in UpdateKey]: {\n type: PropType<FunctionN<[T], void>>;\n default: Lazy<FunctionN<[T], void>>;\n };\n };\nexport function getUseModelPropsDefinition<\n T,\n ValueKey extends string = 'modelValue',\n UpdateKey extends string = 'onUpdate:modelValue'\n // eslint-disable-next-line\n>(valueKey: ValueKey = 'modelValue' as ValueKey, updateKey: UpdateKey = 'onUpdate:modelValue' as UpdateKey): any {\n return {\n [valueKey]: null,\n [updateKey]: {\n type: Function,\n default: constant(constVoid)\n }\n };\n}\n\nexport type UseModelProps<\n T,\n ValueKey extends string = 'modelValue',\n UpdateKey extends string = 'onUpdate:modelValue'\n> = { [K in ValueKey]?: T | undefined } & { [K in UpdateKey]: FunctionN<[T], void> };\n\nexport function useModel<T>(props: UseModelProps<T>): Model<T>;\nexport function useModel<T, ValueKey extends string, UpdateKey extends string>(\n props: UseModelProps<T, ValueKey, UpdateKey>,\n valueKey: ValueKey,\n updateKey: UpdateKey\n): Model<T>;\nexport function useModel<T, ValueKey extends string = 'modelValue', UpdateKey extends string = 'onUpdate:modelValue'>(\n props: UseModelProps<T, ValueKey, UpdateKey>,\n valueKey: ValueKey = 'modelValue' as ValueKey,\n updateKey: UpdateKey = 'onUpdate:modelValue' as UpdateKey\n): Model<T> {\n const internalValue: Ref<T | undefined> = shallowRef(props[valueKey]);\n\n watch(toRef(props, valueKey), newVal => {\n internalValue.value = newVal;\n });\n\n const value = computed({\n get() {\n return internalValue.value;\n },\n set(val: T | undefined) {\n internalValue.value = val;\n if (val !== undefined) {\n props[updateKey](val);\n }\n }\n });\n\n function onUpdate(e: Event) {\n // eslint-disable-next-line\n // @ts-ignore-next-line\n if (isObject(e.target) && exists(e.target.value)) {\n // eslint-disable-next-line\n // @ts-ignore-next-line\n value.value = e.target.value;\n }\n }\n\n function set(val: T) {\n value.value = val;\n }\n\n return {\n set,\n modelValue: value,\n onNativeInput: onUpdate\n };\n}\n\nexport type Model<T> = {\n set: FunctionN<[T], void>;\n modelValue: Ref<T | undefined>;\n onNativeInput: FunctionN<[Event], void>;\n};\n"],"sourceRoot":"","file":"useModel.js"}
|
||||
Reference in New Issue
Block a user