@onereach/ui-components 4.1.2 → 4.1.3-beta.2559.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.
Files changed (150) hide show
  1. package/dist/bundled/v2/components/OrCheckboxGroupV3/OrCheckboxGroup.js +140 -0
  2. package/dist/bundled/v2/components/OrCheckboxGroupV3/OrCheckboxGroup.vue.d.ts +115 -0
  3. package/dist/bundled/v2/components/OrCheckboxGroupV3/index.d.ts +1 -0
  4. package/dist/bundled/v2/components/OrCheckboxGroupV3/index.js +25 -0
  5. package/dist/bundled/v2/components/OrCheckboxTreeV3/OrCheckboxTree.js +203 -0
  6. package/dist/bundled/v2/components/OrCheckboxTreeV3/OrCheckboxTree.vue.d.ts +76 -0
  7. package/dist/bundled/v2/components/OrCheckboxTreeV3/index.d.ts +1 -0
  8. package/dist/bundled/v2/components/OrCheckboxTreeV3/index.js +17 -0
  9. package/dist/bundled/v2/components/OrCheckboxTreeV3/styles.d.ts +2 -0
  10. package/dist/bundled/v2/components/OrCheckboxTreeV3/styles.js +10 -0
  11. package/dist/bundled/v2/components/OrCheckboxTreeV3/types.d.ts +7 -0
  12. package/dist/bundled/v2/components/OrCheckboxTreeV3/types.js +1 -0
  13. package/dist/bundled/v2/components/OrCheckboxV3/OrCheckbox.js +34 -39
  14. package/dist/bundled/v2/components/OrCheckboxV3/OrCheckbox.vue.d.ts +18 -16
  15. package/dist/bundled/v2/components/OrCheckboxV3/index.js +1 -0
  16. package/dist/bundled/v2/components/OrFormGroupV3/OrFormGroup.js +123 -0
  17. package/dist/bundled/v2/components/OrFormGroupV3/OrFormGroup.vue.d.ts +85 -0
  18. package/dist/bundled/v2/components/OrFormGroupV3/index.d.ts +2 -0
  19. package/dist/bundled/v2/components/OrFormGroupV3/index.js +12 -0
  20. package/dist/bundled/v2/components/OrFormGroupV3/props.d.ts +4 -0
  21. package/dist/bundled/v2/components/OrFormGroupV3/props.js +7 -0
  22. package/dist/bundled/v2/components/OrFormGroupV3/styles.d.ts +6 -0
  23. package/dist/bundled/v2/components/OrFormGroupV3/styles.js +20 -0
  24. package/dist/bundled/v2/components/OrRadioGroupV3/OrRadioGroup.js +132 -0
  25. package/dist/bundled/v2/components/OrRadioGroupV3/OrRadioGroup.vue.d.ts +110 -0
  26. package/dist/bundled/v2/components/OrRadioGroupV3/index.d.ts +1 -0
  27. package/dist/bundled/v2/components/OrRadioGroupV3/index.js +19 -0
  28. package/dist/bundled/v2/components/OrSelectV3/OrSelect.js +1 -1
  29. package/dist/bundled/v2/components/OrSelectV3/index.js +1 -1
  30. package/dist/bundled/v2/index.d.ts +1 -0
  31. package/dist/bundled/v2/index.js +4 -3
  32. package/dist/bundled/v2/utils/functions/flattenDeep.d.ts +2 -0
  33. package/dist/bundled/v2/utils/functions/flattenDeep.js +5 -0
  34. package/dist/bundled/v3/{OrCheckbox.vue_vue_type_script_lang-60cefcbd.js → OrCheckbox.vue_vue_type_script_lang-51a4f8d3.js} +26 -10
  35. package/dist/bundled/v3/OrCheckboxTree.vue_vue_type_script_lang-ffa313a0.js +102 -0
  36. package/dist/bundled/v3/OrFormGroup.vue_vue_type_script_lang-360b258b.js +60 -0
  37. package/dist/bundled/v3/{OrSelect.vue_vue_type_script_lang-f7601423.js → OrSelect.vue_vue_type_script_lang-c0612348.js} +1 -1
  38. package/dist/bundled/v3/components/OrCheckboxGroupV3/OrCheckboxGroup.js +112 -0
  39. package/dist/bundled/v3/components/OrCheckboxGroupV3/OrCheckboxGroup.vue.d.ts +115 -0
  40. package/dist/bundled/v3/components/OrCheckboxGroupV3/index.d.ts +1 -0
  41. package/dist/bundled/v3/components/OrCheckboxGroupV3/index.js +32 -0
  42. package/dist/bundled/v3/components/OrCheckboxTreeV3/OrCheckboxTree.js +74 -0
  43. package/dist/bundled/v3/components/OrCheckboxTreeV3/OrCheckboxTree.vue.d.ts +76 -0
  44. package/dist/bundled/v3/components/OrCheckboxTreeV3/index.d.ts +1 -0
  45. package/dist/bundled/v3/components/OrCheckboxTreeV3/index.js +20 -0
  46. package/dist/bundled/v3/components/OrCheckboxTreeV3/styles.d.ts +2 -0
  47. package/dist/bundled/v3/components/OrCheckboxTreeV3/styles.js +10 -0
  48. package/dist/bundled/v3/components/OrCheckboxTreeV3/types.d.ts +7 -0
  49. package/dist/bundled/v3/components/OrCheckboxTreeV3/types.js +1 -0
  50. package/dist/bundled/v3/components/OrCheckboxV3/OrCheckbox.js +9 -7
  51. package/dist/bundled/v3/components/OrCheckboxV3/OrCheckbox.vue.d.ts +18 -16
  52. package/dist/bundled/v3/components/OrCheckboxV3/index.js +2 -1
  53. package/dist/bundled/v3/components/OrFormGroupV3/OrFormGroup.js +58 -0
  54. package/dist/bundled/v3/components/OrFormGroupV3/OrFormGroup.vue.d.ts +85 -0
  55. package/dist/bundled/v3/components/OrFormGroupV3/index.d.ts +2 -0
  56. package/dist/bundled/v3/components/OrFormGroupV3/index.js +15 -0
  57. package/dist/bundled/v3/components/OrFormGroupV3/props.d.ts +4 -0
  58. package/dist/bundled/v3/components/OrFormGroupV3/props.js +7 -0
  59. package/dist/bundled/v3/components/OrFormGroupV3/styles.d.ts +6 -0
  60. package/dist/bundled/v3/components/OrFormGroupV3/styles.js +20 -0
  61. package/dist/bundled/v3/components/OrRadioGroupV3/OrRadioGroup.js +104 -0
  62. package/dist/bundled/v3/components/OrRadioGroupV3/OrRadioGroup.vue.d.ts +110 -0
  63. package/dist/bundled/v3/components/OrRadioGroupV3/index.d.ts +1 -0
  64. package/dist/bundled/v3/components/OrRadioGroupV3/index.js +24 -0
  65. package/dist/bundled/v3/components/OrSelectV3/OrSelect.js +4 -4
  66. package/dist/bundled/v3/components/OrSelectV3/index.js +3 -3
  67. package/dist/bundled/v3/components/index.js +2 -2
  68. package/dist/bundled/v3/index.d.ts +1 -0
  69. package/dist/bundled/v3/index.js +7 -7
  70. package/dist/bundled/v3/utils/functions/flattenDeep.d.ts +2 -0
  71. package/dist/bundled/v3/utils/functions/flattenDeep.js +5 -0
  72. package/dist/esm/v2/{OrCheckbox-dc587ec9.js → OrCheckbox-e55228e5.js} +34 -40
  73. package/dist/esm/v2/OrCheckboxTree-4944c6a3.js +202 -0
  74. package/dist/esm/v2/OrFormGroup-7a883bce.js +140 -0
  75. package/dist/esm/v2/{OrSelect-40183874.js → OrSelect-4031334e.js} +1 -1
  76. package/dist/esm/v2/components/index.js +2 -2
  77. package/dist/esm/v2/components/or-checkbox-group-v3/OrCheckboxGroup.vue.d.ts +115 -0
  78. package/dist/esm/v2/components/or-checkbox-group-v3/index.d.ts +1 -0
  79. package/dist/esm/v2/components/or-checkbox-group-v3/index.js +129 -0
  80. package/dist/esm/v2/components/or-checkbox-tree-v3/OrCheckboxTree.vue.d.ts +76 -0
  81. package/dist/esm/v2/components/or-checkbox-tree-v3/index.d.ts +1 -0
  82. package/dist/esm/v2/components/or-checkbox-tree-v3/index.js +10 -0
  83. package/dist/esm/v2/components/or-checkbox-tree-v3/styles.d.ts +2 -0
  84. package/dist/esm/v2/components/or-checkbox-tree-v3/types.d.ts +7 -0
  85. package/dist/esm/v2/components/or-checkbox-v3/OrCheckbox.vue.d.ts +18 -16
  86. package/dist/esm/v2/components/or-checkbox-v3/index.js +2 -2
  87. package/dist/esm/v2/components/or-form-group-v3/OrFormGroup.vue.d.ts +85 -0
  88. package/dist/esm/v2/components/or-form-group-v3/index.d.ts +2 -0
  89. package/dist/esm/v2/components/or-form-group-v3/index.js +6 -0
  90. package/dist/esm/v2/components/or-form-group-v3/props.d.ts +4 -0
  91. package/dist/esm/v2/components/or-form-group-v3/styles.d.ts +6 -0
  92. package/dist/esm/v2/components/or-radio-group-v3/OrRadioGroup.vue.d.ts +110 -0
  93. package/dist/esm/v2/components/or-radio-group-v3/index.d.ts +1 -0
  94. package/dist/esm/v2/components/or-radio-group-v3/index.js +124 -0
  95. package/dist/esm/v2/components/or-select-v3/index.js +2 -2
  96. package/dist/esm/v2/flattenDeep-e7a8b995.js +5 -0
  97. package/dist/esm/v2/index.d.ts +1 -0
  98. package/dist/esm/v2/index.js +3 -2
  99. package/dist/esm/v2/utils/functions/flattenDeep.d.ts +2 -0
  100. package/dist/esm/v3/{OrCheckbox-56f849f7.js → OrCheckbox-eab735d0.js} +32 -16
  101. package/dist/esm/v3/OrCheckboxTree-7a2a4b7d.js +162 -0
  102. package/dist/esm/v3/OrFormGroup-d9255559.js +121 -0
  103. package/dist/esm/v3/{OrSelect-5502d82d.js → OrSelect-ebdab996.js} +1 -1
  104. package/dist/esm/v3/components/index.js +2 -2
  105. package/dist/esm/v3/components/or-checkbox-group-v3/OrCheckboxGroup.vue.d.ts +115 -0
  106. package/dist/esm/v3/components/or-checkbox-group-v3/index.d.ts +1 -0
  107. package/dist/esm/v3/components/or-checkbox-group-v3/index.js +94 -0
  108. package/dist/esm/v3/components/or-checkbox-tree-v3/OrCheckboxTree.vue.d.ts +76 -0
  109. package/dist/esm/v3/components/or-checkbox-tree-v3/index.d.ts +1 -0
  110. package/dist/esm/v3/components/or-checkbox-tree-v3/index.js +10 -0
  111. package/dist/esm/v3/components/or-checkbox-tree-v3/styles.d.ts +2 -0
  112. package/dist/esm/v3/components/or-checkbox-tree-v3/types.d.ts +7 -0
  113. package/dist/esm/v3/components/or-checkbox-v3/OrCheckbox.vue.d.ts +18 -16
  114. package/dist/esm/v3/components/or-checkbox-v3/index.js +2 -2
  115. package/dist/esm/v3/components/or-form-group-v3/OrFormGroup.vue.d.ts +85 -0
  116. package/dist/esm/v3/components/or-form-group-v3/index.d.ts +2 -0
  117. package/dist/esm/v3/components/or-form-group-v3/index.js +6 -0
  118. package/dist/esm/v3/components/or-form-group-v3/props.d.ts +4 -0
  119. package/dist/esm/v3/components/or-form-group-v3/styles.d.ts +6 -0
  120. package/dist/esm/v3/components/or-radio-group-v3/OrRadioGroup.vue.d.ts +110 -0
  121. package/dist/esm/v3/components/or-radio-group-v3/index.d.ts +1 -0
  122. package/dist/esm/v3/components/or-radio-group-v3/index.js +91 -0
  123. package/dist/esm/v3/components/or-select-v3/index.js +2 -2
  124. package/dist/esm/v3/flattenDeep-e7a8b995.js +5 -0
  125. package/dist/esm/v3/index.d.ts +1 -0
  126. package/dist/esm/v3/index.js +3 -2
  127. package/dist/esm/v3/utils/functions/flattenDeep.d.ts +2 -0
  128. package/package.json +2 -3
  129. package/src/components/or-checkbox-group-v3/OrCheckboxGroup.docs.mdx +7 -0
  130. package/src/components/or-checkbox-group-v3/OrCheckboxGroup.stories3.ts +309 -0
  131. package/src/components/or-checkbox-group-v3/OrCheckboxGroup.vue +82 -0
  132. package/src/components/or-checkbox-group-v3/index.ts +1 -0
  133. package/src/components/or-checkbox-tree-v3/OrCheckboxTree.docs.mdx +7 -0
  134. package/src/components/or-checkbox-tree-v3/OrCheckboxTree.stories3.ts +112 -0
  135. package/src/components/or-checkbox-tree-v3/OrCheckboxTree.vue +168 -0
  136. package/src/components/or-checkbox-tree-v3/index.ts +1 -0
  137. package/src/components/or-checkbox-tree-v3/styles.ts +15 -0
  138. package/src/components/or-checkbox-tree-v3/types.ts +7 -0
  139. package/src/components/or-checkbox-v3/OrCheckbox.vue +30 -12
  140. package/src/components/or-form-group-v3/OrFormGroup.stories3.ts +114 -0
  141. package/src/components/or-form-group-v3/OrFormGroup.vue +114 -0
  142. package/src/components/or-form-group-v3/index.ts +2 -0
  143. package/src/components/or-form-group-v3/props.ts +4 -0
  144. package/src/components/or-form-group-v3/styles.ts +36 -0
  145. package/src/components/or-radio-group-v3/OrRadioGroup.stories3.ts +81 -0
  146. package/src/components/or-radio-group-v3/OrRadioGroup.vue +80 -0
  147. package/src/components/or-radio-group-v3/index.ts +1 -0
  148. package/src/components/or-radio-v3/OrRadio.stories3.ts +1 -1
  149. package/src/index.ts +1 -0
  150. package/src/utils/functions/flattenDeep.ts +5 -0
