@onereach/ui-components 2.62.7-beta.1930.0 → 2.62.7-beta.1932.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 (254) hide show
  1. package/dist/v2/{OrConfirm-edc537b3.js → OrConfirm-24e2a1a2.js} +1 -1
  2. package/dist/v2/{OrInlineInput-73ec1b85.js → OrInlineInput-f00cba5e.js} +8 -7
  3. package/dist/v2/{OrInlineTextarea-1858a348.js → OrInlineTextarea-75de33d0.js} +8 -7
  4. package/dist/v2/{OrInput-655bed71.js → OrInput-24028f23.js} +5 -5
  5. package/dist/v2/{OrSearch-287a08a9.js → OrSearch-978a3a6e.js} +1 -1
  6. package/dist/v2/OrSegmentedControl-17df63b8.js +236 -0
  7. package/dist/v2/{OrSelect-1a353817.js → OrSelect-c6d0a69e.js} +3 -3
  8. package/dist/v2/{OrTabs-b4a9740b.js → OrTabs-f2a60b41.js} +1 -1
  9. package/dist/v2/{OrTextarea-cc70afc9.js → OrTextarea-8773d494.js} +5 -5
  10. package/dist/v2/components/index.d.ts +1 -2
  11. package/dist/v2/components/{or-sort-header-v3/OrSortHeader.stories3.d.ts → or-segmented-control-v3/OrSegmentedControl.stories3.d.ts} +1 -1
  12. package/dist/{v3/components/or-sort-header-v3/OrSortHeader.vue.d.ts → v2/components/or-segmented-control-v3/OrSegmentedControl.vue.d.ts} +45 -25
  13. package/dist/v2/components/or-segmented-control-v3/components/or-segmented-control-item/OrSegmentedControlItem.vue.d.ts +47 -0
  14. package/dist/v2/components/or-segmented-control-v3/components/or-segmented-control-item/styles.d.ts +3 -0
  15. package/dist/v2/components/or-segmented-control-v3/index.d.ts +3 -0
  16. package/dist/v2/components/or-segmented-control-v3/props.d.ts +4 -0
  17. package/dist/v2/components/or-segmented-control-v3/styles.d.ts +3 -0
  18. package/dist/v2/components/or-segmented-control-v3/types.d.ts +4 -0
  19. package/dist/v2/index.js +9 -10
  20. package/dist/v2/index11.js +1 -20
  21. package/dist/v2/index12.js +12 -3
  22. package/dist/v2/index13.js +2 -3
  23. package/dist/v2/index14.js +5 -11
  24. package/dist/v2/index15.js +14 -5
  25. package/dist/v2/index16.js +19 -4
  26. package/dist/v2/index17.js +4 -28
  27. package/dist/v2/index18.js +7 -3
  28. package/dist/v2/index19.js +23 -5
  29. package/dist/v2/index2.js +9 -10
  30. package/dist/v2/index20.js +21 -25
  31. package/dist/v2/index21.js +18 -21
  32. package/dist/v2/index22.js +2 -20
  33. package/dist/v2/index23.js +4 -2
  34. package/dist/v2/index24.js +1 -2
  35. package/dist/v2/index25.js +2 -1
  36. package/dist/v2/index26.js +2 -2
  37. package/dist/v2/index27.js +7 -4
  38. package/dist/v2/index28.js +2 -6
  39. package/dist/v2/index29.js +3 -3
  40. package/dist/v2/index30.js +10 -3
  41. package/dist/v2/index31.js +12 -9
  42. package/dist/v2/index32.js +1 -11
  43. package/dist/v2/index33.js +1 -1
  44. package/dist/v2/index34.js +16 -1
  45. package/dist/v2/index35.js +17 -17
  46. package/dist/v2/index36.js +17 -17
  47. package/dist/v2/index37.js +1 -16
  48. package/dist/v2/index38.js +17 -1
  49. package/dist/v2/index39.js +22 -18
  50. package/dist/v2/index40.js +2 -22
  51. package/dist/v2/index41.js +3 -3
  52. package/dist/v2/index42.js +1 -1
  53. package/dist/v2/index43.js +20 -3
  54. package/dist/v2/index44.js +7 -1
  55. package/dist/v2/index45.js +1 -24
  56. package/dist/v2/index46.js +3 -3
  57. package/dist/v2/index47.js +2 -1
  58. package/dist/v2/index48.js +9 -2
  59. package/dist/v2/index49.js +17 -10
  60. package/dist/v2/index50.js +13 -17
  61. package/dist/v2/index51.js +14 -13
  62. package/dist/v2/index52.js +13 -14
  63. package/dist/v2/index53.js +15 -12
  64. package/dist/v2/index54.js +1 -16
  65. package/dist/v2/index55.js +6 -2
  66. package/dist/v2/index56.js +5 -1
  67. package/dist/v2/index57.js +3 -10
  68. package/dist/v2/index58.js +4 -2
  69. package/dist/v2/index59.js +3 -5
  70. package/dist/v2/index60.js +1 -2
  71. package/dist/v2/index61.js +5 -2
  72. package/dist/v2/index62.js +18 -3
  73. package/dist/v2/index63.js +2 -19
  74. package/dist/v2/index65.js +2 -2
  75. package/dist/v2/index71.js +15 -4
  76. package/dist/v2/index72.js +2 -13
  77. package/dist/v2/index73.js +6 -4
  78. package/dist/v2/index74.js +4 -6
  79. package/dist/v2/index75.js +1 -2
  80. package/dist/v2/index76.js +3 -3
  81. package/dist/v2/index77.js +4 -3
  82. package/dist/v2/index78.js +15 -4
  83. package/dist/v2/index79.js +11 -14
  84. package/dist/v2/index80.js +13 -11
  85. package/dist/v2/index81.js +2 -14
  86. package/dist/v2/index82.js +2 -2
  87. package/dist/v2/index83.js +3 -2
  88. package/dist/v2/index84.js +6 -1
  89. package/dist/v2/index85.js +20 -7
  90. package/dist/v2/index86.js +9 -12
  91. package/dist/v2/index87.js +1 -18
  92. package/dist/v2/index88.js +18 -2
  93. package/dist/v2/index89.js +2 -18
  94. package/dist/v2/index90.js +10 -2
  95. package/dist/v2/index91.js +11 -9
  96. package/dist/v2/index92.js +1 -12
  97. package/dist/v2/index93.js +6 -1
  98. package/dist/v2/index94.js +1 -5
  99. package/dist/v3/{OrConfirm-0bafcc7b.js → OrConfirm-371630a4.js} +1 -1
  100. package/dist/v3/{OrInlineInput-dc71bbcb.js → OrInlineInput-bac4abdd.js} +6 -7
  101. package/dist/v3/{OrInlineTextarea-bdebb784.js → OrInlineTextarea-d1ec1bba.js} +6 -7
  102. package/dist/v3/{OrInput-db4813b4.js → OrInput-256d2530.js} +3 -5
  103. package/dist/v3/{OrSearch-0c29f499.js → OrSearch-375eab55.js} +1 -1
  104. package/dist/v3/OrSegmentedControl-2bbc0f22.js +184 -0
  105. package/dist/v3/{OrSelect-323a87b4.js → OrSelect-52cfb10d.js} +4 -6
  106. package/dist/v3/{OrTabs-194ca950.js → OrTabs-ac0be933.js} +1 -1
  107. package/dist/v3/{OrTextarea-98895b2a.js → OrTextarea-09aa33dc.js} +4 -6
  108. package/dist/v3/components/index.d.ts +1 -2
  109. package/dist/v3/components/{or-sort-header-v3/OrSortHeader.stories3.d.ts → or-segmented-control-v3/OrSegmentedControl.stories3.d.ts} +1 -1
  110. package/dist/{v2/components/or-sort-header-v3/OrSortHeader.vue.d.ts → v3/components/or-segmented-control-v3/OrSegmentedControl.vue.d.ts} +45 -25
  111. package/dist/v3/components/or-segmented-control-v3/components/or-segmented-control-item/OrSegmentedControlItem.vue.d.ts +47 -0
  112. package/dist/v3/components/or-segmented-control-v3/components/or-segmented-control-item/styles.d.ts +3 -0
  113. package/dist/v3/components/or-segmented-control-v3/index.d.ts +3 -0
  114. package/dist/v3/components/or-segmented-control-v3/props.d.ts +4 -0
  115. package/dist/v3/components/or-segmented-control-v3/styles.d.ts +3 -0
  116. package/dist/v3/components/or-segmented-control-v3/types.d.ts +4 -0
  117. package/dist/v3/index.js +9 -10
  118. package/dist/v3/index11.js +1 -19
  119. package/dist/v3/index12.js +11 -3
  120. package/dist/v3/index13.js +2 -3
  121. package/dist/v3/index14.js +4 -9
  122. package/dist/v3/index15.js +11 -4
  123. package/dist/v3/index16.js +17 -3
  124. package/dist/v3/index17.js +4 -25
  125. package/dist/v3/index18.js +6 -3
  126. package/dist/v3/index19.js +20 -5
  127. package/dist/v3/index2.js +9 -10
  128. package/dist/v3/index20.js +20 -21
  129. package/dist/v3/index21.js +15 -20
  130. package/dist/v3/index22.js +1 -16
  131. package/dist/v3/index23.js +4 -2
  132. package/dist/v3/index24.js +1 -2
  133. package/dist/v3/index25.js +2 -1
  134. package/dist/v3/index26.js +2 -2
  135. package/dist/v3/index27.js +6 -4
  136. package/dist/v3/index28.js +2 -5
  137. package/dist/v3/index29.js +3 -3
  138. package/dist/v3/index30.js +9 -3
  139. package/dist/v3/index31.js +11 -8
  140. package/dist/v3/index32.js +1 -10
  141. package/dist/v3/index33.js +1 -1
  142. package/dist/v3/index34.js +15 -1
  143. package/dist/v3/index35.js +14 -16
  144. package/dist/v3/index36.js +16 -14
  145. package/dist/v3/index37.js +2 -16
  146. package/dist/v3/index38.js +17 -2
  147. package/dist/v3/index39.js +17 -17
  148. package/dist/v3/index40.js +1 -16
  149. package/dist/v3/index41.js +3 -3
  150. package/dist/v3/index42.js +1 -1
  151. package/dist/v3/index43.js +16 -3
  152. package/dist/v3/index44.js +7 -1
  153. package/dist/v3/index45.js +1 -20
  154. package/dist/v3/index46.js +3 -3
  155. package/dist/v3/index47.js +2 -1
  156. package/dist/v3/index48.js +8 -2
  157. package/dist/v3/index49.js +14 -9
  158. package/dist/v3/index50.js +12 -14
  159. package/dist/v3/index51.js +11 -12
  160. package/dist/v3/index52.js +12 -11
  161. package/dist/v3/index53.js +11 -11
  162. package/dist/v3/index54.js +1 -12
  163. package/dist/v3/index55.js +5 -2
  164. package/dist/v3/index56.js +5 -1
  165. package/dist/v3/index57.js +3 -9
  166. package/dist/v3/index58.js +4 -2
  167. package/dist/v3/index59.js +3 -5
  168. package/dist/v3/index60.js +1 -2
  169. package/dist/v3/index61.js +4 -1
  170. package/dist/v3/index62.js +17 -3
  171. package/dist/v3/index63.js +2 -18
  172. package/dist/v3/index65.js +2 -2
  173. package/dist/v3/index71.js +12 -4
  174. package/dist/v3/index72.js +2 -10
  175. package/dist/v3/index73.js +5 -3
  176. package/dist/v3/index74.js +3 -5
  177. package/dist/v3/index75.js +1 -2
  178. package/dist/v3/index76.js +3 -3
  179. package/dist/v3/index77.js +4 -3
  180. package/dist/v3/index78.js +14 -4
  181. package/dist/v3/index79.js +10 -13
  182. package/dist/v3/index80.js +12 -10
  183. package/dist/v3/index81.js +1 -13
  184. package/dist/v3/index82.js +1 -1
  185. package/dist/v3/index83.js +3 -1
  186. package/dist/v3/index84.js +6 -1
  187. package/dist/v3/index85.js +16 -6
  188. package/dist/v3/index86.js +9 -12
  189. package/dist/v3/index87.js +1 -15
  190. package/dist/v3/index88.js +17 -2
  191. package/dist/v3/index89.js +2 -17
  192. package/dist/v3/index90.js +8 -2
  193. package/dist/v3/index91.js +9 -6
  194. package/dist/v3/index92.js +1 -11
  195. package/dist/v3/index93.js +6 -1
  196. package/dist/v3/index94.js +1 -5
  197. package/package.json +1 -1
  198. package/src/components/index.ts +1 -2
  199. package/src/components/or-checkbox-v3/OrCheckbox.stories3.ts +1 -1
  200. package/src/components/or-inline-input-v3/OrInlineInput.vue +12 -14
  201. package/src/components/or-inline-textarea-v3/OrInlineTextarea.vue +12 -14
  202. package/src/components/or-input-v3/OrInput.vue +10 -12
  203. package/src/components/or-radio-v3/OrRadio.stories3.ts +1 -1
  204. package/src/components/or-segmented-control-v3/OrSegmentedControl.docs.mdx +7 -0
  205. package/src/components/or-segmented-control-v3/OrSegmentedControl.stories3.ts +106 -0
  206. package/src/components/{or-sort-header-v3/OrSortHeader.vue → or-segmented-control-v3/OrSegmentedControl.vue} +34 -38
  207. package/src/components/or-segmented-control-v3/components/or-segmented-control-item/OrSegmentedControlItem.vue +64 -0
  208. package/src/components/or-segmented-control-v3/components/or-segmented-control-item/styles.ts +50 -0
  209. package/src/components/or-segmented-control-v3/index.ts +3 -0
  210. package/src/components/or-segmented-control-v3/props.ts +4 -0
  211. package/src/components/or-segmented-control-v3/styles.ts +24 -0
  212. package/src/components/or-segmented-control-v3/types.ts +4 -0
  213. package/src/components/or-select-v3/OrSelect.vue +3 -5
  214. package/src/components/or-switch-v3/OrSwitch.stories3.ts +1 -1
  215. package/src/components/or-tabs-v3/OrTabs.stories3.ts +9 -4
  216. package/src/components/or-tabs-v3/OrTabs.vue +1 -1
  217. package/src/components/or-textarea-v3/OrTextarea.vue +10 -12
  218. package/src/hooks/useClassAttribute.ts +1 -1
  219. package/dist/v2/OrCardCollection-5d5046f1.js +0 -227
  220. package/dist/v2/OrSortHeader-a6004b24.js +0 -133
  221. package/dist/v2/components/or-card-collection-v3/OrCardCollection.stories3.d.ts +0 -17
  222. package/dist/v2/components/or-card-collection-v3/OrCardCollection.vue.d.ts +0 -98
  223. package/dist/v2/components/or-card-collection-v3/index.d.ts +0 -3
  224. package/dist/v2/components/or-card-collection-v3/props.d.ts +0 -4
  225. package/dist/v2/components/or-card-collection-v3/styles.d.ts +0 -6
  226. package/dist/v2/components/or-card-collection-v3/types.d.ts +0 -7
  227. package/dist/v2/components/or-sort-header-v3/index.d.ts +0 -2
  228. package/dist/v2/components/or-sort-header-v3/styles.d.ts +0 -1
  229. package/dist/v2/components/or-sort-header-v3/types.d.ts +0 -4
  230. package/dist/v2/index95.js +0 -3
  231. package/dist/v3/OrCardCollection-c6f3ac23.js +0 -198
  232. package/dist/v3/OrSortHeader-5eba50cd.js +0 -104
  233. package/dist/v3/components/or-card-collection-v3/OrCardCollection.stories3.d.ts +0 -17
  234. package/dist/v3/components/or-card-collection-v3/OrCardCollection.vue.d.ts +0 -98
  235. package/dist/v3/components/or-card-collection-v3/index.d.ts +0 -3
  236. package/dist/v3/components/or-card-collection-v3/props.d.ts +0 -4
  237. package/dist/v3/components/or-card-collection-v3/styles.d.ts +0 -6
  238. package/dist/v3/components/or-card-collection-v3/types.d.ts +0 -7
  239. package/dist/v3/components/or-sort-header-v3/index.d.ts +0 -2
  240. package/dist/v3/components/or-sort-header-v3/styles.d.ts +0 -1
  241. package/dist/v3/components/or-sort-header-v3/types.d.ts +0 -4
  242. package/dist/v3/index95.js +0 -3
  243. package/src/components/or-card-collection-v3/OrCardCollection.docs.mdx +0 -3
  244. package/src/components/or-card-collection-v3/OrCardCollection.stories3.ts +0 -162
  245. package/src/components/or-card-collection-v3/OrCardCollection.vue +0 -210
  246. package/src/components/or-card-collection-v3/index.ts +0 -3
  247. package/src/components/or-card-collection-v3/props.ts +0 -4
  248. package/src/components/or-card-collection-v3/styles.ts +0 -53
  249. package/src/components/or-card-collection-v3/types.ts +0 -8
  250. package/src/components/or-sort-header-v3/OrSortHeader.docs.mdx +0 -3
  251. package/src/components/or-sort-header-v3/OrSortHeader.stories3.ts +0 -132
  252. package/src/components/or-sort-header-v3/index.ts +0 -2
  253. package/src/components/or-sort-header-v3/styles.ts +0 -23
  254. package/src/components/or-sort-header-v3/types.ts +0 -4
