@dative-gpi/foundation-shared-components 0.0.5 → 0.0.7
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/components/FSBreadcrumbs.vue +16 -14
- package/components/FSButton.vue +171 -115
- package/components/FSCheckbox.vue +21 -10
- package/components/FSCol.vue +17 -17
- package/components/FSColor.vue +80 -0
- package/components/FSFadeOut.vue +4 -4
- package/components/FSIcon.vue +5 -3
- package/components/FSNumberField.vue +1 -1
- package/components/FSPasswordField.vue +20 -9
- package/components/FSRadio.vue +20 -10
- package/components/FSRadioGroup.vue +5 -7
- package/components/FSRow.vue +17 -17
- package/components/FSSearchField.vue +122 -0
- package/components/FSSlideGroup.vue +16 -12
- package/components/FSSpan.vue +27 -2
- package/components/FSSwitch.vue +25 -12
- package/components/FSTab.vue +9 -2
- package/components/FSTabs.vue +18 -10
- package/components/FSTag.vue +31 -17
- package/components/FSTagField.vue +152 -0
- package/components/FSTagGroup.vue +60 -0
- package/components/FSText.vue +78 -0
- package/components/FSTextField.vue +74 -18
- package/components/FSWrapGroup.vue +15 -12
- package/composables/useColors.ts +31 -21
- package/{defaults → models}/FSButtons.ts +24 -6
- package/models/FSTags.ts +8 -0
- package/models/FSTextFields.ts +17 -0
- package/package.json +5 -4
- package/styles/components/fs_breadcrumbs.scss +10 -5
- package/styles/components/fs_button.scss +21 -20
- package/styles/components/fs_checkbox.scss +3 -4
- package/styles/components/fs_color.scss +5 -0
- package/styles/components/fs_password_field.scss +6 -1
- package/styles/components/fs_radio.scss +3 -4
- package/styles/components/fs_span.scss +7 -2
- package/styles/components/fs_switch.scss +4 -4
- package/styles/components/fs_tabs.scss +8 -8
- package/styles/components/fs_tag.scss +8 -8
- package/styles/components/fs_tag_field.scss +10 -0
- package/styles/components/fs_text.scss +5 -0
- package/styles/components/fs_text_field.scss +25 -14
- package/styles/components/index.scss +3 -0
- package/styles/globals/overrides.scss +13 -4
- package/styles/globals/text_fonts.scss +4 -0
- package/themes/default.ts +6 -6
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FSCol>
|
|
3
|
+
<FSTextField
|
|
4
|
+
:label="$props.label"
|
|
5
|
+
:description="$props.description"
|
|
6
|
+
:type="type"
|
|
7
|
+
:color="$props.color"
|
|
8
|
+
:required="$props.required"
|
|
9
|
+
:editable="$props.editable"
|
|
10
|
+
:value="innerValue"
|
|
11
|
+
@update:value="(value) => innerValue = value"
|
|
12
|
+
@keydown.enter="onAdd"
|
|
13
|
+
v-bind="$attrs"
|
|
14
|
+
>
|
|
15
|
+
<template #append-inner>
|
|
16
|
+
<FSIcon
|
|
17
|
+
class="fs-tag-field-icon"
|
|
18
|
+
size="m"
|
|
19
|
+
:style="style"
|
|
20
|
+
@click="onAdd"
|
|
21
|
+
>
|
|
22
|
+
mdi-tag-outline
|
|
23
|
+
</FSIcon>
|
|
24
|
+
</template>
|
|
25
|
+
<template v-for="(_, name) in $slots" v-slot:[name]="slotData">
|
|
26
|
+
<slot :name="name" v-bind="slotData" />
|
|
27
|
+
</template>
|
|
28
|
+
</FSTextField>
|
|
29
|
+
<FSTagGroup
|
|
30
|
+
:tags="$props.value"
|
|
31
|
+
:variant="$props.variant"
|
|
32
|
+
:color="$props.tagColor"
|
|
33
|
+
:editable="$props.editable"
|
|
34
|
+
@remove="onRemove"
|
|
35
|
+
/>
|
|
36
|
+
</FSCol>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<script lang="ts">
|
|
40
|
+
import { computed, defineComponent, PropType, ref, toRefs } from "vue";
|
|
41
|
+
|
|
42
|
+
import { useColors } from "@dative-gpi/foundation-shared-components/composables";
|
|
43
|
+
import { ColorBase } from "@dative-gpi/foundation-shared-components/themes";
|
|
44
|
+
|
|
45
|
+
import FSTextField from "./FSTextField.vue";
|
|
46
|
+
import FSTagGroup from "./FSTagGroup.vue";
|
|
47
|
+
import FSCol from "./FSCol.vue"
|
|
48
|
+
|
|
49
|
+
export default defineComponent({
|
|
50
|
+
name: "FSTagField",
|
|
51
|
+
components: {
|
|
52
|
+
FSTextField,
|
|
53
|
+
FSTagGroup,
|
|
54
|
+
FSCol
|
|
55
|
+
},
|
|
56
|
+
props: {
|
|
57
|
+
label: {
|
|
58
|
+
type: String,
|
|
59
|
+
required: false,
|
|
60
|
+
default: null
|
|
61
|
+
},
|
|
62
|
+
description: {
|
|
63
|
+
type: String,
|
|
64
|
+
required: false,
|
|
65
|
+
default: null
|
|
66
|
+
},
|
|
67
|
+
value: {
|
|
68
|
+
type: Array as PropType<string[]>,
|
|
69
|
+
required: false,
|
|
70
|
+
default: () => []
|
|
71
|
+
},
|
|
72
|
+
variant: {
|
|
73
|
+
type: String as PropType<"standard" | "full">,
|
|
74
|
+
required: false,
|
|
75
|
+
default: "full"
|
|
76
|
+
},
|
|
77
|
+
color: {
|
|
78
|
+
type: String as PropType<ColorBase>,
|
|
79
|
+
required: false,
|
|
80
|
+
default: ColorBase.Primary
|
|
81
|
+
},
|
|
82
|
+
tagColor: {
|
|
83
|
+
type: String as PropType<ColorBase>,
|
|
84
|
+
required: false,
|
|
85
|
+
default: ColorBase.Primary
|
|
86
|
+
},
|
|
87
|
+
required: {
|
|
88
|
+
type: Boolean,
|
|
89
|
+
required: false,
|
|
90
|
+
default: false
|
|
91
|
+
},
|
|
92
|
+
editable: {
|
|
93
|
+
type: Boolean,
|
|
94
|
+
required: false,
|
|
95
|
+
default: true
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
emits: ["update:value"],
|
|
99
|
+
setup(props, { emit }) {
|
|
100
|
+
const { value, editable } = toRefs(props);
|
|
101
|
+
|
|
102
|
+
const innerValue = ref("");
|
|
103
|
+
|
|
104
|
+
const darks = useColors().getColors(ColorBase.Dark);
|
|
105
|
+
|
|
106
|
+
const style = computed((): {[code: string]: string} & Partial<CSSStyleDeclaration> => {
|
|
107
|
+
if (!editable.value) {
|
|
108
|
+
return {
|
|
109
|
+
"--fs-tag-field-cursor" : "default",
|
|
110
|
+
"--fs-tag-field-base-text": darks.light,
|
|
111
|
+
"--fs-tag-field-dark-text": darks.light
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
"--fs-tag-field-cursor" : "pointer",
|
|
116
|
+
"--fs-tag-field-base-text": darks.base,
|
|
117
|
+
"--fs-tag-field-dark-text": darks.dark
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const onAdd = (): void => {
|
|
122
|
+
if (!editable.value) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const tags = value.value ?? [];
|
|
126
|
+
if (!innerValue.value.length || tags.includes(innerValue.value)) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
emit("update:value", tags.concat(innerValue.value));
|
|
130
|
+
innerValue.value = "";
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const onRemove = (label: string): void => {
|
|
134
|
+
if (!editable.value) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const tags = value.value ?? [];
|
|
138
|
+
if (!tags.length || !tags.includes(label)) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
emit("update:value", tags.filter(t => t !== label));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
innerValue,
|
|
146
|
+
style,
|
|
147
|
+
onAdd,
|
|
148
|
+
onRemove
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
</script>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FSWrapGroup v-bind="$attrs">
|
|
3
|
+
<FSTag
|
|
4
|
+
v-for="(tag, index) in $props.tags"
|
|
5
|
+
:key="index"
|
|
6
|
+
:label="tag"
|
|
7
|
+
:variant="$props.variant"
|
|
8
|
+
:color="$props.color"
|
|
9
|
+
:editable="$props.editable"
|
|
10
|
+
@remove="() => $emit('remove', tag)"
|
|
11
|
+
/>
|
|
12
|
+
<slot name="default" />
|
|
13
|
+
</FSWrapGroup>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script lang="ts">
|
|
17
|
+
import { defineComponent, PropType } from "vue";
|
|
18
|
+
|
|
19
|
+
import { ColorBase } from "@dative-gpi/foundation-shared-components/themes";
|
|
20
|
+
|
|
21
|
+
import FSWrapGroup from "./FSWrapGroup.vue";
|
|
22
|
+
import FSTag from "./FSTag.vue";
|
|
23
|
+
|
|
24
|
+
export interface FSTagItem {
|
|
25
|
+
label: string,
|
|
26
|
+
variant: "standard" | "full",
|
|
27
|
+
color: ColorBase,
|
|
28
|
+
editable: boolean
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default defineComponent({
|
|
32
|
+
name: "FSTagGroup",
|
|
33
|
+
components: {
|
|
34
|
+
FSWrapGroup,
|
|
35
|
+
FSTag
|
|
36
|
+
},
|
|
37
|
+
props: {
|
|
38
|
+
tags: {
|
|
39
|
+
type: Array as PropType<Array<String>>,
|
|
40
|
+
required: false,
|
|
41
|
+
default: () => []
|
|
42
|
+
},
|
|
43
|
+
variant: {
|
|
44
|
+
type: String as PropType<"standard" | "full">,
|
|
45
|
+
required: false,
|
|
46
|
+
default: "full"
|
|
47
|
+
},
|
|
48
|
+
color: {
|
|
49
|
+
type: String as PropType<ColorBase>,
|
|
50
|
+
required: false,
|
|
51
|
+
default: ColorBase.Primary
|
|
52
|
+
},
|
|
53
|
+
editable: {
|
|
54
|
+
type: Boolean,
|
|
55
|
+
required: false,
|
|
56
|
+
default: true
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
</script>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span
|
|
3
|
+
:class="classes"
|
|
4
|
+
:style="style"
|
|
5
|
+
v-bind="$attrs"
|
|
6
|
+
>
|
|
7
|
+
<slot />
|
|
8
|
+
</span>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
import { computed, defineComponent, PropType, toRefs, useSlots } from "vue";
|
|
13
|
+
|
|
14
|
+
import { useColors } from "@dative-gpi/foundation-shared-components/composables";
|
|
15
|
+
import { ColorBase } from "@dative-gpi/foundation-shared-components/themes";
|
|
16
|
+
|
|
17
|
+
export default defineComponent({
|
|
18
|
+
name: "FSText",
|
|
19
|
+
props: {
|
|
20
|
+
font: {
|
|
21
|
+
type: String as PropType<"text-h1" | "text-h2" | "text-h3" | "text-body" | "text-button" | "text-overline" | "text-underline">,
|
|
22
|
+
required: false,
|
|
23
|
+
default: "text-body"
|
|
24
|
+
},
|
|
25
|
+
color: {
|
|
26
|
+
type: String as PropType<ColorBase>,
|
|
27
|
+
required: false,
|
|
28
|
+
default: ColorBase.Dark
|
|
29
|
+
},
|
|
30
|
+
variant: {
|
|
31
|
+
type: String as PropType<"base" | "light" | "dark">,
|
|
32
|
+
required: false,
|
|
33
|
+
default: "dark"
|
|
34
|
+
},
|
|
35
|
+
ellipsis: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
required: false,
|
|
38
|
+
default: true
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
setup(props) {
|
|
42
|
+
const { color, font, variant } = toRefs(props);
|
|
43
|
+
|
|
44
|
+
const colors = useColors().getColors(color.value);
|
|
45
|
+
const slots = useSlots();
|
|
46
|
+
|
|
47
|
+
const style = computed((): { [code: string]: string } & Partial<CSSStyleDeclaration> => {
|
|
48
|
+
switch (variant.value) {
|
|
49
|
+
case "base": return {
|
|
50
|
+
"--fs-text-color": colors.base
|
|
51
|
+
};
|
|
52
|
+
case "light": return {
|
|
53
|
+
"--fs-text-color": colors.light
|
|
54
|
+
};
|
|
55
|
+
case "dark": return {
|
|
56
|
+
"--fs-text-color": colors.dark
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const classes = computed((): string[] => {
|
|
62
|
+
const classes = ["fs-text", font.value];
|
|
63
|
+
if (props.ellipsis) {
|
|
64
|
+
classes.push("fs-span-ellipsis");
|
|
65
|
+
}
|
|
66
|
+
if (!slots.default) {
|
|
67
|
+
classes.push("fs-span-pre-wrap");
|
|
68
|
+
}
|
|
69
|
+
return classes;
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
classes,
|
|
74
|
+
style
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
</script>
|
|
@@ -1,14 +1,35 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<FSCol>
|
|
3
3
|
<slot name="label">
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
<FSRow :wrap="false">
|
|
5
|
+
<FSSpan
|
|
6
|
+
v-if="$props.label"
|
|
7
|
+
class="fs-text-field-label"
|
|
8
|
+
font="text-overline"
|
|
9
|
+
:style="style"
|
|
10
|
+
>
|
|
11
|
+
{{ $props.label }}
|
|
12
|
+
</FSSpan>
|
|
13
|
+
<FSSpan
|
|
14
|
+
v-if="$props.label && $props.required"
|
|
15
|
+
class="fs-text-field-label"
|
|
16
|
+
style="margin-left: -8px;"
|
|
17
|
+
font="text-overline"
|
|
18
|
+
:ellipsis="false"
|
|
19
|
+
:style="style"
|
|
20
|
+
>
|
|
21
|
+
*
|
|
22
|
+
</FSSpan>
|
|
23
|
+
<v-spacer style="min-width: 40px;" />
|
|
24
|
+
<FSSpan
|
|
25
|
+
v-if="messages.length > 0"
|
|
26
|
+
class="fs-text-field-messages"
|
|
27
|
+
font="text-overline"
|
|
28
|
+
:style="style"
|
|
29
|
+
>
|
|
30
|
+
{{ messages.join(", ") }}
|
|
31
|
+
</FSSpan>
|
|
32
|
+
</FSRow>
|
|
12
33
|
</slot>
|
|
13
34
|
<v-text-field
|
|
14
35
|
class="fs-text-field"
|
|
@@ -16,6 +37,7 @@
|
|
|
16
37
|
hide-details
|
|
17
38
|
:style="style"
|
|
18
39
|
:type="$props.type"
|
|
40
|
+
:rules="$props.rules"
|
|
19
41
|
:readonly="!$props.editable"
|
|
20
42
|
:modelValue="$props.value"
|
|
21
43
|
@update:modelValue="(value) => $emit('update:value', value)"
|
|
@@ -46,18 +68,20 @@ import { ColorBase } from "@dative-gpi/foundation-shared-components/themes";
|
|
|
46
68
|
|
|
47
69
|
import FSSpan from "./FSSpan.vue";
|
|
48
70
|
import FSCol from "./FSCol.vue";
|
|
71
|
+
import FSRow from "./FSRow.vue";
|
|
49
72
|
|
|
50
73
|
export default defineComponent({
|
|
51
74
|
name: "FSTextField",
|
|
52
75
|
components: {
|
|
53
76
|
FSSpan,
|
|
54
|
-
FSCol
|
|
77
|
+
FSCol,
|
|
78
|
+
FSRow
|
|
55
79
|
},
|
|
56
80
|
inheritAttrs: false,
|
|
57
81
|
props: {
|
|
58
82
|
label: {
|
|
59
83
|
type: String,
|
|
60
|
-
required:
|
|
84
|
+
required: true,
|
|
61
85
|
default: null
|
|
62
86
|
},
|
|
63
87
|
description: {
|
|
@@ -85,6 +109,11 @@ export default defineComponent({
|
|
|
85
109
|
required: false,
|
|
86
110
|
default: false
|
|
87
111
|
},
|
|
112
|
+
rules: {
|
|
113
|
+
type: Array as PropType<Function[]>,
|
|
114
|
+
required: false,
|
|
115
|
+
default: () => []
|
|
116
|
+
},
|
|
88
117
|
editable: {
|
|
89
118
|
type: Boolean,
|
|
90
119
|
required: false,
|
|
@@ -95,17 +124,44 @@ export default defineComponent({
|
|
|
95
124
|
setup(props) {
|
|
96
125
|
const { color, editable } = toRefs(props);
|
|
97
126
|
|
|
98
|
-
const colors = useColors().
|
|
99
|
-
|
|
127
|
+
const colors = useColors().getColors(color.value);
|
|
128
|
+
|
|
129
|
+
const errors = useColors().getColors(ColorBase.Error);
|
|
130
|
+
const lights = useColors().getColors(ColorBase.Light);
|
|
131
|
+
const darks = useColors().getColors(ColorBase.Dark);
|
|
132
|
+
|
|
133
|
+
const style = computed((): {[code: string]: string} & Partial<CSSStyleDeclaration> => {
|
|
134
|
+
if (!editable.value) {
|
|
135
|
+
return {
|
|
136
|
+
"--fs-text-field-cursor" : "default",
|
|
137
|
+
"--fs-text-field-border-color" : lights.base,
|
|
138
|
+
"--fs-text-field-color" : lights.dark,
|
|
139
|
+
"--fs-text-field-active-border-color": lights.base
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
"--fs-text-field-cursor" : "text",
|
|
144
|
+
"--fs-text-field-border-color" : colors.base,
|
|
145
|
+
"--fs-text-field-color" : darks.base,
|
|
146
|
+
"--fs-text-field-active-border-color": colors.dark,
|
|
147
|
+
"--fs-text-field-error-color" : errors.base,
|
|
148
|
+
"--fs-text-field-error-border-color" : errors.base
|
|
149
|
+
};
|
|
150
|
+
});
|
|
100
151
|
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
152
|
+
const messages = computed(() => {
|
|
153
|
+
const messages = [];
|
|
154
|
+
for (const rule of props.rules) {
|
|
155
|
+
const message = rule(props.value);
|
|
156
|
+
if (typeof(message) === "string") {
|
|
157
|
+
messages.push(message);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return messages;
|
|
161
|
+
});
|
|
107
162
|
|
|
108
163
|
return {
|
|
164
|
+
messages,
|
|
109
165
|
style
|
|
110
166
|
};
|
|
111
167
|
}
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
>
|
|
7
7
|
<FSRow>
|
|
8
8
|
<v-slide-group-item v-for="(component, index) in $slots.default()" :key="index">
|
|
9
|
-
<component :is="component" v-bind="{ color }" />
|
|
9
|
+
<component :is="component" v-bind="{ color, colors, style }" />
|
|
10
10
|
</v-slide-group-item>
|
|
11
11
|
</FSRow>
|
|
12
12
|
</v-slide-group>
|
|
13
13
|
</template>
|
|
14
14
|
|
|
15
15
|
<script lang="ts">
|
|
16
|
-
import { defineComponent, PropType, toRefs } from "vue";
|
|
16
|
+
import { defineComponent, PropType, Ref, ref, toRefs } from "vue";
|
|
17
17
|
|
|
18
18
|
import { useColors } from "@dative-gpi/foundation-shared-components/composables";
|
|
19
19
|
import { ColorBase } from "@dative-gpi/foundation-shared-components/themes";
|
|
@@ -35,20 +35,23 @@ export default defineComponent({
|
|
|
35
35
|
setup(props) {
|
|
36
36
|
const { color } = toRefs(props);
|
|
37
37
|
|
|
38
|
-
const colors = useColors().
|
|
39
|
-
const dark = useColors().getVariants(ColorBase.Dark);
|
|
38
|
+
const colors = useColors().getColors(color.value);
|
|
40
39
|
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"--fs-group-
|
|
45
|
-
"--fs-group-
|
|
46
|
-
"--fs-group-
|
|
47
|
-
"--fs-group-
|
|
48
|
-
|
|
40
|
+
const darks = useColors().getColors(ColorBase.Dark);
|
|
41
|
+
|
|
42
|
+
const style: Ref<{ [code: string]: string } & Partial<CSSStyleDeclaration>> = ref({
|
|
43
|
+
"--fs-group-color": darks.base,
|
|
44
|
+
"--fs-group-hover-background-color": colors.light,
|
|
45
|
+
"--fs-group-hover-color": darks.dark,
|
|
46
|
+
"--fs-group-disabled-color": darks.light,
|
|
47
|
+
"--fs-group-light": colors.light,
|
|
48
|
+
"--fs-group-base": colors.base,
|
|
49
|
+
"--fs-group-dark": colors.dark
|
|
50
|
+
});
|
|
49
51
|
|
|
50
52
|
return {
|
|
51
53
|
color,
|
|
54
|
+
colors,
|
|
52
55
|
style
|
|
53
56
|
};
|
|
54
57
|
}
|
package/composables/useColors.ts
CHANGED
|
@@ -7,29 +7,23 @@ import { ColorBase } from "@dative-gpi/foundation-shared-components/themes";
|
|
|
7
7
|
export const useColors = () => {
|
|
8
8
|
const theme = useTheme().current.value;
|
|
9
9
|
|
|
10
|
-
const lighten = (color: Color): Color =>
|
|
11
|
-
|
|
12
|
-
const darken = (color: Color): Color => color.value(Math.max(color.value() - 30, 0));
|
|
13
|
-
|
|
14
|
-
const getBackground = () => {
|
|
15
|
-
const base = new Color(theme.colors[ColorBase.Background]);
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
base: base.hex()
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const getLight = (color: ColorBase, base: Color): Color => {
|
|
10
|
+
const lighten = (color: ColorBase, base: Color): Color => {
|
|
23
11
|
switch (color) {
|
|
24
|
-
case ColorBase.Light:
|
|
25
|
-
case ColorBase.Dark: return base.
|
|
26
|
-
default: return
|
|
12
|
+
case ColorBase.Light:
|
|
13
|
+
case ColorBase.Dark: return base.value(Math.min(base.value() + 10, 100));
|
|
14
|
+
default: return base.saturationv(10).value(Math.min(base.value() + 10, 100));
|
|
27
15
|
}
|
|
28
16
|
};
|
|
29
17
|
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
18
|
+
const darken = (base: Color): Color => {
|
|
19
|
+
return base.value(Math.max(base.value() - 15, 0));
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const getColors = (color: ColorBase | String) => {
|
|
23
|
+
const themed = (Object as any).values(ColorBase).includes(color);
|
|
24
|
+
|
|
25
|
+
const base = themed ? new Color(theme.colors[color as ColorBase]) : new Color(color);
|
|
26
|
+
const light = lighten(color as ColorBase, base);
|
|
33
27
|
const dark = darken(base);
|
|
34
28
|
|
|
35
29
|
return {
|
|
@@ -39,8 +33,24 @@ export const useColors = () => {
|
|
|
39
33
|
};
|
|
40
34
|
};
|
|
41
35
|
|
|
36
|
+
const getContrasts = (color: ColorBase | string) => {
|
|
37
|
+
switch (color) {
|
|
38
|
+
case ColorBase.Light: {
|
|
39
|
+
const base = new Color(theme.colors[ColorBase.Dark]);
|
|
40
|
+
return {
|
|
41
|
+
light: base.hex(),
|
|
42
|
+
base: base.hex(),
|
|
43
|
+
dark: base.hex()
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
default: {
|
|
47
|
+
return getColors(color);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
42
52
|
return {
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
getColors,
|
|
54
|
+
getContrasts
|
|
45
55
|
};
|
|
46
56
|
}
|
|
@@ -58,36 +58,54 @@ export const FSButtonsProps = {
|
|
|
58
58
|
prependIcon: "mdi-content-save-outline",
|
|
59
59
|
label: "Save",
|
|
60
60
|
variant: "standard",
|
|
61
|
-
color: ColorBase.
|
|
61
|
+
color: ColorBase.Primary
|
|
62
62
|
},
|
|
63
63
|
FSButtonSaveMini: {
|
|
64
64
|
prependIcon: "mdi-content-save-outline",
|
|
65
65
|
label: undefined,
|
|
66
66
|
variant: "standard",
|
|
67
|
-
color: ColorBase.
|
|
67
|
+
color: ColorBase.Primary
|
|
68
68
|
},
|
|
69
69
|
FSButtonSaveIcon: {
|
|
70
70
|
icon: "mdi-content-save-outline",
|
|
71
71
|
label: undefined,
|
|
72
72
|
variant: "icon",
|
|
73
|
-
color: ColorBase.
|
|
73
|
+
color: ColorBase.Primary
|
|
74
74
|
},
|
|
75
75
|
FSButtonCancel: {
|
|
76
76
|
prependIcon: "mdi-cancel",
|
|
77
77
|
label: "Cancel",
|
|
78
78
|
variant: "standard",
|
|
79
|
-
color: ColorBase.
|
|
79
|
+
color: ColorBase.Light
|
|
80
80
|
},
|
|
81
81
|
FSButtonCancelMini: {
|
|
82
82
|
prependIcon: "mdi-cancel",
|
|
83
83
|
label: undefined,
|
|
84
84
|
variant: "standard",
|
|
85
|
-
color: ColorBase.
|
|
85
|
+
color: ColorBase.Light
|
|
86
86
|
},
|
|
87
87
|
FSButtonCancelIcon: {
|
|
88
88
|
icon: "mdi-cancel",
|
|
89
89
|
label: undefined,
|
|
90
90
|
variant: "icon",
|
|
91
|
-
color: ColorBase.
|
|
91
|
+
color: ColorBase.Light
|
|
92
|
+
},
|
|
93
|
+
FSButtonDocumentation: {
|
|
94
|
+
prependIcon: "mdi-file-document-outline",
|
|
95
|
+
label: "Documentation",
|
|
96
|
+
variant: "standard",
|
|
97
|
+
color: ColorBase.Light
|
|
98
|
+
},
|
|
99
|
+
FSButtonDocumentationMini: {
|
|
100
|
+
prependIcon: "mdi-file-document-outline",
|
|
101
|
+
label: undefined,
|
|
102
|
+
variant: "standard",
|
|
103
|
+
color: ColorBase.Light
|
|
104
|
+
},
|
|
105
|
+
FSButtonDocumentationIcon: {
|
|
106
|
+
icon: "mdi-file-document-outline",
|
|
107
|
+
label: undefined,
|
|
108
|
+
variant: "icon",
|
|
109
|
+
color: ColorBase.Light
|
|
92
110
|
}
|
|
93
111
|
}
|
package/models/FSTags.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const TextRules = {
|
|
2
|
+
required: (message: string) => (value: string) => !!value || (message ?? "Required"),
|
|
3
|
+
minLength: (length: number, message: string) => (value: string) => value.length >= length || (message ?? `Must be at least ${length} characters`),
|
|
4
|
+
maxLength: (length: number, message: string) => (value: string) => value.length <= length || (message ?? `Must be at most ${length} characters`),
|
|
5
|
+
email: (message: string) => (value: string) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value) || (message ?? "Must be a valid email"),
|
|
6
|
+
digit: (message: string) => (value: string) => /(?=.*\d)/.test(value) || (message ?? "Must contain a digit"),
|
|
7
|
+
uppercase: (message: string) => (value: string) => /(?=.*[A-Z])/.test(value) || (message ?? "Must contain an uppercase letter"),
|
|
8
|
+
lowercase: (message: string) => (value: string) => /(?=.*[a-z])/.test(value) || (message ?? "Must contain a lowercase letter"),
|
|
9
|
+
special: (message: string) => (value: string) => /(?=.*[!@#$%^&*])/.test(value) || (message ?? "Must contain a special character")
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const NumberRules = {
|
|
13
|
+
required: (message: string) => (value: number) => !!value || (message ?? "Required"),
|
|
14
|
+
min: (min: number, message: string) => (value: number) => value >= min || (message ?? `Must be at least ${min}`),
|
|
15
|
+
max: (max: number, message: string) => (value: number) => value <= max || (message ?? `Must be at most ${max}`),
|
|
16
|
+
integer: (message: string) => (value: number) => Number.isInteger(value) || (message ?? "Must be an integer")
|
|
17
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dative-gpi/foundation-shared-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
"author": "",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@dative-gpi/foundation-shared-domain": "0.0.
|
|
13
|
-
"@dative-gpi/foundation-shared-services": "0.0.
|
|
12
|
+
"@dative-gpi/foundation-shared-domain": "0.0.7",
|
|
13
|
+
"@dative-gpi/foundation-shared-services": "0.0.7",
|
|
14
|
+
"@fontsource/montserrat": "^5.0.16",
|
|
14
15
|
"color": "^4.2.3",
|
|
15
16
|
"vue": "^3.2.0"
|
|
16
17
|
},
|
|
@@ -19,5 +20,5 @@
|
|
|
19
20
|
"sass": "^1.69.5",
|
|
20
21
|
"sass-loader": "^13.3.2"
|
|
21
22
|
},
|
|
22
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "970e56be5ba41712db154bd27ad98962dbeb802e"
|
|
23
24
|
}
|