@@ -0,0 +1,309 @@
1
+ import { action } from '@storybook/addon-actions';
2
+ import { Meta, StoryFn } from '@storybook/vue3';
3
+ import { ref, watch } from 'vue-demi';
4
+ import { FormGroupDirection } from '../or-form-group-v3';
5
+ import OrCheckboxGroupDocs from './OrCheckboxGroup.docs.mdx';
6
+ import OrCheckboxGroup from './OrCheckboxGroup.vue';
7
+ import { OrIconV3 as OrIcon } from '../or-icon-v3';
8
+
9
+ export default {
10
+ title: 'Components/Forms/Checkbox/Group',
11
+ component: OrCheckboxGroup,
12
+ argTypes: {
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: {
24
+ type: 'radio',
25
+ options: Object.values(FormGroupDirection),
26
+ },
27
+ },
28
+ },
29
+ parameters: {
30
+ docs: {
31
+ page: OrCheckboxGroupDocs,
32
+ },
33
+ design: {
34
+ type: 'figma',
35
+ url: 'https://www.figma.com/file/o7DdkaznUW2PtX4wiSuhhQ/Core?node-id=202%3A12',
36
+ },
37
+ },
38
+ } as Meta<typeof OrCheckboxGroup>;
39
+
40
+ const Template: StoryFn<typeof OrCheckboxGroup> = (args) => ({
41
+ components: {
42
+ OrCheckboxGroup,
43
+ },
44
+ setup() {
45
+ const model = ref([]);
46
+
47
+ watch(model, (value) => {
48
+ console.debug(value);
49
+ });
50
+
51
+ return {
52
+ args,
53
+ model,
54
+ onUpdateModelValue: action('update:modelValue'),
55
+ };
56
+ },
57
+
58
+ template: `
59
+ <div class="contents">
60
+ <OrCheckboxGroup
61
+ v-bind="args"
62
+ v-model="model"
63
+ @update:modelValue="onUpdateModelValue"
64
+ />
65
+ </div>
66
+ `,
67
+ });
68
+
69
+ export const CheckboxGroup = Template.bind({});
70
+
71
+ CheckboxGroup.args = {
72
+ label: 'Checkbox Group',
73
+ options: [
74
+ {
75
+ label: 'Option 1',
76
+ value: '1',
77
+ },
78
+ {
79
+ label: 'Option 2',
80
+ value: '2',
81
+ },
82
+ {
83
+ label: 'Option 3',
84
+ value: '3',
85
+ },
86
+ ],
87
+ };
88
+
89
+ export const CheckboxGroupTree = Template.bind({});
90
+
91
+ CheckboxGroupTree.args = {
92
+ label: 'Checkbox Group tree',
93
+ options: [
94
+ {
95
+ label: 'Option 1',
96
+ children: [
97
+ {
98
+ label: 'Option 1.1',
99
+ value: '1.1',
100
+ },
101
+ {
102
+ label: 'Option 1.2',
103
+ value: '1.2',
104
+ },
105
+ {
106
+ label: 'Option 1.3',
107
+ value: '1.3',
108
+ },
109
+ ],
110
+ },
111
+ ],
112
+ };
113
+
114
+
115
+ export const CheckboxGroupDeepTree = Template.bind({});
116
+
117
+ CheckboxGroupDeepTree.args = {
118
+ label: 'Checkbox Group tree',
119
+ options: [
120
+ {
121
+ label: 'Option 1',
122
+ value: '1',
123
+ },
124
+ {
125
+ label: 'Option 2',
126
+ value: '2',
127
+ },
128
+ {
129
+ label: 'Option 3',
130
+ children: [
131
+ {
132
+ label: 'Option 3.1',
133
+ value: '3.1',
134
+ },
135
+ {
136
+ label: 'Option 3.2',
137
+ value: '3.2',
138
+ },
139
+ {
140
+ label: 'Option 3.3',
141
+ children: [
142
+ {
143
+ label: 'Option 3.3.1',
144
+ value: '3.3.1',
145
+ },
146
+ {
147
+ label: 'Option 3.3.2',
148
+ value: '3.3.2',
149
+ },
150
+ {
151
+ label: 'Option 3.3.3',
152
+ value: '3.3.3',
153
+ },
154
+ ],
155
+ },
156
+ ],
157
+ },
158
+ ],
159
+ };
160
+
161
+
162
+ export const CheckboxGroupDeepCollapsibleTree = Template.bind({});
163
+
164
+ CheckboxGroupDeepCollapsibleTree.args = {
165
+ label: 'Checkbox Group tree',
166
+ options: [
167
+ {
168
+ label: 'Option 1',
169
+ value: '1',
170
+ },
171
+ {
172
+ label: 'Option 2',
173
+ value: '2',
174
+ },
175
+ {
176
+ label: 'Option 3',
177
+ collapsible: true,
178
+ children: [
179
+ {
180
+ label: 'Option 3.1',
181
+ value: '3.1',
182
+ },
183
+ {
184
+ label: 'Option 3.2',
185
+ value: '3.2',
186
+ },
187
+ {
188
+ label: 'Option 3.3',
189
+ collapsible: true,
190
+ children: [
191
+ {
192
+ label: 'Option 3.3.1',
193
+ value: '3.3.1',
194
+ },
195
+ {
196
+ label: 'Option 3.3.2',
197
+ value: '3.3.2',
198
+ },
199
+ {
200
+ label: 'Option 3.3.3',
201
+ value: '3.3.3',
202
+ },
203
+ ],
204
+ },
205
+ ],
206
+ },
207
+ ],
208
+ };
209
+
210
+ export const CheckboxGroupDeepPartiallyCollapsibleTree = Template.bind({});
211
+
212
+ CheckboxGroupDeepPartiallyCollapsibleTree.args = {
213
+ label: 'Checkbox Group tree',
214
+ options: [
215
+ {
216
+ label: 'Option 1',
217
+ value: '1',
218
+ },
219
+ {
220
+ label: 'Option 2',
221
+ value: '2',
222
+ },
223
+ {
224
+ label: 'Option 3',
225
+ collapsible: true,
226
+ children: [
227
+ {
228
+ label: 'Option 3.1',
229
+ value: '3.1',
230
+ },
231
+ {
232
+ label: 'Option 3.2',
233
+ value: '3.2',
234
+ },
235
+ {
236
+ label: 'Option 3.3',
237
+ children: [
238
+ {
239
+ label: 'Option 3.3.1',
240
+ value: '3.3.1',
241
+ },
242
+ {
243
+ label: 'Option 3.3.2',
244
+ value: '3.3.2',
245
+ },
246
+ {
247
+ label: 'Option 3.3.3',
248
+ value: '3.3.3',
249
+ },
250
+ ],
251
+ },
252
+ ],
253
+ },
254
+ ],
255
+ };
256
+
257
+ const TemplateWithAddon: StoryFn<typeof OrCheckboxGroup> = (args) => ({
258
+ components: {
259
+ OrCheckboxGroup,
260
+ OrIcon,
261
+ },
262
+ setup() {
263
+ const model = ref([]);
264
+
265
+ watch(model, (value) => {
266
+ console.debug(value);
267
+ });
268
+
269
+ return {
270
+ args,
271
+ model,
272
+ onUpdateModelValue: action('update:modelValue'),
273
+ };
274
+ },
275
+
276
+ template: `
277
+ <div class="contents">
278
+ <OrCheckboxGroup
279
+ v-bind="args"
280
+ v-model="model"
281
+ @update:modelValue="onUpdateModelValue"
282
+ >
283
+ <template #addon>
284
+ <OrIcon icon="info" />
285
+ </template>
286
+ </OrCheckboxGroup>
287
+ </div>
288
+ `,
289
+ });
290
+
291
+ export const CheckboxGroupWithAddon = TemplateWithAddon.bind({});
292
+
293
+ CheckboxGroupWithAddon.args = {
294
+ label: 'Checkbox Group',
295
+ options: [
296
+ {
297
+ label: 'Option 1',
298
+ value: '1',
299
+ },
300
+ {
301
+ label: 'Option 2',
302
+ value: '2',
303
+ },
304
+ {
305
+ label: 'Option 3',
306
+ value: '3',
307
+ },
308
+ ],
309
+ };
@@ -0,0 +1,82 @@
1
+ <template>
2
+ <OrFormGroup
3
+ :label="label"
4
+ :error="error"
5
+ :hint="hint"
6
+ :disabled="disabled"
7
+ :direction="direction"
8
+ >
9
+ <template v-slot:addon>
10
+ <slot name="addon" />
11
+ </template>
12
+ <OrCheckboxTree
13
+ v-for="option in options"
14
+ :key="option.value"
15
+ v-model="proxyModelValue"
16
+ :item="option"
17
+ :disabled="disabled || option.disabled"
18
+ :collapsible="option.collapsible"
19
+ />
20
+ </OrFormGroup>
21
+ </template>
22
+
23
+ <script lang="ts">
24
+ import { defineComponent, PropType } from 'vue-demi';
25
+ import { useVModel } from '@vueuse/core';
26
+ import { OrFormGroupV3 as OrFormGroup, FormGroupDirection } from '../or-form-group-v3';
27
+ import { OrCheckboxTreeV3 as OrCheckboxTree } from '../or-checkbox-tree-v3';
28
+
29
+
30
+ export default defineComponent({
31
+ name: 'OrCheckboxGroup',
32
+ components: {
33
+ OrCheckboxTree,
34
+ OrFormGroup,
35
+ },
36
+ model: {
37
+ prop: 'modelValue',
38
+ event: 'update:modelValue',
39
+ },
40
+ props: {
41
+ modelValue: {
42
+ type: Array as PropType<string[]>,
43
+ default: () => [],
44
+ },
45
+ label: {
46
+ type: String,
47
+ default: '',
48
+ },
49
+ error: {
50
+ type: String,
51
+ default: '',
52
+ },
53
+ hint: {
54
+ type: String,
55
+ default: '',
56
+ },
57
+ direction: {
58
+ type: String as PropType<FormGroupDirection>,
59
+ default: FormGroupDirection.Vertical,
60
+ },
61
+ options: {
62
+ type: Array as PropType<{ label: string; value: any; disabled?: boolean; collapsible: boolean;}[]>,
63
+ default: () => [],
64
+ },
65
+ disabled: {
66
+ type: Boolean,
67
+ default: false,
68
+ },
69
+ },
70
+ setup(props, { emit }) {
71
+ const proxyModelValue = useVModel(props, 'modelValue', emit);
72
+ return {
73
+ proxyModelValue,
74
+ };
75
+ },
76
+ });
77
+
78
+ </script>
79
+
80
+ <style scoped>
81
+
82
+ </style>
@@ -0,0 +1 @@
1
+ export { default as OrCheckboxGroupV3 } from './OrCheckboxGroup.vue';
@@ -0,0 +1,7 @@
1
+ import { DocsPage } from '@storybook/addon-docs';
2
+
3
+ ```ts
4
+ import { OrCheckboxTreeV3 as OrCheckboxTree } from '@onereach/ui-components';
5
+ ```
6
+
7
+ <DocsPage />
@@ -0,0 +1,112 @@
1
+ import { Meta, StoryFn } from '@storybook/vue3';
2
+ import { ref } from 'vue-demi';
3
+ import OrCheckboxTreeDocs from './OrCheckboxTree.docs.mdx';
4
+ import OrCheckboxTree from './OrCheckboxTree.vue';
5
+
6
+ export default {
7
+ title: 'Components/Forms/Checkbox/Tree',
8
+ component: OrCheckboxTree,
9
+ parameters: {
10
+ docs: {
11
+ page: OrCheckboxTreeDocs,
12
+ },
13
+ },
14
+ } as Meta<typeof OrCheckboxTree>;
15
+
16
+ const Template: StoryFn<typeof OrCheckboxTree> = (args) => ({
17
+ components: {
18
+ OrCheckboxTree,
19
+ },
20
+ setup() {
21
+ const model = ref<string[]>([]);
22
+ return {
23
+ args,
24
+ model,
25
+ };
26
+ },
27
+ template: `
28
+ <div class="contents">
29
+ <OrCheckboxTree
30
+ v-for="item in args.items"
31
+ v-model="model"
32
+ :item="item"
33
+ />
34
+ </div>
35
+ `,
36
+ });
37
+
38
+ export const Default = Template.bind({});
39
+ Default.args = {
40
+ items: [
41
+ {
42
+ label: 'Option 1',
43
+ value: '1',
44
+ },
45
+ {
46
+ label: 'Option 2',
47
+ value: '2',
48
+ },
49
+ {
50
+ label: 'Option 3',
51
+ children: [
52
+ {
53
+ label: 'Option 3.1',
54
+ value: '3.1',
55
+ },
56
+ {
57
+ label: 'Option 3.2',
58
+ collapsible: true,
59
+ children: [
60
+ {
61
+ label: 'Option 3.2.1',
62
+ value: '3.2.1',
63
+ },
64
+ {
65
+ label: 'Option 3.2.2',
66
+ value: '3.2.2',
67
+ },
68
+ {
69
+ label: 'Option 3.2.3',
70
+ children: [
71
+ {
72
+ label: 'Option',
73
+ value: '3.3.1',
74
+ },
75
+ {
76
+ label: 'Option',
77
+ value: '3.3.2',
78
+ },
79
+ {
80
+ label: 'Option',
81
+ value: '3.3.3',
82
+ },
83
+ ],
84
+ },
85
+ ],
86
+ },
87
+ {
88
+ label: 'Option 3.3',
89
+ value: '3.3',
90
+ },
91
+ ],
92
+ },
93
+ {
94
+ label: 'Option 4',
95
+ value: '4',
96
+ },
97
+ {
98
+ label: 'Option 5',
99
+ collapsible: true,
100
+ children: [
101
+ {
102
+ label: 'Option 5.1',
103
+ value: '5.1',
104
+ },
105
+ {
106
+ label: 'Option 5.2',
107
+ value: '5.2',
108
+ },
109
+ ],
110
+ },
111
+ ],
112
+ };
@@ -0,0 +1,168 @@
1
+ <template>
2
+ <div
3
+ ref="root"
4
+ :class="rootStyles"
5
+ >
6
+ <template v-if="hasChildren">
7
+ <div :class="parentStyles">
8
+ <template
9
+ v-if="collapsible"
10
+ >
11
+ <OrIcon
12
+ :class="[isOpen ? 'rotate-[180deg]': 'rotate-0']"
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
+ :disabled="disabled"
24
+ @click="handleParentClick"
25
+ />
26
+ </div>
27
+ <div
28
+ v-if="hasChildren && isOpen"
29
+ :class="{
30
+ 'ml-2xl': collapsible,
31
+ 'ml-lg': !collapsible
32
+ }"
33
+ >
34
+ <OrCheckboxTree
35
+ v-for="child in item.children"
36
+ :key="child.value"
37
+ v-model="proxyModelValue"
38
+ class="mt-xs"
39
+ :item="child"
40
+ :collapsible="child.collapsible"
41
+ :disabled="disabled || child.disabled"
42
+ />
43
+ </div>
44
+ </template>
45
+ <template v-else>
46
+ <OrCheckbox
47
+ v-model="proxyModelValue"
48
+ :disabled="disabled || item.disabled"
49
+ :label="item.label"
50
+ :value="item.value"
51
+ />
52
+ </template>
53
+ </div>
54
+ </template>
55
+
56
+ <script lang="ts">
57
+ import { computed, defineComponent, PropType } from 'vue-demi';
58
+ import { useVModel, useToggle } from '@vueuse/core';
59
+ import { OrCheckboxV3 as OrCheckbox } from '../or-checkbox-v3';
60
+ import { OrIconV3 as OrIcon } from '../or-icon-v3';
61
+ import { CheckboxTreeRoot, CheckboxTreeRootParent } from './styles';
62
+ import { CheckboxNode } from './types';
63
+ import flattenDeep from '../../utils/functions/flattenDeep';
64
+
65
+ export default defineComponent({
66
+ name: 'OrCheckboxTree',
67
+ components: {
68
+ OrIcon,
69
+ OrCheckbox,
70
+ },
71
+
72
+ model: {
73
+ prop: 'modelValue',
74
+ event: 'update:modelValue',
75
+ },
76
+
77
+ props: {
78
+ modelValue: {
79
+ type: Array as PropType<string[]>,
80
+ default: () => [],
81
+ },
82
+ item: {
83
+ type: Object as PropType<CheckboxNode>,
84
+ required: true,
85
+ },
86
+ collapsible: {
87
+ type: Boolean,
88
+ default: false,
89
+ },
90
+ disabled: {
91
+ type: Boolean,
92
+ default: false,
93
+ },
94
+ },
95
+
96
+ setup(props, { emit }) {
97
+
98
+ // State
99
+ const hasChildren = computed(() => props.item.children && props.item.children.length > 0);
100
+ const childrenValues = computed(() => {
101
+ const getChildValues = (children?: CheckboxNode[]): any[] | undefined => {
102
+ return children?.map((child) => {
103
+ if (child.children) {
104
+ return getChildValues(child.children);
105
+ } else {
106
+ return child.value;
107
+ }
108
+ });
109
+ };
110
+
111
+ return flattenDeep(getChildValues(props.item.children));
112
+ });
113
+
114
+ const proxyModelValue = useVModel(props, 'modelValue', emit);
115
+
116
+ const isAnyChildrenSelected = computed(() => {
117
+ return proxyModelValue.value?.some((value) => childrenValues.value?.includes(value));
118
+ });
119
+
120
+ const isAllChildrenSelected = computed(() => {
121
+ return childrenValues.value?.every((value) => proxyModelValue.value?.includes(value));
122
+ });
123
+
124
+ const isIntermediate = computed(() => {
125
+ return isAnyChildrenSelected.value && !isAllChildrenSelected.value;
126
+ });
127
+
128
+ const [isOpen, setIsOpen] = useToggle(true);
129
+
130
+ // Styles
131
+ const rootStyles = computed(() => [
132
+ 'or-checkbox-tree-v3',
133
+ ...CheckboxTreeRoot,
134
+ ]);
135
+
136
+ // Styles
137
+ const parentStyles = computed(() => [
138
+ ...CheckboxTreeRootParent,
139
+ ]);
140
+
141
+ // Methods
142
+ const handleParentClick = () => {
143
+ if (isAllChildrenSelected.value) {
144
+ proxyModelValue.value = proxyModelValue.value.filter((value) => !childrenValues.value.includes(value));
145
+ } else {
146
+ proxyModelValue.value = [
147
+ ...proxyModelValue.value,
148
+ ...childrenValues.value,
149
+ ];
150
+ }
151
+ };
152
+
153
+ return {
154
+ rootStyles,
155
+ parentStyles,
156
+ hasChildren,
157
+ proxyModelValue,
158
+ isOpen,
159
+ setIsOpen,
160
+ isIntermediate,
161
+ isAllChildrenSelected,
162
+ isAnyChildrenSelected,
163
+ childrenValues,
164
+ handleParentClick,
165
+ };
166
+ },
167
+ });
168
+ </script>
@@ -0,0 +1 @@
1
+ export { default as OrCheckboxTreeV3 } from './OrCheckboxTree.vue';
@@ -0,0 +1,15 @@
1
+ export const CheckboxTreeRoot: string[] = [
2
+ // Layout
3
+ 'flex',
4
+ 'flex-col',
5
+
6
+ // Spacing
7
+ 'gap-sm+ md:gap-sm',
8
+ ];
9
+
10
+ export const CheckboxTreeRootParent: string[] = [
11
+ // Layout
12
+ 'flex',
13
+ 'flex-row',
14
+ 'gap-xs',
15
+ ];
@@ -0,0 +1,7 @@
1
+ export type CheckboxNode = {
2
+ label: string;
3
+ value: string;
4
+ children?: CheckboxNode[];
5
+ collapsible?: boolean;
6
+ disabled?: boolean;
7
+ };