@@ -0,0 +1,106 @@
1
+ import { action } from '@storybook/addon-actions';
2
+ import { Meta, StoryFn } from '@storybook/vue3';
3
+ import { ref, watch } from 'vue-demi';
4
+ import OrSegmentedControlDocs from './OrSegmentedControl.docs.mdx';
5
+ import OrSegmentedControl from './OrSegmentedControl.vue';
6
+ import { SegmentedControlSize } from './props';
7
+ import { SegmentedControlOption } from './types';
8
+
9
+ export default {
10
+ title: 'Components/Forms/Segmented Control',
11
+ component: OrSegmentedControl,
12
+
13
+ argTypes: {
14
+ // Props
15
+ options: {
16
+ control: { type: 'object' },
17
+ },
18
+
19
+ modelValue: {
20
+ control: { type: 'text' },
21
+ },
22
+
23
+ value: { // TODO: Remove Vue 2 fallback
24
+ table: { disable: true },
25
+ },
26
+
27
+ size: {
28
+ control: { type: 'select' },
29
+ options: Object.values(SegmentedControlSize),
30
+ },
31
+
32
+ disabled: {
33
+ control: { type: 'boolean' },
34
+ },
35
+
36
+ // Events
37
+ 'update:modelValue': {
38
+ table: { disable: true },
39
+ },
40
+
41
+ input: {
42
+ table: { disable: true },
43
+ },
44
+ },
45
+
46
+ parameters: {
47
+ layout: 'centered',
48
+
49
+ docs: {
50
+ page: OrSegmentedControlDocs,
51
+ },
52
+
53
+ design: {
54
+ type: 'figma',
55
+ url: 'https://www.figma.com/file/o7DdkaznUW2PtX4wiSuhhQ/Core?node-id=410%3A2097&t=7N93DAotOYMOX2kx-1',
56
+ },
57
+ },
58
+ } as Meta<typeof OrSegmentedControl>;
59
+
60
+ const Template: StoryFn<typeof OrSegmentedControl> = (args) => ({
61
+ components: {
62
+ OrSegmentedControl,
63
+ },
64
+
65
+ setup() {
66
+ // State
67
+ const model = ref<string>();
68
+
69
+ // Effects
70
+ watch(model, (value) => {
71
+ console.debug(value);
72
+ });
73
+
74
+ return {
75
+ args,
76
+ model,
77
+ onUpdateModelValue: action('update:modelValue'),
78
+ onInput: action('input'),
79
+ };
80
+ },
81
+
82
+ template: `
83
+ <OrSegmentedControl
84
+ v-model="model"
85
+ v-bind="args"
86
+ @update:modelValue="onUpdateModelValue"
87
+ @input="onInput"
88
+ />
89
+ `,
90
+ });
91
+
92
+ export const Base = Template.bind({});
93
+
94
+ Base.args = {
95
+ // Props
96
+ options: Array.from<string, SegmentedControlOption>([
97
+ 'Alfa',
98
+ 'Bravo',
99
+ 'Charlie',
100
+ 'Delta',
101
+ 'Echo',
102
+ ], (item) => ({
103
+ value: item.toLowerCase(),
104
+ label: item,
105
+ })),
106
+ };
@@ -3,50 +3,61 @@
3
3
  ref="root"
