@onereach/ui-components 4.1.1 → 4.1.2-beta.2552.0
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/bundled/v2/components/OrCheckboxGroupV3/OrCheckboxGroup.js +132 -0
- package/dist/bundled/v2/components/OrCheckboxGroupV3/OrCheckboxGroup.vue.d.ts +110 -0
- package/dist/bundled/v2/components/OrCheckboxGroupV3/index.d.ts +1 -0
- package/dist/bundled/v2/components/OrCheckboxGroupV3/index.js +25 -0
- package/dist/bundled/v2/components/OrCheckboxTreeV3/OrCheckboxTree.js +190 -0
- package/dist/bundled/v2/components/OrCheckboxTreeV3/OrCheckboxTree.vue.d.ts +63 -0
- package/dist/bundled/v2/components/OrCheckboxTreeV3/index.d.ts +1 -0
- package/dist/bundled/v2/components/OrCheckboxTreeV3/index.js +17 -0
- package/dist/bundled/v2/components/OrCheckboxTreeV3/styles.d.ts +1 -0
- package/dist/bundled/v2/components/OrCheckboxTreeV3/styles.js +7 -0
- package/dist/bundled/v2/components/OrCheckboxTreeV3/types.d.ts +5 -0
- package/dist/bundled/v2/components/OrCheckboxTreeV3/types.js +1 -0
- package/dist/bundled/v2/components/OrCheckboxV3/OrCheckbox.js +34 -39
- package/dist/bundled/v2/components/OrCheckboxV3/OrCheckbox.vue.d.ts +18 -16
- package/dist/bundled/v2/components/OrCheckboxV3/index.js +1 -0
- package/dist/bundled/v2/components/OrFormGroupV3/OrFormGroup.js +121 -0
- package/dist/bundled/v2/components/OrFormGroupV3/OrFormGroup.vue.d.ts +83 -0
- package/dist/bundled/v2/components/OrFormGroupV3/index.d.ts +2 -0
- package/dist/bundled/v2/components/OrFormGroupV3/index.js +12 -0
- package/dist/bundled/v2/components/OrFormGroupV3/props.d.ts +4 -0
- package/dist/bundled/v2/components/OrFormGroupV3/props.js +7 -0
- package/dist/bundled/v2/components/OrFormGroupV3/styles.d.ts +4 -0
- package/dist/bundled/v2/components/OrFormGroupV3/styles.js +14 -0
- package/dist/bundled/v2/components/OrRadioGroupV3/OrRadioGroup.js +132 -0
- package/dist/bundled/v2/components/OrRadioGroupV3/OrRadioGroup.vue.d.ts +110 -0
- package/dist/bundled/v2/components/OrRadioGroupV3/index.d.ts +1 -0
- package/dist/bundled/v2/components/OrRadioGroupV3/index.js +19 -0
- package/dist/bundled/v2/components/OrSelectV3/OrSelect.js +1 -1
- package/dist/bundled/v2/components/OrSelectV3/index.js +1 -1
- package/dist/bundled/v2/index.js +3 -3
- package/dist/bundled/v3/{OrCheckbox.vue_vue_type_script_lang-60cefcbd.js → OrCheckbox.vue_vue_type_script_lang-51a4f8d3.js} +26 -10
- package/dist/bundled/v3/OrCheckboxTree.vue_vue_type_script_lang-80c4ebd5.js +93 -0
- package/dist/bundled/v3/OrFormGroup.vue_vue_type_script_lang-fb14a874.js +58 -0
- package/dist/bundled/v3/{OrSelect.vue_vue_type_script_lang-f7601423.js → OrSelect.vue_vue_type_script_lang-c0612348.js} +1 -1
- package/dist/bundled/v3/components/OrCheckboxGroupV3/OrCheckboxGroup.js +110 -0
- package/dist/bundled/v3/components/OrCheckboxGroupV3/OrCheckboxGroup.vue.d.ts +110 -0
- package/dist/bundled/v3/components/OrCheckboxGroupV3/index.d.ts +1 -0
- package/dist/bundled/v3/components/OrCheckboxGroupV3/index.js +32 -0
- package/dist/bundled/v3/components/OrCheckboxTreeV3/OrCheckboxTree.js +71 -0
- package/dist/bundled/v3/components/OrCheckboxTreeV3/OrCheckboxTree.vue.d.ts +63 -0
- package/dist/bundled/v3/components/OrCheckboxTreeV3/index.d.ts +1 -0
- package/dist/bundled/v3/components/OrCheckboxTreeV3/index.js +20 -0
- package/dist/bundled/v3/components/OrCheckboxTreeV3/styles.d.ts +1 -0
- package/dist/bundled/v3/components/OrCheckboxTreeV3/styles.js +7 -0
- package/dist/bundled/v3/components/OrCheckboxTreeV3/types.d.ts +5 -0
- package/dist/bundled/v3/components/OrCheckboxTreeV3/types.js +1 -0
- package/dist/bundled/v3/components/OrCheckboxV3/OrCheckbox.js +9 -7
- package/dist/bundled/v3/components/OrCheckboxV3/OrCheckbox.vue.d.ts +18 -16
- package/dist/bundled/v3/components/OrCheckboxV3/index.js +2 -1
- package/dist/bundled/v3/components/OrFormGroupV3/OrFormGroup.js +58 -0
- package/dist/bundled/v3/components/OrFormGroupV3/OrFormGroup.vue.d.ts +83 -0
- package/dist/bundled/v3/components/OrFormGroupV3/index.d.ts +2 -0
- package/dist/bundled/v3/components/OrFormGroupV3/index.js +15 -0
- package/dist/bundled/v3/components/OrFormGroupV3/props.d.ts +4 -0
- package/dist/bundled/v3/components/OrFormGroupV3/props.js +7 -0
- package/dist/bundled/v3/components/OrFormGroupV3/styles.d.ts +4 -0
- package/dist/bundled/v3/components/OrFormGroupV3/styles.js +14 -0
- package/dist/bundled/v3/components/OrRadioGroupV3/OrRadioGroup.js +104 -0
- package/dist/bundled/v3/components/OrRadioGroupV3/OrRadioGroup.vue.d.ts +110 -0
- package/dist/bundled/v3/components/OrRadioGroupV3/index.d.ts +1 -0
- package/dist/bundled/v3/components/OrRadioGroupV3/index.js +24 -0
- package/dist/bundled/v3/components/OrSelectV3/OrSelect.js +4 -4
- package/dist/bundled/v3/components/OrSelectV3/index.js +3 -3
- package/dist/bundled/v3/components/index.js +2 -2
- package/dist/bundled/v3/index.js +6 -7
- package/dist/esm/v2/{OrCheckbox-dc587ec9.js → OrCheckbox-e55228e5.js} +34 -40
- package/dist/esm/v2/OrCheckboxTree-636b7553.js +186 -0
- package/dist/esm/v2/OrFormGroup-e583c054.js +132 -0
- package/dist/esm/v2/{OrSelect-40183874.js → OrSelect-4031334e.js} +1 -1
- package/dist/esm/v2/components/index.js +2 -2
- package/dist/esm/v2/components/or-checkbox-group-v3/OrCheckboxGroup.vue.d.ts +110 -0
- package/dist/esm/v2/components/or-checkbox-group-v3/index.d.ts +1 -0
- package/dist/esm/v2/components/or-checkbox-group-v3/index.js +121 -0
- package/dist/esm/v2/components/or-checkbox-tree-v3/OrCheckboxTree.vue.d.ts +63 -0
- package/dist/esm/v2/components/or-checkbox-tree-v3/index.d.ts +1 -0
- package/dist/esm/v2/components/or-checkbox-tree-v3/index.js +10 -0
- package/dist/esm/v2/components/or-checkbox-tree-v3/styles.d.ts +1 -0
- package/dist/esm/v2/components/or-checkbox-tree-v3/types.d.ts +5 -0
- package/dist/esm/v2/components/or-checkbox-v3/OrCheckbox.vue.d.ts +18 -16
- package/dist/esm/v2/components/or-checkbox-v3/index.js +2 -2
- package/dist/esm/v2/components/or-form-group-v3/OrFormGroup.vue.d.ts +83 -0
- package/dist/esm/v2/components/or-form-group-v3/index.d.ts +2 -0
- package/dist/esm/v2/components/or-form-group-v3/index.js +6 -0
- package/dist/esm/v2/components/or-form-group-v3/props.d.ts +4 -0
- package/dist/esm/v2/components/or-form-group-v3/styles.d.ts +4 -0
- package/dist/esm/v2/components/or-radio-group-v3/OrRadioGroup.vue.d.ts +110 -0
- package/dist/esm/v2/components/or-radio-group-v3/index.d.ts +1 -0
- package/dist/esm/v2/components/or-radio-group-v3/index.js +124 -0
- package/dist/esm/v2/components/or-select-v3/index.js +2 -2
- package/dist/esm/v2/index.js +2 -2
- package/dist/esm/v3/{OrCheckbox-56f849f7.js → OrCheckbox-eab735d0.js} +32 -16
- package/dist/esm/v3/OrCheckboxTree-1acfe5c8.js +147 -0
- package/dist/esm/v3/OrFormGroup-e7a78131.js +113 -0
- package/dist/esm/v3/{OrSelect-5502d82d.js → OrSelect-ebdab996.js} +1 -1
- package/dist/esm/v3/components/index.js +2 -2
- package/dist/esm/v3/components/or-checkbox-group-v3/OrCheckboxGroup.vue.d.ts +110 -0
- package/dist/esm/v3/components/or-checkbox-group-v3/index.d.ts +1 -0
- package/dist/esm/v3/components/or-checkbox-group-v3/index.js +92 -0
- package/dist/esm/v3/components/or-checkbox-tree-v3/OrCheckboxTree.vue.d.ts +63 -0
- package/dist/esm/v3/components/or-checkbox-tree-v3/index.d.ts +1 -0
- package/dist/esm/v3/components/or-checkbox-tree-v3/index.js +10 -0
- package/dist/esm/v3/components/or-checkbox-tree-v3/styles.d.ts +1 -0
- package/dist/esm/v3/components/or-checkbox-tree-v3/types.d.ts +5 -0
- package/dist/esm/v3/components/or-checkbox-v3/OrCheckbox.vue.d.ts +18 -16
- package/dist/esm/v3/components/or-checkbox-v3/index.js +2 -2
- package/dist/esm/v3/components/or-form-group-v3/OrFormGroup.vue.d.ts +83 -0
- package/dist/esm/v3/components/or-form-group-v3/index.d.ts +2 -0
- package/dist/esm/v3/components/or-form-group-v3/index.js +6 -0
- package/dist/esm/v3/components/or-form-group-v3/props.d.ts +4 -0
- package/dist/esm/v3/components/or-form-group-v3/styles.d.ts +4 -0
- package/dist/esm/v3/components/or-radio-group-v3/OrRadioGroup.vue.d.ts +110 -0
- package/dist/esm/v3/components/or-radio-group-v3/index.d.ts +1 -0
- package/dist/esm/v3/components/or-radio-group-v3/index.js +91 -0
- package/dist/esm/v3/components/or-select-v3/index.js +2 -2
- package/dist/esm/v3/index.js +2 -2
- package/package.json +2 -3
- package/src/components/or-checkbox-group-v3/OrCheckboxGroup.docs.mdx +12 -0
- package/src/components/or-checkbox-group-v3/OrCheckboxGroup.stories3.ts +163 -0
- package/src/components/or-checkbox-group-v3/OrCheckboxGroup.vue +78 -0
- package/src/components/or-checkbox-group-v3/index.ts +1 -0
- package/src/components/or-checkbox-tree-v3/OrCheckboxTree.docs.mdx +7 -0
- package/src/components/or-checkbox-tree-v3/OrCheckboxTree.stories3.ts +99 -0
- package/src/components/or-checkbox-tree-v3/OrCheckboxTree.vue +149 -0
- package/src/components/or-checkbox-tree-v3/index.ts +1 -0
- package/src/components/or-checkbox-tree-v3/styles.ts +9 -0
- package/src/components/or-checkbox-tree-v3/types.ts +5 -0
- package/src/components/or-checkbox-v3/OrCheckbox.vue +30 -12
- package/src/components/or-form-group-v3/OrFormGroup.stories3.ts +114 -0
- package/src/components/or-form-group-v3/OrFormGroup.vue +108 -0
- package/src/components/or-form-group-v3/index.ts +2 -0
- package/src/components/or-form-group-v3/props.ts +4 -0
- package/src/components/or-form-group-v3/styles.ts +26 -0
- package/src/components/or-radio-group-v3/OrRadioGroup.stories3.ts +81 -0
- package/src/components/or-radio-group-v3/OrRadioGroup.vue +80 -0
- package/src/components/or-radio-group-v3/index.ts +1 -0
- package/src/components/or-radio-v3/OrRadio.stories3.ts +1 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<OrFormGroup
|
|
3
|
+
:label="label"
|
|
4
|
+
:error="error"
|
|
5
|
+
:hint="hint"
|
|
6
|
+
:disabled="disabled"
|
|
7
|
+
:direction="direction"
|
|
8
|
+
>
|
|
9
|
+
<OrCheckboxTree
|
|
10
|
+
v-for="option in options"
|
|
11
|
+
:key="option.value"
|
|
12
|
+
v-model="proxyModelValue"
|
|
13
|
+
:item="option"
|
|
14
|
+
:disabeld="disabled || option.disabled"
|
|
15
|
+
/>
|
|
16
|
+
</OrFormGroup>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script lang="ts">
|
|
20
|
+
import { defineComponent, PropType } from 'vue-demi';
|
|
21
|
+
import { OrFormGroupV3 as OrFormGroup, FormGroupDirection } from '../or-form-group-v3';
|
|
22
|
+
import { OrCheckboxTreeV3 as OrCheckboxTree } from '../or-checkbox-tree-v3';
|
|
23
|
+
import { useVModel } from '@vueuse/core';
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
export default defineComponent({
|
|
27
|
+
name: 'OrCheckboxGroup',
|
|
28
|
+
components: {
|
|
29
|
+
OrCheckboxTree,
|
|
30
|
+
OrFormGroup,
|
|
31
|
+
},
|
|
32
|
+
model: {
|
|
33
|
+
prop: 'modelValue',
|
|
34
|
+
event: 'update:modelValue',
|
|
35
|
+
},
|
|
36
|
+
props: {
|
|
37
|
+
modelValue: {
|
|
38
|
+
type: Array as PropType<string[]>,
|
|
39
|
+
default: () => [],
|
|
40
|
+
},
|
|
41
|
+
label: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: '',
|
|
44
|
+
},
|
|
45
|
+
error: {
|
|
46
|
+
type: String,
|
|
47
|
+
default: '',
|
|
48
|
+
},
|
|
49
|
+
hint: {
|
|
50
|
+
type: String,
|
|
51
|
+
default: '',
|
|
52
|
+
},
|
|
53
|
+
direction: {
|
|
54
|
+
type: String as PropType<FormGroupDirection>,
|
|
55
|
+
default: FormGroupDirection.Vertical,
|
|
56
|
+
},
|
|
57
|
+
options: {
|
|
58
|
+
type: Array as PropType<{ label: string; value: any; disabled?: boolean;}[]>,
|
|
59
|
+
default: () => [],
|
|
60
|
+
},
|
|
61
|
+
disabled: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: false,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
setup(props, { emit }) {
|
|
67
|
+
const proxyModelValue = useVModel(props, 'modelValue', emit);
|
|
68
|
+
return {
|
|
69
|
+
proxyModelValue,
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<style scoped>
|
|
77
|
+
|
|
78
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as OrCheckboxGroupV3 } from './OrCheckboxGroup.vue';
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Meta, StoryFn } from '@storybook/vue3';
|
|
2
|
+
import { ref } from 'vue-demi';
|
|
3
|
+
import OrCheckboxDeepDocs from './OrCheckboxTree.docs.mdx';
|
|
4
|
+
import OrCheckboxTree from './OrCheckboxTree.vue';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Components/Forms/OrCheckboxTree',
|
|
8
|
+
component: OrCheckboxTree,
|
|
9
|
+
|
|
10
|
+
parameters: {
|
|
11
|
+
docs: {
|
|
12
|
+
page: OrCheckboxDeepDocs,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
} as Meta<typeof OrCheckboxTree>;
|
|
16
|
+
|
|
17
|
+
const Template: StoryFn<typeof OrCheckboxTree> = (args) => ({
|
|
18
|
+
components: {
|
|
19
|
+
OrCheckboxTree,
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
setup() {
|
|
23
|
+
// State
|
|
24
|
+
const model = ref<string[]>([]);
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
args,
|
|
29
|
+
model,
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
template: `
|
|
34
|
+
<div class="contents">
|
|
35
|
+
<OrCheckboxTree
|
|
36
|
+
v-for="item in args.items"
|
|
37
|
+
v-model="model"
|
|
38
|
+
:item="item"
|
|
39
|
+
/>
|
|
40
|
+
</div>
|
|
41
|
+
`,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export const Default = Template.bind({});
|
|
45
|
+
Default.args = {
|
|
46
|
+
items: [
|
|
47
|
+
{
|
|
48
|
+
label: 'Option 1',
|
|
49
|
+
value: '1',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
label: 'Option 2',
|
|
53
|
+
value: '2',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
label: 'Option 3',
|
|
57
|
+
children: [
|
|
58
|
+
{
|
|
59
|
+
label: 'Option 3.1',
|
|
60
|
+
value: '3.1',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
label: 'Option 3.2',
|
|
64
|
+
children: [
|
|
65
|
+
{
|
|
66
|
+
label: 'Option 3.2.1',
|
|
67
|
+
value: '3.2.1',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
label: 'Option 3.2.2',
|
|
71
|
+
value: '3.2.2',
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
label: 'Option 3.3',
|
|
77
|
+
value: '3.3',
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
label: 'Option 4',
|
|
83
|
+
value: '4',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
label: 'Option 5',
|
|
87
|
+
children: [
|
|
88
|
+
{
|
|
89
|
+
label: 'Option 5.1',
|
|
90
|
+
value: '5.1',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
label: 'Option 5.2',
|
|
94
|
+
value: '5.2',
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
ref="root"
|
|
4
|
+
:class="rootStyles"
|
|
5
|
+
>
|
|
6
|
+
<template v-if="hasChildren">
|
|
7
|
+
<div class="flex flex-row gap-xs">
|
|
8
|
+
<template
|
|
9
|
+
v-if="collapsible"
|
|
10
|
+
>
|
|
11
|
+
<OrIcon
|
|
12
|
+
:class="[isOpen ? 'rotate-0' : 'rotate-[-90deg]']"
|
|
13
|
+
icon="arrow_drop_down"
|
|
14
|
+
size="l"
|
|
15
|
+
@click="() => setIsOpen(!isOpen)"
|
|
16
|
+
/>
|
|
17
|
+
</template>
|
|
18
|
+
<OrCheckbox
|
|
19
|
+
value="true"
|
|
20
|
+
:model-value="isAllChildrenSelected"
|
|
21
|
+
:indeterminate="isIntermediate"
|
|
22
|
+
:label="item.label"
|
|
23
|
+
@click="handleParentClick"
|
|
24
|
+
/>
|
|
25
|
+
</div>
|
|
26
|
+
<div
|
|
27
|
+
v-if="hasChildren && isOpen"
|
|
28
|
+
:class="{'ml-2xl': collapsible}"
|
|
29
|
+
>
|
|
30
|
+
<OrCheckboxTree
|
|
31
|
+
v-for="child in item.children"
|
|
32
|
+
:key="child.value"
|
|
33
|
+
v-model="proxyModelValue"
|
|
34
|
+
class="mt-xs"
|
|
35
|
+
:item="child"
|
|
36
|
+
:collapsible="collapsible"
|
|
37
|
+
/>
|
|
38
|
+
</div>
|
|
39
|
+
</template>
|
|
40
|
+
<template v-else>
|
|
41
|
+
<OrCheckbox
|
|
42
|
+
v-model="proxyModelValue"
|
|
43
|
+
:label="item.label"
|
|
44
|
+
:value="item.value"
|
|
45
|
+
/>
|
|
46
|
+
</template>
|
|
47
|
+
</div>
|
|
48
|
+
</template>
|
|
49
|
+
|
|
50
|
+
<script lang="ts">
|
|
51
|
+
import { computed, defineComponent, PropType } from 'vue-demi';
|
|
52
|
+
import _ from 'lodash';
|
|
53
|
+
import { useVModel, useToggle } from '@vueuse/core';
|
|
54
|
+
import { OrCheckboxV3 as OrCheckbox } from '../or-checkbox-v3';
|
|
55
|
+
import { OrIconV3 as OrIcon } from '../or-icon-v3';
|
|
56
|
+
import { CheckboxDeepRoot } from './styles';
|
|
57
|
+
import { CheckboxNode } from './types';
|
|
58
|
+
|
|
59
|
+
export default defineComponent({
|
|
60
|
+
name: 'OrCheckboxTree',
|
|
61
|
+
components: {
|
|
62
|
+
OrIcon,
|
|
63
|
+
OrCheckbox,
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
model: {
|
|
67
|
+
prop: 'modelValue',
|
|
68
|
+
event: 'update:modelValue',
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
props: {
|
|
72
|
+
modelValue: {
|
|
73
|
+
type: Array as PropType<string[]>,
|
|
74
|
+
default: () => [],
|
|
75
|
+
},
|
|
76
|
+
item: {
|
|
77
|
+
type: Object as PropType<CheckboxNode>,
|
|
78
|
+
required: true,
|
|
79
|
+
},
|
|
80
|
+
collapsible: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: true,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
setup(props, { emit }) {
|
|
87
|
+
const hasChildren = computed(() => props.item.children && props.item.children.length > 0);
|
|
88
|
+
const childrenValues = computed(() => {
|
|
89
|
+
const getChildValues = (children?: CheckboxNode[]): any[] | undefined => {
|
|
90
|
+
return children?.map((child) => {
|
|
91
|
+
if (child.children) {
|
|
92
|
+
return getChildValues(child.children);
|
|
93
|
+
} else {
|
|
94
|
+
return child.value;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
return _.flatten(getChildValues(props.item.children));
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const proxyModelValue = useVModel(props, 'modelValue', emit);
|
|
103
|
+
|
|
104
|
+
const isAnyChildrenSelected = computed(() => {
|
|
105
|
+
return proxyModelValue.value?.some((value) => childrenValues.value?.includes(value));
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const isAllChildrenSelected = computed(() => {
|
|
109
|
+
return childrenValues.value?.every((value) => proxyModelValue.value?.includes(value));
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const isIntermediate = computed(() => {
|
|
113
|
+
return isAnyChildrenSelected.value && !isAllChildrenSelected.value;
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const [isOpen, setIsOpen] = useToggle(true);
|
|
117
|
+
|
|
118
|
+
// Styles
|
|
119
|
+
const rootStyles = computed(() => [
|
|
120
|
+
'or-checkbox-deep-v3',
|
|
121
|
+
...CheckboxDeepRoot,
|
|
122
|
+
]);
|
|
123
|
+
|
|
124
|
+
const handleParentClick = () => {
|
|
125
|
+
if (isAllChildrenSelected.value) {
|
|
126
|
+
proxyModelValue.value = proxyModelValue.value.filter((value) => !childrenValues.value.includes(value));
|
|
127
|
+
} else {
|
|
128
|
+
proxyModelValue.value = [
|
|
129
|
+
...proxyModelValue.value,
|
|
130
|
+
...childrenValues.value,
|
|
131
|
+
];
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
rootStyles,
|
|
137
|
+
hasChildren,
|
|
138
|
+
proxyModelValue,
|
|
139
|
+
isOpen,
|
|
140
|
+
setIsOpen,
|
|
141
|
+
isIntermediate,
|
|
142
|
+
isAllChildrenSelected,
|
|
143
|
+
isAnyChildrenSelected,
|
|
144
|
+
childrenValues,
|
|
145
|
+
handleParentClick,
|
|
146
|
+
};
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as OrCheckboxTreeV3 } from './OrCheckboxTree.vue';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
>
|
|
6
6
|
<input
|
|
7
7
|
ref="control"
|
|
8
|
-
|
|
8
|
+
:checked="isChecked"
|
|
9
9
|
v-bind="controlAttributes"
|
|
10
10
|
:class="controlStyles"
|
|
11
11
|
:type="'checkbox'"
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
:indeterminate="indeterminate"
|
|
14
14
|
:required="required"
|
|
15
15
|
:disabled="disabled"
|
|
16
|
+
@change="handleChange"
|
|
16
17
|
@focus="$emit('focus', $event)"
|
|
17
18
|
@blur="$emit('blur', $event)"
|
|
18
19
|
>
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
|
|
37
38
|
<script lang="ts">
|
|
38
39
|
import { computed, defineComponent, PropType, reactive, ref } from 'vue-demi';
|
|
40
|
+
import { useVModel } from '@vueuse/core';
|
|
39
41
|
import { useControlAttributes, useIdAttribute } from '../../hooks';
|
|
40
42
|
import { LabelVariant, OrLabelV3 as OrLabel } from '../or-label-v3';
|
|
41
43
|
import { CheckboxControl, CheckboxControlHandle, CheckboxRoot } from './styles';
|
|
@@ -54,13 +56,13 @@ export default defineComponent({
|
|
|
54
56
|
|
|
55
57
|
props: {
|
|
56
58
|
modelValue: {
|
|
57
|
-
type:
|
|
58
|
-
default:
|
|
59
|
+
type: null as any,
|
|
60
|
+
default: null,
|
|
59
61
|
},
|
|
60
62
|
|
|
61
63
|
value: {
|
|
62
|
-
type: String,
|
|
63
|
-
default:
|
|
64
|
+
type: [String, Boolean, Number] as PropType<string | boolean | number>,
|
|
65
|
+
default: null,
|
|
64
66
|
},
|
|
65
67
|
|
|
66
68
|
label: {
|
|
@@ -103,7 +105,7 @@ export default defineComponent({
|
|
|
103
105
|
'blur',
|
|
104
106
|
],
|
|
105
107
|
|
|
106
|
-
setup(props,
|
|
108
|
+
setup(props, { emit }) {
|
|
107
109
|
// Refs
|
|
108
110
|
const root = ref<HTMLElement>();
|
|
109
111
|
const control = ref<HTMLInputElement>();
|
|
@@ -125,15 +127,30 @@ export default defineComponent({
|
|
|
125
127
|
...useControlAttributes(),
|
|
126
128
|
});
|
|
127
129
|
|
|
128
|
-
const proxyModelValue =
|
|
129
|
-
|
|
130
|
+
const proxyModelValue = useVModel(props, 'modelValue', emit);
|
|
131
|
+
|
|
132
|
+
const isChecked = computed(() => {
|
|
133
|
+
if (Array.isArray(proxyModelValue.value)) {
|
|
134
|
+
return props.value && proxyModelValue.value.includes(props.value);
|
|
135
|
+
}
|
|
130
136
|
|
|
131
|
-
|
|
132
|
-
context.emit('update:modelValue', value);
|
|
133
|
-
},
|
|
137
|
+
return !!proxyModelValue.value;
|
|
134
138
|
});
|
|
135
139
|
|
|
136
140
|
// Methods
|
|
141
|
+
|
|
142
|
+
function handleChange(): void {
|
|
143
|
+
if (Array.isArray(proxyModelValue.value)) {
|
|
144
|
+
if (isChecked.value) {
|
|
145
|
+
proxyModelValue.value = proxyModelValue.value.filter((v) => v !== props.value);
|
|
146
|
+
} else {
|
|
147
|
+
proxyModelValue.value = [...proxyModelValue.value, props.value];
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
proxyModelValue.value = !proxyModelValue.value;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
137
154
|
function focus(): void {
|
|
138
155
|
control.value?.focus();
|
|
139
156
|
}
|
|
@@ -148,7 +165,8 @@ export default defineComponent({
|
|
|
148
165
|
rootStyles,
|
|
149
166
|
controlStyles,
|
|
150
167
|
controlAttributes,
|
|
151
|
-
|
|
168
|
+
isChecked,
|
|
169
|
+
handleChange,
|
|
152
170
|
focus,
|
|
153
171
|
blur,
|
|
154
172
|
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import OrFormGroup from './OrFormGroup.vue';
|
|
2
|
+
import { ref } from 'vue-demi';
|
|
3
|
+
import { Meta, StoryFn } from '@storybook/vue3';
|
|
4
|
+
import { OrRadioV3 as OrRadio } from '../or-radio-v3';
|
|
5
|
+
import { OrCheckboxV3 as OrCheckbox } from '../or-checkbox-v3';
|
|
6
|
+
import { OrSwitchV3 as OrSwitch } from '../or-switch-v3';
|
|
7
|
+
import { FormGroupDirection } from './props';
|
|
8
|
+
export default {
|
|
9
|
+
title: 'Components/Forms/Group',
|
|
10
|
+
component: OrFormGroup,
|
|
11
|
+
argTypes: {
|
|
12
|
+
// Props
|
|
13
|
+
label: {
|
|
14
|
+
control: { type: 'text' },
|
|
15
|
+
},
|
|
16
|
+
error: {
|
|
17
|
+
control: { type: 'text' },
|
|
18
|
+
},
|
|
19
|
+
hint: {
|
|
20
|
+
control: { type: 'text' },
|
|
21
|
+
},
|
|
22
|
+
direction: {
|
|
23
|
+
control: { type: 'select' },
|
|
24
|
+
options: Object.values(FormGroupDirection),
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
} as Meta<typeof OrFormGroup>;
|
|
28
|
+
|
|
29
|
+
const RadioTemplate: StoryFn<typeof OrFormGroup> = (args) => ({
|
|
30
|
+
components: {
|
|
31
|
+
OrFormGroup,
|
|
32
|
+
OrRadio,
|
|
33
|
+
},
|
|
34
|
+
setup() {
|
|
35
|
+
const modelValue = ref('');
|
|
36
|
+
return {
|
|
37
|
+
args,
|
|
38
|
+
modelValue,
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
template: `
|
|
42
|
+
<OrFormGroup
|
|
43
|
+
v-bind="args"
|
|
44
|
+
>
|
|
45
|
+
<OrRadio :label="'Option 1'" value="1" v-model="modelValue"/>
|
|
46
|
+
<OrRadio :label="'Option 2'" value="3" v-model="modelValue"/>
|
|
47
|
+
<OrRadio :label="'Option 3'" value="4" v-model="modelValue"/>
|
|
48
|
+
</OrFormGroup>
|
|
49
|
+
`,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export const RadioGroup = RadioTemplate.bind({});
|
|
53
|
+
RadioGroup.args = {
|
|
54
|
+
label: 'Radio Group',
|
|
55
|
+
hint: 'This is a hint',
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const CheckboxTemplate: StoryFn<typeof OrFormGroup> = (args) => ({
|
|
59
|
+
components: {
|
|
60
|
+
OrFormGroup,
|
|
61
|
+
OrCheckbox,
|
|
62
|
+
},
|
|
63
|
+
setup() {
|
|
64
|
+
const modelValue = ref([]);
|
|
65
|
+
return {
|
|
66
|
+
args,
|
|
67
|
+
modelValue,
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
template: `
|
|
71
|
+
<OrFormGroup
|
|
72
|
+
v-bind="args"
|
|
73
|
+
>
|
|
74
|
+
<OrCheckbox :label="'Option 1'" value="1" v-model="modelValue"/>
|
|
75
|
+
<OrCheckbox :label="'Option 2'" value="3" v-model="modelValue"/>
|
|
76
|
+
<OrCheckbox :label="'Option 3'" value="4" v-model="modelValue"/>
|
|
77
|
+
</OrFormGroup>
|
|
78
|
+
`,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export const CheckboxGroup = CheckboxTemplate.bind({});
|
|
82
|
+
CheckboxGroup.args = {
|
|
83
|
+
label: 'Checkbox Group',
|
|
84
|
+
hint: 'This is a hint',
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const SwitchTemplate: StoryFn<typeof OrFormGroup> = (args) => ({
|
|
88
|
+
components: {
|
|
89
|
+
OrFormGroup,
|
|
90
|
+
OrSwitch,
|
|
91
|
+
},
|
|
92
|
+
setup() {
|
|
93
|
+
const modelValue = ref([]);
|
|
94
|
+
return {
|
|
95
|
+
args,
|
|
96
|
+
modelValue,
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
template: `
|
|
100
|
+
<OrFormGroup
|
|
101
|
+
v-bind="args"
|
|
102
|
+
>
|
|
103
|
+
<OrSwitch :label="'Option 1'" value="1" v-model="modelValue"/>
|
|
104
|
+
<OrSwitch :label="'Option 2'" value="3" v-model="modelValue"/>
|
|
105
|
+
<OrSwitch :label="'Option 3'" value="4" v-model="modelValue"/>
|
|
106
|
+
</OrFormGroup>
|
|
107
|
+
`,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
export const SwitchGroup = SwitchTemplate.bind({});
|
|
111
|
+
SwitchGroup.args = {
|
|
112
|
+
label: 'Switch Group',
|
|
113
|
+
hint: 'This is a hint',
|
|
114
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
ref="root"
|
|
4
|
+
:class="rootStyles"
|
|
5
|
+
>
|
|
6
|
+
<div class="flex flex-row">
|
|
7
|
+
<slot name="label">
|
|
8
|
+
<OrLabel
|
|
9
|
+
v-if="label"
|
|
10
|
+
:required="required"
|
|
11
|
+
:disabled="disabled"
|
|
12
|
+
class="!typography-body-2-regular"
|
|
13
|
+
>
|
|
14
|
+
{{ label }}
|
|
15
|
+
|
|
16
|
+
<template v-slot:addon>
|
|
17
|
+
<slot name="addon" />
|
|
18
|
+
</template>
|
|
19
|
+
</OrLabel>
|
|
20
|
+
</slot>
|
|
21
|
+
</div>
|
|
22
|
+
<div
|
|
23
|
+
:class="contentStyles"
|
|
24
|
+
>
|
|
25
|
+
<slot />
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<template v-if="hint && !error">
|
|
29
|
+
<OrHint :disabled="disabled">
|
|
30
|
+
{{ hint }}
|
|
31
|
+
</OrHint>
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<template
|
|
35
|
+
v-if="typeof error === 'string'"
|
|
36
|
+
>
|
|
37
|
+
<OrError :disabled="disabled">
|
|
38
|
+
{{ error }}
|
|
39
|
+
</OrError>
|
|
40
|
+
</template>
|
|
41
|
+
</div>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script lang="ts">
|
|
45
|
+
import { defineComponent, ref, PropType, computed } from 'vue-demi';
|
|
46
|
+
import { OrLabelV3 as OrLabel } from '../or-label-v3';
|
|
47
|
+
import { OrErrorV3 as OrError } from '../or-error-v3';
|
|
48
|
+
import { OrHintV3 as OrHint } from '../or-hint-v3';
|
|
49
|
+
import { FormGroupDirection } from './props';
|
|
50
|
+
import { FormGroupContent, FormGroupContentDirections, FormGroupRoot } from './styles';
|
|
51
|
+
|
|
52
|
+
export default defineComponent({
|
|
53
|
+
name: 'OrFormGroupV3',
|
|
54
|
+
components: {
|
|
55
|
+
OrLabel,
|
|
56
|
+
OrError,
|
|
57
|
+
OrHint,
|
|
58
|
+
},
|
|
59
|
+
props: {
|
|
60
|
+
label: {
|
|
61
|
+
type: String,
|
|
62
|
+
default: undefined,
|
|
63
|
+
},
|
|
64
|
+
required: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
default: false,
|
|
67
|
+
},
|
|
68
|
+
disabled: {
|
|
69
|
+
type: Boolean,
|
|
70
|
+
default: false,
|
|
71
|
+
},
|
|
72
|
+
direction: {
|
|
73
|
+
type: String as PropType<FormGroupDirection>,
|
|
74
|
+
default: FormGroupDirection.Vertical,
|
|
75
|
+
},
|
|
76
|
+
error: {
|
|
77
|
+
type: [String, Boolean],
|
|
78
|
+
default: undefined,
|
|
79
|
+
},
|
|
80
|
+
hint: {
|
|
81
|
+
type: String,
|
|
82
|
+
default: undefined,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
setup(props) {
|
|
86
|
+
// Refs
|
|
87
|
+
const root = ref<HTMLElement>();
|
|
88
|
+
|
|
89
|
+
// Styles
|
|
90
|
+
const rootStyles = computed(() => [
|
|
91
|
+
'or-form-group-v3',
|
|
92
|
+
...FormGroupRoot,
|
|
93
|
+
]);
|
|
94
|
+
|
|
95
|
+
const contentStyles = computed(() => [
|
|
96
|
+
...FormGroupContent,
|
|
97
|
+
...FormGroupContentDirections[props.direction],
|
|
98
|
+
]);
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
root,
|
|
102
|
+
rootStyles,
|
|
103
|
+
contentStyles,
|
|
104
|
+
};
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
</script>
|