init component
This commit is contained in:
2
node_modules/buetify/lib/composables/fieldData/index.d.ts
generated
vendored
Executable file
2
node_modules/buetify/lib/composables/fieldData/index.d.ts
generated
vendored
Executable file
@@ -0,0 +1,2 @@
|
||||
export * from './provideFieldData';
|
||||
export * from './useFieldData';
|
||||
3
node_modules/buetify/lib/composables/fieldData/index.js
generated
vendored
Executable file
3
node_modules/buetify/lib/composables/fieldData/index.js
generated
vendored
Executable file
@@ -0,0 +1,3 @@
|
||||
export * from './provideFieldData';
|
||||
export * from './useFieldData';
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/buetify/lib/composables/fieldData/index.js.map
generated
vendored
Executable file
1
node_modules/buetify/lib/composables/fieldData/index.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/composables/fieldData/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAd;AACA,cAAc,gBAAd","sourcesContent":["export * from './provideFieldData';\nexport * from './useFieldData';\n"],"sourceRoot":"","file":"index.js"}
|
||||
56
node_modules/buetify/lib/composables/fieldData/provideFieldData.d.ts
generated
vendored
Executable file
56
node_modules/buetify/lib/composables/fieldData/provideFieldData.d.ts
generated
vendored
Executable file
@@ -0,0 +1,56 @@
|
||||
import { FunctionN } from 'fp-ts/lib/function';
|
||||
import { PropType, ExtractPropTypes, Ref } from 'vue';
|
||||
import { AllColorsVariant } from '../../types/ColorVariants';
|
||||
export declare const PROVIDE_FIELD_DATA_INJECTION_SYMBOL: unique symbol;
|
||||
export declare const ProvideFieldDataPropsDefinition: {
|
||||
variant: {
|
||||
type: PropType<AllColorsVariant>;
|
||||
required: boolean;
|
||||
};
|
||||
message: {
|
||||
type: PropType<string | {
|
||||
[K: string]: boolean;
|
||||
} | (string | {
|
||||
[K: string]: boolean;
|
||||
})[]>;
|
||||
required: boolean;
|
||||
};
|
||||
isExpanded: {
|
||||
type: PropType<boolean>;
|
||||
default: boolean;
|
||||
};
|
||||
labelFor: PropType<string>;
|
||||
label: {
|
||||
type: PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
};
|
||||
export declare type ProvideFieldDataProps = ExtractPropTypes<typeof ProvideFieldDataPropsDefinition>;
|
||||
export declare function formatMessage(message: string | {
|
||||
[K: string]: boolean;
|
||||
} | Array<string | {
|
||||
[K: string]: boolean;
|
||||
}> | undefined): string;
|
||||
export interface FieldDataAttrs {
|
||||
label: Ref<string>;
|
||||
isFullwidth: Ref<boolean>;
|
||||
isExpanded: Ref<boolean>;
|
||||
message: Ref<string>;
|
||||
messageVariant: Ref<undefined | AllColorsVariant>;
|
||||
id: Ref<string | undefined>;
|
||||
labelId: Ref<string | undefined>;
|
||||
}
|
||||
export interface FieldDataListeners {
|
||||
onNewMessage: FunctionN<[string | {
|
||||
[K: string]: boolean;
|
||||
} | Array<string | {
|
||||
[K: string]: boolean;
|
||||
}>], void>;
|
||||
onNewVariant: FunctionN<[AllColorsVariant], void>;
|
||||
}
|
||||
export interface FieldDataInjection {
|
||||
attrs: FieldDataAttrs;
|
||||
setters: FieldDataListeners;
|
||||
}
|
||||
export declare const DEFAULT_FIELD_DATA_INJECTION: FieldDataInjection;
|
||||
export declare function provideFieldData(props: ProvideFieldDataProps): FieldDataInjection;
|
||||
100
node_modules/buetify/lib/composables/fieldData/provideFieldData.js
generated
vendored
Executable file
100
node_modules/buetify/lib/composables/fieldData/provideFieldData.js
generated
vendored
Executable file
@@ -0,0 +1,100 @@
|
||||
import { constVoid, not } from 'fp-ts/lib/function';
|
||||
import { provide, shallowRef, computed, watch, toRef } from 'vue';
|
||||
import { isEmptyString, isString } from '../../utils/helpers';
|
||||
import { useLabelId, UseLabelIdPropsDefinition } from '../labelId';
|
||||
export const PROVIDE_FIELD_DATA_INJECTION_SYMBOL = Symbol('use-field-data');
|
||||
export const ProvideFieldDataPropsDefinition = { ...UseLabelIdPropsDefinition,
|
||||
variant: {
|
||||
type: [String, Object],
|
||||
required: false
|
||||
},
|
||||
message: {
|
||||
type: [String, Array, Object],
|
||||
required: false
|
||||
},
|
||||
isExpanded: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
};
|
||||
export function formatMessage(message) {
|
||||
if (isString(message)) {
|
||||
return message;
|
||||
} else {
|
||||
const messages = [];
|
||||
|
||||
if (Array.isArray(message)) {
|
||||
message.forEach(m => {
|
||||
if (isString(m)) {
|
||||
messages.push(m);
|
||||
} else {
|
||||
for (const key in m) {
|
||||
if (m[key]) {
|
||||
messages.push(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (const key in message) {
|
||||
if (message[key]) {
|
||||
messages.push(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return messages.filter(not(isEmptyString)).join(' <br> ');
|
||||
}
|
||||
}
|
||||
export const DEFAULT_FIELD_DATA_INJECTION = {
|
||||
attrs: {
|
||||
label: shallowRef(''),
|
||||
isFullwidth: shallowRef(false),
|
||||
isExpanded: shallowRef(false),
|
||||
message: shallowRef(''),
|
||||
messageVariant: shallowRef(),
|
||||
id: shallowRef(),
|
||||
labelId: shallowRef()
|
||||
},
|
||||
setters: {
|
||||
onNewMessage: constVoid,
|
||||
onNewVariant: constVoid
|
||||
}
|
||||
};
|
||||
export function provideFieldData(props) {
|
||||
const label = useLabelId(props, 'field');
|
||||
const variant = shallowRef(props.variant);
|
||||
watch(toRef(props, 'variant'), newVariant => {
|
||||
variant.value = newVariant;
|
||||
});
|
||||
const message = shallowRef(props.message);
|
||||
watch(toRef(props, 'message'), newMessage => {
|
||||
message.value = newMessage;
|
||||
});
|
||||
const formattedMessage = computed(() => formatMessage(message.value));
|
||||
const isExpanded = toRef(props, 'isExpanded');
|
||||
const attrs = {
|
||||
label: toRef(props, 'label'),
|
||||
isFullwidth: isExpanded,
|
||||
isExpanded: isExpanded,
|
||||
message: formattedMessage,
|
||||
messageVariant: variant,
|
||||
id: label.id,
|
||||
labelId: label.labelId
|
||||
};
|
||||
const setters = {
|
||||
onNewMessage: newMessage => {
|
||||
message.value = newMessage;
|
||||
},
|
||||
onNewVariant: newVariant => {
|
||||
variant.value = newVariant;
|
||||
}
|
||||
};
|
||||
const injection = {
|
||||
attrs,
|
||||
setters
|
||||
};
|
||||
provide(PROVIDE_FIELD_DATA_INJECTION_SYMBOL, injection);
|
||||
return injection;
|
||||
}
|
||||
//# sourceMappingURL=provideFieldData.js.map
|
||||
1
node_modules/buetify/lib/composables/fieldData/provideFieldData.js.map
generated
vendored
Executable file
1
node_modules/buetify/lib/composables/fieldData/provideFieldData.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
1
node_modules/buetify/lib/composables/fieldData/useFieldData.d.ts
generated
vendored
Executable file
1
node_modules/buetify/lib/composables/fieldData/useFieldData.d.ts
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
export declare function useFieldData(): import("./provideFieldData").FieldDataInjection;
|
||||
6
node_modules/buetify/lib/composables/fieldData/useFieldData.js
generated
vendored
Executable file
6
node_modules/buetify/lib/composables/fieldData/useFieldData.js
generated
vendored
Executable file
@@ -0,0 +1,6 @@
|
||||
import { inject } from 'vue';
|
||||
import { DEFAULT_FIELD_DATA_INJECTION, PROVIDE_FIELD_DATA_INJECTION_SYMBOL } from './provideFieldData';
|
||||
export function useFieldData() {
|
||||
return inject(PROVIDE_FIELD_DATA_INJECTION_SYMBOL, DEFAULT_FIELD_DATA_INJECTION);
|
||||
}
|
||||
//# sourceMappingURL=useFieldData.js.map
|
||||
1
node_modules/buetify/lib/composables/fieldData/useFieldData.js.map
generated
vendored
Executable file
1
node_modules/buetify/lib/composables/fieldData/useFieldData.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/composables/fieldData/useFieldData.ts"],"names":[],"mappings":"AAAA,SAAS,MAAT,QAAuB,KAAvB;AACA,SAAS,4BAAT,EAAuC,mCAAvC,QAAkF,oBAAlF;AAEA,OAAM,SAAU,YAAV,GAAsB;AAC1B,SAAO,MAAM,CAAC,mCAAD,EAAsC,4BAAtC,CAAb;AACD","sourcesContent":["import { inject } from 'vue';\nimport { DEFAULT_FIELD_DATA_INJECTION, PROVIDE_FIELD_DATA_INJECTION_SYMBOL } from './provideFieldData';\n\nexport function useFieldData() {\n return inject(PROVIDE_FIELD_DATA_INJECTION_SYMBOL, DEFAULT_FIELD_DATA_INJECTION);\n}\n"],"sourceRoot":"","file":"useFieldData.js"}
|
||||
Reference in New Issue
Block a user