4
4
  v-bind="$attrs"
5
5
  :class="rootStyles"
6
- :activated="activated ? '' : null"
7
- @click.stop="toggleDirection()"
8
6
  >
9
- <slot />
10
-
11
- <template v-if="activated">
12
- <OrIcon
13
- :class="{ 'rotate-180': proxyModelValue.direction === 'asc' }"
14
- :icon="'arrow_downward'"
15
- />
16
- </template>
7
+ <OrSegmentedControlItem
8
+ v-for="option in options"
9
+ :key="option.value"
10
+ :size="size"
11
+ :selected="option.value === proxyModelValue"
12
+ :disabled="disabled"
13
+ @click.stop="proxyModelValue = option.value"
14
+ >
15
+ {{ option.label }}
16
+ </OrSegmentedControlItem>
17
17
  </div>
18
18
  </template>
19
19
 
20
20
  <script lang="ts">
21
21
  import { computed, defineComponent, PropType, ref } from 'vue-demi';
22
22
  import { useClassAttribute } from '../../hooks';
23
- import { OrIconV3 as OrIcon } from '../or-icon-v3';
24
- import { SortHeaderRoot } from './styles';
25
- import { SortHeaderModel } from './types';
23
+ import OrSegmentedControlItem from './components/or-segmented-control-item/OrSegmentedControlItem.vue';
24
+ import { SegmentedControlSize } from './props';
25
+ import { SegmentedControlRoot, SegmentedControlRootSizes } from './styles';
26
+ import { SegmentedControlOption } from './types';
26
27
 
27
28
  export default defineComponent({
28
- name: 'OrSortHeader',
29
+ name: 'OrSegmentedControl',
29
30
 
30
31
  components: {
31
- OrIcon,
32
+ OrSegmentedControlItem,
32
33
  },
33
34
 
34
35
  inheritAttrs: false,
35
36
 
36
37
  props: {
38
+ options: {
39
+ type: Array as PropType<SegmentedControlOption[]>,
40
+ default: [] as SegmentedControlOption[],
41
+ },
42
+
37
43
  modelValue: {
38
- type: Object as PropType<SortHeaderModel>,
44
+ type: String,
39
45
  default: undefined,
40
46
  },
41
47
 
42
48
  value: { // TODO: Remove Vue 2 fallback
43
- type: Object as PropType<SortHeaderModel>,
49
+ type: String,
44
50
  default: undefined,
45
51
  },
46
52
 
47
- inputValue: { // TODO: Rename to `value` after complete migration to Vue 3
48
- type: String,
49
- required: true,
53
+ size: {
54
+ type: String as PropType<SegmentedControlSize>,
55
+ default: SegmentedControlSize.M,
56
+ },
57
+
58
+ disabled: {
59
+ type: Boolean,
60
+ default: false,
50
61
  },
51
62
  },
52
63
 
@@ -54,8 +65,6 @@ export default defineComponent({
54
65
  'update:modelValue',
55
66
 
56
67
  'input',
57
- 'focus',
58
- 'blur',
59
68
  ],
60
69
 
61
70
  expose: [
@@ -70,8 +79,9 @@ export default defineComponent({
70
79
  const classAttribute = useClassAttribute();
71
80
 
72
81
  const rootStyles = computed(() => [
73
- 'or-sort-header',
74
- ...SortHeaderRoot,
82
+ 'or-segmented-control',
83
+ ...SegmentedControlRoot,
84
+ ...SegmentedControlRootSizes[props.size],
75
85
  classAttribute.value,
76
86
  ]);
77
87
 
@@ -87,24 +97,10 @@ export default defineComponent({
87
97
  },
88
98
  });
89
99
 
90
- const activated = computed(() => {
91
- return proxyModelValue.value?.column === props.inputValue;
92
- });
93
-
94
- // Methods
95
- function toggleDirection(): void {
96
- proxyModelValue.value = {
97
- column: props.inputValue,
98
- direction: proxyModelValue.value?.direction === 'asc' ? 'desc' : 'asc',
99
- };
100
- }
101
-
102
100
  return {
103
101
  root,
104
102
  rootStyles,
105
103
  proxyModelValue,
106
- activated,
107
- toggleDirection,
108
104
  };
109
105
  },
110
106
  });
@@ -0,0 +1,64 @@
1
+ <template>
2
+ <div
3
+ ref="root"
4
+ v-bind="$attrs"
5
+ :class="rootStyles"
6
+ :selected="selected ? '' : null"
7
+ :disabled="disabled ? '' : null"
8
+ @click="$emit('click', $event)"
9
+ >
10
+ <div :class="['truncate']">
11
+ <slot />
12
+ </div>
13
+ </div>
14
+ </template>
15
+
16
+ <script lang="ts">
17
+ import { computed, defineComponent, PropType, ref } from 'vue-demi';
18
+ import { useClassAttribute } from '../../../../hooks';
19
+ import { SegmentedControlSize } from '../../props';
20
+ import { SegmentedControlItemRoot, SegmentedControlItemRootSizes } from './styles';
21
+
22
+ export default defineComponent({
23
+ name: 'OrSegmentedControlItem',
24
+
25
+ inheritAttrs: false,
26
+
27
+ props: {
28
+ size: {
29
+ type: String as PropType<SegmentedControlSize>,
30
+ required: true,
31
+ },
32
+
33
+ selected: {
34
+ type: Boolean,
35
+ default: false,
36
+ },
37
+
38
+ disabled: {
39
+ type: Boolean,
40
+ default: false,
41
+ },
42
+ },
43
+
44
+ setup(props) {
45
+ // Refs
46
+ const root = ref<HTMLElement>();
47
+
48
+ // Styles
49
+ const classAttribute = useClassAttribute();
50
+
51
+ const rootStyles = computed(() => [
52
+ 'or-segmented-control-item',
53
+ ...SegmentedControlItemRoot,
54
+ ...SegmentedControlItemRootSizes[props.size],
55
+ classAttribute.value,
56
+ ]);
57
+
58
+ return {
59
+ root,
60
+ rootStyles,
61
+ };
62
+ },
63
+ });
64
+ </script>
@@ -0,0 +1,50 @@
1
+ import { SegmentedControlSize } from '../../props';
2
+
3
+ export const SegmentedControlItemRoot: string[] = [
4
+ // Layout
5
+ 'flex',
6
+ 'items-center',
7
+ 'justify-center',
8
+
9
+ // Shape
10
+ 'rounded-md',
11
+
12
+ // Interactivity
13
+ 'interactivity-auto',
14
+
15
+ // Theme
16
+ 'theme-foreground-default',
17
+ 'dark:theme-foreground-default-dark',
18
+
19
+ // Theme (selected)
20
+ 'selected:theme-background-default',
21
+ 'dark:selected:theme-background-default-dark',
22
+
23
+ // Theme (selected, enabled)
24
+ 'selected:enabled:shadow-card',
25
+ 'dark:selected:enabled:shadow-card-dark',
26
+ ];
27
+
28
+ export const SegmentedControlItemRootSizes: Record<SegmentedControlSize, string[]> = {
29
+ 'm': [
30
+ // Box
31
+ 'h-[44px] md:h-[36px]',
32
+
33
+ // Spacing
34
+ 'px-sm+ md:px-sm+',
35
+
36
+ // Typography
37
+ 'typography-body-2-regular',
38
+ ],
39
+
40
+ 's': [
41
+ // Box
42
+ 'h-[36px] md:h-[32px]',
43
+
44
+ // Spacing
45
+ 'px-sm+ md:px-sm',
46
+
47
+ // Typography
48
+ 'typography-caption-regular',
49
+ ],
50
+ };
@@ -0,0 +1,3 @@
1
+ export { default as OrSegmentedControlV3 } from './OrSegmentedControl.vue';
2
+ export * from './props';
3
+ export * from './types';
@@ -0,0 +1,4 @@
1
+ export enum SegmentedControlSize {
2
+ M = 'm',
3
+ S = 's',
4
+ }
@@ -0,0 +1,24 @@
1
+ import { SegmentedControlSize } from './props';
2
+
3
+ export const SegmentedControlRoot: string[] = [
4
+ // Layout
5
+ 'grid',
6
+ 'grid-flow-col',
7
+ 'auto-cols-fr',
8
+
9
+ // Shape
10
+ 'rounded-md',
11
+
12
+ // Spacing
13
+ 'px-[2px]',
14
+ 'py-[2px]',
15
+
16
+ // Theme
17
+ 'theme-background-surface-variant',
18
+ 'dark:theme-background-surface-variant-dark',
19
+ ];
20
+
21
+ export const SegmentedControlRootSizes: Record<SegmentedControlSize, string[]> = {
22
+ 'm': [],
23
+ 's': [],
24
+ };
@@ -0,0 +1,4 @@
1
+ export interface SegmentedControlOption {
2
+ value: string;
3
+ label: string;
4
+ }
@@ -193,11 +193,9 @@
193
193
  </OrInputBox>
194
194
 
195
195
  <template v-if="!invalid">
196
- <template v-if="hint">
197
- <OrHint :disabled="disabled">
198
- {{ hint }}
199
- </OrHint>
200
- </template>
196
+ <OrHint :disabled="disabled">
197
+ {{ hint }}
198
+ </OrHint>
201
199
  </template>
202
200
 
203
201
  <template v-else>
@@ -27,7 +27,7 @@ export default {
27
27
  },
28
28
 
29
29
  value: { // TODO: Remove Vue 2 fallback
30
- control: { type: 'object' },
30
+ table: { disable: true },
31
31
  },
32
32
 
33
33
  inputValue: { // TODO: Rename to `value` after complete migration to Vue 3
@@ -1,6 +1,6 @@
1
1
  import { action } from '@storybook/addon-actions';
2
2
  import { Meta, StoryFn } from '@storybook/vue3';
3
- import { ref } from 'vue-demi';
3
+ import { ref, watch } from 'vue-demi';
4
4
  import OrTabsDocs from './OrTabs.docs.mdx';
5
5
  import OrTabs from './OrTabs.vue';
6
6
  import { TabsVariant } from './props';
@@ -63,11 +63,16 @@ const Template: StoryFn<typeof OrTabs> = (args) => ({
63
63
 
64
64
  setup() {
65
65
  // State
66
- const value = ref<string>();
66
+ const model = ref<string>();
67
+
68
+ // Effects
69
+ watch(model, (value) => {
70
+ console.debug(value);
71
+ });
67
72
 
68
73
  return {
69
74
  args,
70
- value,
75
+ model,
71
76
  onUpdateModelValue: action('update:modelValue'),
72
77
  onInput: action('input'),
73
78
  };
@@ -75,7 +80,7 @@ const Template: StoryFn<typeof OrTabs> = (args) => ({
75
80
 
76
81
  template: `
77
82
  <OrTabs
78
- v-model="value"
83
+ v-model="model"
79
84
  v-bind="args"
80
85
  @update:modelValue="onUpdateModelValue"
81
86
  @input="onInput"
@@ -8,7 +8,7 @@
8
8
  <OrTab
9
9
  v-for="tab in tabs.normal"
10
10
  :key="tab.value"
11
- :selected="proxyModelValue === tab.value"
11
+ :selected="tab.value === proxyModelValue"
12
12
  @click.stop="proxyModelValue = tab.value"
13
13
  >
14
14
  {{ tab.label }}
@@ -40,18 +40,16 @@
40
40
  </OrInputBox>
41
41
 
42
42
  <template v-if="!invalid">
43
- <template v-if="hint || maxLength">
44
- <OrHint :disabled="disabled">
45
- {{ hint }}
46
-
47
- <template
48
- v-if="maxLength"
49
- v-slot:addon
50
- >
51
- {{ currentLength }} / {{ maxLength }}
52
- </template>
53
- </OrHint>
54
- </template>
43
+ <OrHint :disabled="disabled">
44
+ {{ hint }}
45
+
46
+ <template
47
+ v-if="maxLength"
48
+ v-slot:addon
49
+ >
50
+ {{ currentLength }} / {{ maxLength }}
51
+ </template>
52
+ </OrHint>
55
53
  </template>
56
54
 
57
55
  <template v-else>
@@ -8,7 +8,7 @@ export function useClassAttribute(): UseClassAttributeReturn {
8
8
 
9
9
  // Functions
10
10
  function composeClass(): UnwrapRef<UseClassAttributeReturn> {
11
- const { staticClass = '', class: classProperty } = (currentInstance?.vnode as VNode).data ?? {};
11
+ const { staticClass = '', class: classProperty } = (currentInstance?.vnode as unknown as VNode).data ?? {};
12
12
 
13
13
  if (!classProperty) {
14
14
  return staticClass || undefined;