vueless 0.0.151 → 0.0.153

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.151",
3
+ "version": "0.0.153",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -28,17 +28,17 @@
28
28
  "cva": "^1.0.0-beta.1",
29
29
  "lodash-es": "^4.17.21",
30
30
  "tailwind-merge": "^2.3.0",
31
- "tailwindcss": "^3.4.3",
31
+ "tailwindcss": "^3.4.4",
32
32
  "tippy.js": "^6.3.7",
33
33
  "vuedraggable": "^4.1.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@material-symbols/svg-500": "^0.17.4",
37
37
  "@release-it/bumper": "^6.0.1",
38
- "@vitejs/plugin-vue": "^5.0.4",
38
+ "@vitejs/plugin-vue": "^5.0.5",
39
39
  "@vue/eslint-config-prettier": "^9.0.0",
40
- "@vueless/plugin-vite": "^0.0.27",
41
- "@vueless/storybook": "^0.0.27",
40
+ "@vueless/plugin-vite": "^0.0.28",
41
+ "@vueless/storybook": "^0.0.30",
42
42
  "@vueless/web-types": "^0.0.8",
43
43
  "autoprefixer": "^10.4.19",
44
44
  "cssnano": "^6.1.2",
@@ -52,10 +52,10 @@
52
52
  "prettier": "^3.2.5",
53
53
  "prettier-eslint": "^16.3.0",
54
54
  "release-it": "^17.2.1",
55
- "vite": "^5.2.10",
55
+ "vite": "^5.2.13",
56
56
  "vite-plugin-compression": "^0.5.1",
57
57
  "vite-plugin-eslint": "^1.8.1",
58
- "vue": "^3.4.25",
58
+ "vue": "^3.4.27",
59
59
  "vue-router": "^4.3.2"
60
60
  },
61
61
  "resolutions": {
@@ -67,6 +67,5 @@
67
67
  },
68
68
  "bugs": {
69
69
  "url": "https://github.com/vuelessjs/vueless/issues"
70
- },
71
- "web-types": "./web-types.json"
70
+ }
72
71
  }
@@ -25,7 +25,7 @@ export function vuelessPreset() {
25
25
  const prodSafelist = getSafelist();
26
26
  const devSafelist = [
27
27
  {
28
- pattern: /(border|bg|text|ring)-(.*)-((50|[1-9]00|950)?)$/,
28
+ pattern: /^!?(border|bg|text|ring)-(.*)-((50|[1-9]00|950)?)$/,
29
29
  variants: ["hover", "focus", "focus-within", "active", "disabled"],
30
30
  },
31
31
  ];
@@ -3,7 +3,7 @@ export default /*tw*/ {
3
3
  base: `
4
4
  flex items-center justify-center
5
5
  text-base font-medium outline-none
6
- border border-solid rounded-lg
6
+ border border-solid
7
7
  transition duration-100 ease-in-out
8
8
  focus:ring-opacity-20 focus:ring-4 focus:ring-{color}-700
9
9
  focus-within:ring-opacity-20 focus-within:ring-4 focus-within:ring-{color}-700
@@ -47,6 +47,7 @@ export default /*tw*/ {
47
47
  true: "pointer-events-none gap-0",
48
48
  },
49
49
  pill: {
50
+ false: "rounded-lg",
50
51
  true: "rounded-full",
51
52
  },
52
53
  block: {
@@ -23,6 +23,8 @@ export function useAttrs(props) {
23
23
  const itemsClasses = computed(() =>
24
24
  cvaItems({
25
25
  size: props.size,
26
+ variant: props.variant,
27
+ multiple: props.multiple,
26
28
  separated: props.separated,
27
29
  }),
28
30
  );
@@ -1,12 +1,4 @@
1
1
  export default /*tw*/ {
2
- label: {
3
- base: "flex flex-wrap",
4
- variants: {
5
- block: {
6
- true: "w-full",
7
- },
8
- },
9
- },
10
2
  items: {
11
3
  base: "flex flex-wrap",
12
4
  variants: {
@@ -20,23 +12,33 @@ export default /*tw*/ {
20
12
  },
21
13
  separated: {
22
14
  false: `
23
- gap-px flex-nowrap
15
+ flex-nowrap -space-x-px gap-0
24
16
  [&>*:first-child]:rounded-l-lg [&>*:first-child]:rounded-r-none
25
17
  [&>*:last-child]:rounded-r-lg [&>*:last-child]:rounded-l-none
26
18
  `,
27
19
  },
28
20
  },
21
+ compoundVariants: [
22
+ { separated: false, variant: "thirdary", class: "space-x-0" },
23
+ { separated: false, multiple: true, class: "space-x-px" },
24
+ ],
25
+ },
26
+ label: {
27
+ base: "flex flex-wrap",
28
+ variants: {
29
+ block: {
30
+ true: "w-full",
31
+ },
32
+ },
29
33
  },
30
34
  item: "",
31
35
  defaultVariants: {
32
- color: "brand",
33
36
  variant: "primary",
34
37
  labelAlign: "top",
35
38
  size: "md",
36
39
  block: false,
37
40
  pill: false,
38
41
  square: false,
39
- filled: false,
40
42
  disabled: false,
41
43
  multiple: false,
42
44
  separated: false,
@@ -1,14 +1,23 @@
1
- import { getArgTypes, getSlotNames } from "../service.storybook";
1
+ import { ref } from "vue";
2
+ import { getArgTypes } from "../service.storybook";
2
3
 
3
4
  import UToggle from "../ui.button-toggle";
4
5
  import UIcon from "../ui.image-icon";
5
6
  import UToggleItem from "../ui.button-toggle-item";
6
7
  import URow from "../ui.container-row";
7
8
 
9
+ const OPTIONS = [
10
+ { value: "11", label: "label 1" },
11
+ { value: "12", label: "label 2" },
12
+ { value: "13", label: "label 3" },
13
+ { value: "14", label: "label 4" },
14
+ ];
15
+
8
16
  /**
9
17
  * The `UToggle` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.button-toggle)
10
18
  */
11
19
  export default {
20
+ components: { UIcon, UToggleItem },
12
21
  title: "Buttons & Links / Toggle",
13
22
  component: UToggle,
14
23
  argTypes: {
@@ -25,26 +34,18 @@ const DefaultTemplate = (args) => ({
25
34
  };
26
35
  },
27
36
  setup() {
28
- const groupOptions = [
29
- { value: "11", label: "label 1" },
30
- { value: "12", label: "label 2" },
31
- { value: "13", label: "label 3" },
32
- { value: "14", label: "label 4" },
33
- ];
34
-
35
- return { args, groupOptions };
37
+ return { args, OPTIONS };
36
38
  },
37
39
  template: `
38
40
  <UToggle
39
41
  v-model="value"
40
42
  v-bind="args"
41
- :options="groupOptions"
42
- name="defaultTemplate"
43
+ :options="OPTIONS"
43
44
  />
44
45
  `,
45
46
  });
46
47
 
47
- const checkboxTemplate = (args) => ({
48
+ const multipleTemplate = (args) => ({
48
49
  components: { UToggle },
49
50
  data() {
50
51
  return {
@@ -52,39 +53,27 @@ const checkboxTemplate = (args) => ({
52
53
  };
53
54
  },
54
55
  setup() {
55
- const groupOptions = [
56
- { value: "11", label: "label 1" },
57
- { value: "12", label: "label 2" },
58
- { value: "13", label: "label 3" },
59
- { value: "14", label: "label 4" },
60
- ];
61
-
62
- return { args, groupOptions };
56
+ return { args, OPTIONS };
63
57
  },
64
58
  template: `
65
59
  <UToggle
66
60
  v-model="value"
67
61
  v-bind="args"
68
62
  multiple
69
- :options="groupOptions"
70
- name="defaultTemplate"
63
+ :options="OPTIONS"
64
+ name="multipleTemplate"
71
65
  />
72
66
  `,
73
67
  });
74
68
 
75
69
  const SizesTemplate = (args, { argTypes } = {}) => ({
76
70
  components: { UToggle, URow },
77
- data() {
78
- return {
79
- value: "",
80
- };
81
- },
82
71
  setup() {
83
- const slots = getSlotNames(UToggle.name);
72
+ const value = ref("");
84
73
 
85
74
  return {
86
75
  args,
87
- slots,
76
+ value,
88
77
  sizes: argTypes.size.options,
89
78
  };
90
79
  },
@@ -92,6 +81,9 @@ const SizesTemplate = (args, { argTypes } = {}) => ({
92
81
  <URow>
93
82
  <UToggle
94
83
  v-for="(size, index) in sizes"
84
+ :key="index"
85
+ name="sizeTemplate"
86
+ v-model="value"
95
87
  v-bind="args"
96
88
  :size="size"
97
89
  :label="size"
@@ -99,14 +91,37 @@ const SizesTemplate = (args, { argTypes } = {}) => ({
99
91
  { value: size + 1, label: size },
100
92
  { value: size + 2, label: size },
101
93
  ]"
102
- v-model="value"
94
+ />
95
+ </URow>
96
+ `,
97
+ });
98
+
99
+ const VariantsTemplate = (args, { argTypes } = {}) => ({
100
+ components: { UToggle, URow },
101
+ setup() {
102
+ const value = ref("");
103
+
104
+ return {
105
+ args,
106
+ value,
107
+ variants: argTypes.variant.options,
108
+ };
109
+ },
110
+ template: `
111
+ <URow>
112
+ <UToggle
113
+ v-for="(variant, index) in variants"
103
114
  :key="index"
104
115
  name="sizeTemplate"
105
- >
106
- <template v-for="(slot, index) of slots" :key="index" v-slot:[slot]>
107
- <template v-if="args[slot]">{{ args[slot] }}</template>
108
- </template>
109
- </UToggle>
116
+ v-model="value"
117
+ v-bind="args"
118
+ :variant="variant"
119
+ :label="variant"
120
+ :options="[
121
+ { value: variant + 1, label: variant },
122
+ { value: variant + 2, label: variant },
123
+ ]"
124
+ />
110
125
  </URow>
111
126
  `,
112
127
  });
@@ -114,9 +129,11 @@ const SizesTemplate = (args, { argTypes } = {}) => ({
114
129
  const SlotTemplate = (args) => ({
115
130
  components: { UToggle, UIcon, UToggleItem },
116
131
  setup() {
132
+ const selected = ref("");
133
+
117
134
  return {
118
135
  args,
119
- selected: "55",
136
+ selected,
120
137
  };
121
138
  },
122
139
  template: `
@@ -128,31 +145,79 @@ const SlotTemplate = (args) => ({
128
145
 
129
146
  export const Default = DefaultTemplate.bind({});
130
147
  Default.args = {
131
- name: "first name",
148
+ name: "Default",
132
149
  };
133
150
 
134
- export const multiple = checkboxTemplate.bind({});
135
- multiple.args = {
136
- name: "second name",
151
+ export const label = DefaultTemplate.bind({});
152
+ label.args = {
153
+ label: "Label",
154
+ description: "description",
137
155
  };
138
156
 
139
157
  export const sizes = SizesTemplate.bind({});
140
158
  sizes.args = {
141
- name: "four name",
159
+ name: "sizes",
160
+ };
161
+
162
+ export const variants = VariantsTemplate.bind({});
163
+ variants.args = {
164
+ name: "variants",
165
+ };
166
+
167
+ export const multiple = multipleTemplate.bind({});
168
+ multiple.args = {
169
+ name: "multiple",
142
170
  };
143
171
 
144
172
  export const block = DefaultTemplate.bind({});
145
173
  block.args = {
146
- name: "five name",
174
+ name: "block",
147
175
  block: true,
148
176
  };
149
177
 
178
+ export const separated = DefaultTemplate.bind({});
179
+ separated.args = {
180
+ name: "separated",
181
+ separated: true,
182
+ };
183
+
184
+ export const pill = DefaultTemplate.bind({});
185
+ pill.args = {
186
+ name: "pill",
187
+ pill: true,
188
+ separated: true,
189
+ };
190
+
191
+ export const square = SlotTemplate.bind({});
192
+ square.args = {
193
+ name: "square",
194
+ variant: "secondary",
195
+ square: true,
196
+ slotTemplate: `
197
+ <template #default>
198
+ <UToggleItem value="1">
199
+ <UIcon name="star" />
200
+ </UToggleItem>
201
+
202
+ <UToggleItem value="2" >
203
+ <UIcon name="add" />
204
+ </UToggleItem>
205
+
206
+ <UToggleItem value="3">
207
+ <UIcon name="timer" />
208
+ </UToggleItem>
209
+ </template>
210
+ `,
211
+ };
212
+
150
213
  export const slotDefault = SlotTemplate.bind({});
151
214
  slotDefault.args = {
152
- name: "third name",
215
+ name: "slotDefault",
153
216
  slotTemplate: `
154
217
  <template #default>
155
- <UToggleItem label="label" />
218
+ <UToggleItem label="label 1" value="1" />
219
+ <UToggleItem label="label 2" value="2" />
220
+ <UToggleItem label="label 3" value="3" />
156
221
  </template>
157
222
  `,
158
223
  };
@@ -17,6 +17,7 @@
17
17
  :name="name"
18
18
  :model-value="item.value"
19
19
  :value="item.value"
20
+ :disabled="disabled"
20
21
  :label="item.label"
21
22
  :data-cy="`${dataCy}-item-${index}`"
22
23
  v-bind="itemAttrs"
@@ -49,15 +50,6 @@ const props = defineProps({
49
50
  default: () => (!this.multiple ? "" : []),
50
51
  },
51
52
 
52
- /**
53
- * Toggle variant.
54
- * @values primary, secondary, thirdary
55
- */
56
- variant: {
57
- type: String,
58
- default: UIService.get(defaultConfig, UToggle).default.variant,
59
- },
60
-
61
53
  /**
62
54
  * Toggle item options.
63
55
  */
@@ -67,11 +59,12 @@ const props = defineProps({
67
59
  },
68
60
 
69
61
  /**
70
- * Toggle name.
62
+ * Toggle variant.
63
+ * @values primary, secondary, thirdary
71
64
  */
72
- name: {
65
+ variant: {
73
66
  type: String,
74
- required: true,
67
+ default: UIService.get(defaultConfig, UToggle).default.variant,
75
68
  },
76
69
 
77
70
  /**
@@ -83,6 +76,15 @@ const props = defineProps({
83
76
  default: UIService.get(defaultConfig, UToggle).default.size,
84
77
  },
85
78
 
79
+ /**
80
+ * Label placement.
81
+ * @values top, topInside, topWithDesc, bottom, left, right
82
+ */
83
+ labelAlign: {
84
+ type: String,
85
+ default: UIService.get(defaultConfig, UToggle).default.labelAlign,
86
+ },
87
+
86
88
  /**
87
89
  * Toggle label.
88
90
  */
@@ -100,20 +102,11 @@ const props = defineProps({
100
102
  },
101
103
 
102
104
  /**
103
- * Label placement.
104
- * @values top, topInside, topWithDesc, bottom, left, right
105
+ * Toggle name.
105
106
  */
106
- labelAlign: {
107
+ name: {
107
108
  type: String,
108
- default: UIService.get(defaultConfig, UToggle).default.labelAlign,
109
- },
110
-
111
- /**
112
- * Make the toggle fill the width with its container.
113
- */
114
- block: {
115
- type: Boolean,
116
- default: UIService.get(defaultConfig, UToggle).default.block,
109
+ required: true,
117
110
  },
118
111
 
119
112
  /**
@@ -124,15 +117,6 @@ const props = defineProps({
124
117
  default: UIService.get(defaultConfig, UToggle).default.multiple,
125
118
  },
126
119
 
127
- /**
128
- * Button color.
129
- * @values brand, grayscale, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, white
130
- */
131
- color: {
132
- type: String,
133
- default: UIService.get(defaultConfig, UToggle).default.color,
134
- },
135
-
136
120
  /**
137
121
  * Separate toggle items.
138
122
  */
@@ -150,11 +134,11 @@ const props = defineProps({
150
134
  },
151
135
 
152
136
  /**
153
- * Fill the background for thirdary variant.
137
+ * Make the toggle fill the width with its container.
154
138
  */
155
- filled: {
139
+ block: {
156
140
  type: Boolean,
157
- default: UIService.get(defaultConfig, UToggle).default.filled,
141
+ default: UIService.get(defaultConfig, UToggle).default.block,
158
142
  },
159
143
 
160
144
  /**
@@ -224,23 +208,24 @@ function updateSelectedValue(value, checked) {
224
208
  }
225
209
 
226
210
  if (checked) {
227
- selectedValue.value.push(value);
211
+ const items = selectedValue.value || [];
212
+
213
+ items.push(value);
214
+ selectedValue.value = items;
228
215
  } else {
229
216
  selectedValue.value = selectedValue.value.filter((item) => String(item) !== String(value));
230
217
  }
231
218
  }
232
219
 
233
220
  provide("toggleType", readonly(type));
221
+ provide("togglePill", () => props.pill);
234
222
  provide("toggleName", () => props.name);
235
223
  provide("toggleSize", () => props.size);
236
224
  provide("toggleBlock", () => props.block);
225
+ provide("toggleSquare", () => props.square);
237
226
  provide("toggleVariant", () => props.variant);
238
- provide("toggleColor", () => props.color);
239
- provide("toggleFilled", () => props.filled);
240
227
  provide("toggleDisabled", () => props.disabled);
241
228
  provide("toggleSeparated", () => props.separated);
242
- provide("togglePill", () => props.pill);
243
- provide("toggleSquare", () => props.square);
244
229
 
245
230
  provide("toggleSelectedValue", {
246
231
  selectedValue: readonly(selectedValue),
@@ -4,8 +4,8 @@ import useUI from "../../composable.ui";
4
4
 
5
5
  import defaultConfig from "../configs/default.config";
6
6
 
7
- export function useAttrs(props, { selectedValue, separated, variant, color }) {
8
- const { config, getAttrs, setColor } = useUI(defaultConfig, () => props.config);
7
+ export function useAttrs(props, { selectedValue, separated, variant }) {
8
+ const { config, getAttrs } = useUI(defaultConfig, () => props.config);
9
9
  const { button, selected } = config.value;
10
10
 
11
11
  const cvaButton = cva({
@@ -14,11 +14,12 @@ export function useAttrs(props, { selectedValue, separated, variant, color }) {
14
14
  compoundVariants: button.compoundVariants,
15
15
  });
16
16
 
17
- const buttonClasses = computed(() =>
18
- cvaButton({
17
+ const buttonClasses = computed(() => {
18
+ return cvaButton({
19
+ variant: toValue(variant),
19
20
  separated: toValue(separated),
20
- }),
21
- );
21
+ });
22
+ });
22
23
 
23
24
  const cvaSelected = cva({
24
25
  base: selected.base,
@@ -27,22 +28,18 @@ export function useAttrs(props, { selectedValue, separated, variant, color }) {
27
28
  });
28
29
 
29
30
  const selectedClasses = computed(() =>
30
- setColor(
31
- cvaSelected({
32
- color: toValue(color),
33
- variant: toValue(variant),
34
- }),
35
- toValue(color),
36
- ),
31
+ cvaSelected({
32
+ variant: toValue(variant),
33
+ }),
37
34
  );
38
35
 
39
- const buttonAttrsRaw = getAttrs("button", { isComponent: true, classes: buttonClasses });
40
36
  const inputAttrs = getAttrs("input");
37
+ const buttonAttrsRaw = getAttrs("button", { isComponent: true, classes: buttonClasses });
41
38
 
42
39
  const buttonAttrs = computed(() => {
43
- const isSelected = Array.isArray(selectedValue.value)
44
- ? selectedValue.value?.includes(props.value)
45
- : selectedValue.value === props.value;
40
+ const isSelected = Array.isArray(selectedValue?.value)
41
+ ? selectedValue?.value?.includes(props.value)
42
+ : selectedValue?.value === props.value;
46
43
 
47
44
  return {
48
45
  ...buttonAttrsRaw.value,
@@ -1,40 +1,39 @@
1
1
  export default /*tw*/ {
2
2
  button: {
3
- base: "",
3
+ base: `
4
+ border-gray-300 font-normal
5
+ hover:text-brand-600 hover:border-brand-600 hover:relative hover:z-10
6
+ focus:text-brand-600 focus:border-brand-600 focus:relative focus:z-10 focus:ring-brand-600 focus-within:ring-brand-600
7
+ active:text-brand-700 active:border-brand-700 active:relative active:z-10
8
+ disabled:border-brand-300 disabled:z-0
9
+ `,
4
10
  variants: {
5
11
  separated: {
6
- false: "!rounded-none",
12
+ false: "rounded-none",
13
+ },
14
+ variant: {
15
+ thirdary: "border-none hover:bg-brand-600 hover:bg-opacity-5",
7
16
  },
8
17
  },
9
18
  },
10
19
  input: "p-0 m-0 size-0 invisible absolute",
11
20
  selected: {
12
- base: "",
21
+ base: "relative disabled:z-10",
13
22
  variants: {
14
23
  variant: {
15
- primary: "!bg-{color}-800 !border-{color}-800",
16
- secondary: "!text-{color}-800 !border-{color}-800 bg-{color}-800 bg-opacity-10",
17
- thirdary: "!text-{color}-800 !bg-{color}-800 !bg-opacity-10",
24
+ primary: "!text-white bg-brand-600 border-brand-600 disabled:border-brand-600",
25
+ secondary: "text-brand-600 border-brand-600 disabled:border-brand-600 bg-brand-600 bg-opacity-10",
26
+ thirdary: "text-brand-600 bg-brand-600 bg-opacity-10",
18
27
  },
19
28
  },
20
- compoundVariants: [
21
- { color: "grayscale", variant: "primary", class: "!bg-brand-700 !border-brand-700" },
22
- { color: "grayscale", variant: "secondary", class: "!text-brand-700 !border-brand-700 !bg-brand-50 !bg-opacity-100" },
23
- { color: "grayscale", variant: "thirdary", class: "!text-brand-700 !bg-brand-50" },
24
- { color: "white", variant: "primary", class: "!text-brand-700 !border-brand-600 !bg-brand-50" },
25
- { color: "white", variant: "secondary", class: "!text-brand-700 !border-brand-600 !bg-brand-50" },
26
- { color: "white", variant: "thirdary", class: "!text-brand-700 !bg-brand-50" },
27
- ],
28
29
  },
29
30
  defaultVariants: {
30
- color: "brand",
31
31
  variant: "primary",
32
32
  type: "radio",
33
33
  size: "md",
34
34
  block: false,
35
35
  pill: false,
36
36
  square: false,
37
- filled: false,
38
37
  disabled: false,
39
38
  },
40
39
  };
@@ -12,6 +12,7 @@ export default {
12
12
  args: {
13
13
  value: "1",
14
14
  label: "Label",
15
+ modelValue: "",
15
16
  },
16
17
  argTypes: {
17
18
  ...getArgTypes(UToggleItem.name),
@@ -41,7 +42,7 @@ const SlotTemplate = (args) => ({
41
42
  return { args };
42
43
  },
43
44
  template: `
44
- <UToggleItem v-bind="args" label="Label" >
45
+ <UToggleItem v-bind="args" >
45
46
  ${args.slotTemplate}
46
47
  </UToggleItem>
47
48
  `,
@@ -1,16 +1,15 @@
1
1
  <template>
2
2
  <UButton
3
- tag="label"
4
3
  tabindex="0"
5
4
  :for="id"
5
+ color="grayscale"
6
+ variant="secondary"
6
7
  :label="label"
7
8
  :size="toValue(size)"
8
- :block="toValue(block)"
9
- :variant="toValue(variant)"
10
- :color="toValue(color)"
11
9
  :pill="toValue(pill)"
12
- :filled="toValue(filled)"
10
+ :block="toValue(block)"
13
11
  :square="toValue(square)"
12
+ :disabled="toValue(disabled)"
14
13
  v-bind="buttonAttrs"
15
14
  @click.stop="onClickSetValue"
16
15
  >
@@ -118,21 +117,19 @@ const emit = defineEmits(["update:modelValue"]);
118
117
  const name = inject("toggleName", () => "toggle");
119
118
  const type = inject("toggleType", UIService.get(defaultConfig, UToggleItem).default.type);
120
119
  const size = inject("toggleSize", UIService.get(defaultConfig, UToggleItem).default.size);
121
- const block = inject("toggleBlock", UIService.get(defaultConfig, UToggleItem).default.block);
122
- const variant = inject("toggleVariant", UIService.get(defaultConfig, UToggleItem).default.variant);
123
- const color = inject("toggleColor", UIService.get(defaultConfig, UToggleItem).default.color);
124
- const filled = inject("toggleFilled", UIService.get(defaultConfig, UToggleItem).default.filled);
125
120
  const pill = inject("togglePill", UIService.get(defaultConfig, UToggleItem).default.pill);
121
+ const block = inject("toggleBlock", UIService.get(defaultConfig, UToggleItem).default.block);
126
122
  const square = inject("toggleSquare", UIService.get(defaultConfig, UToggleItem).default.square);
127
- const separated = inject("toggleSeparated", false);
123
+ const variant = inject("toggleVariant", UIService.get(defaultConfig, UToggleItem).default.variant);
124
+ const separated = inject("toggleSeparated", () => true);
128
125
  // eslint-disable-next-line vue/no-dupe-keys, prettier/prettier
129
- const disabled = inject("toggleDisabled", UIService.get(defaultConfig, UToggleItem).default.disabled);
126
+ const disabled = inject("toggleDisabled", props.disabled || UIService.get(defaultConfig, UToggleItem).default.disabled);
130
127
 
131
128
  const { selectedValue, updateSelectedValue } = inject("toggleSelectedValue", {});
132
129
 
133
130
  const selectedItem = ref("");
134
131
 
135
- const { buttonAttrs, inputAttrs } = useAttrs(props, { selectedValue, separated, variant, color });
132
+ const { buttonAttrs, inputAttrs } = useAttrs(props, { selectedValue, separated, variant });
136
133
 
137
134
  onMounted(() => {
138
135
  if (type.value === TYPE_RADIO) {
@@ -1,12 +1,27 @@
1
1
  import useUI from "../../composable.ui";
2
+ import { cva } from "../../service.ui";
2
3
 
3
4
  import defaultConfig from "../configs/default.config";
4
5
  import { computed, watchEffect } from "vue";
5
6
 
6
7
  export default function useAttrs(props, { isShownCalendar }) {
7
8
  const { config, getAttrs } = useUI(defaultConfig, () => props.config);
9
+ const { calendar } = config.value;
8
10
 
9
- const calendarAttrs = getAttrs("calendar");
11
+ const cvaCalendarWrapper = cva({
12
+ base: calendar.wrapper.base,
13
+ variants: calendar.wrapper.variants,
14
+ compoundVariants: calendar.wrapper.compoundVariants,
15
+ });
16
+
17
+ const calendarWrapperClasses = computed(() =>
18
+ cvaCalendarWrapper({ openDirection: props.openDirection }),
19
+ );
20
+
21
+ const calendarAttrs = getAttrs("calendar", {
22
+ isComponent: true,
23
+ classes: calendarWrapperClasses,
24
+ });
10
25
  const inputBlurAttrs = getAttrs("input");
11
26
  const inputActiveAttrs = getAttrs("inputActive");
12
27
  const wrapperAttrs = getAttrs("wrapper");
@@ -6,7 +6,17 @@ export default /*tw*/ {
6
6
  base: "ring-4 ring-brand-600/[.15] border-brand-500 hover:border-brand-500",
7
7
  },
8
8
  },
9
- calendar: "absolute z-40 mt-2",
9
+ calendar: {
10
+ wrapper: {
11
+ base: "absolute z-40 mt-2",
12
+ variants: {
13
+ openDirection: {
14
+ left: "left-0",
15
+ right: "right-0",
16
+ },
17
+ },
18
+ },
19
+ },
10
20
  calendarTransition: {
11
21
  enterFromClass: "opacity-0 scale-95",
12
22
  enterActiveClass: "transition transform ease-out duration-100",
@@ -99,6 +109,7 @@ export default /*tw*/ {
99
109
  dateFormat: "Y-m-d",
100
110
  userFormat: "F j, Y",
101
111
  size: "md",
112
+ openDirection: "left",
102
113
  timepicker: false,
103
114
  disabled: false,
104
115
  maxDate: undefined,
@@ -64,6 +64,28 @@ const SizesTemplate = (args, { argTypes } = {}) => ({
64
64
  `,
65
65
  });
66
66
 
67
+ const OpenDirectionTemplate = (args, { argTypes } = {}) => ({
68
+ components: { UDatePicker, URow },
69
+ setup() {
70
+ return {
71
+ args,
72
+ directions: argTypes.openDirection.options,
73
+ };
74
+ },
75
+ template: `
76
+ <URow class="!flex-col">
77
+ <UDatePicker
78
+ class="w-full"
79
+ v-for="(direction, index) in directions"
80
+ :open-direction="direction"
81
+ v-bind="args"
82
+ v-model="args.value"
83
+ :key="index"
84
+ />
85
+ </URow>
86
+ `,
87
+ });
88
+
67
89
  const SlotTemplate = (args) => ({
68
90
  components: { UDatePicker, UIcon },
69
91
  setup() {
@@ -82,6 +104,9 @@ Default.args = { date: 1645653600 };
82
104
  export const sizes = SizesTemplate.bind({});
83
105
  sizes.args = { label: "" };
84
106
 
107
+ export const openDirection = OpenDirectionTemplate.bind({});
108
+ openDirection.args = {};
109
+
85
110
  export const description = DefaultTemplate.bind({});
86
111
  description.args = { description: "some description" };
87
112
 
@@ -101,6 +101,15 @@ const props = defineProps({
101
101
  default: null,
102
102
  },
103
103
 
104
+ /**
105
+ * Datepicker open direction.
106
+ * @values left, right
107
+ */
108
+ openDirection: {
109
+ type: String,
110
+ default: UIService.get(defaultConfig, UDatePicker).default.openDirection,
111
+ },
112
+
104
113
  /**
105
114
  * Min date in format date string or Date.
106
115
  */
@@ -1,5 +1,5 @@
1
1
  import useUI from "../../composable.ui";
2
- import { cx } from "../../service.ui";
2
+ import { cx, cva } from "../../service.ui";
3
3
 
4
4
  import { computed, watchEffect } from "vue";
5
5
 
@@ -7,6 +7,15 @@ import defaultConfig from "../configs/default.config";
7
7
 
8
8
  export default function useAttrs(props, { isShownMenu }) {
9
9
  const { config, getAttrs } = useUI(defaultConfig, () => props.config);
10
+ const { menu } = config.value;
11
+
12
+ const cvaMenu = cva({
13
+ base: menu.base,
14
+ variants: menu.variants,
15
+ compoundVariants: menu.compoundVariants,
16
+ });
17
+
18
+ const menuClasses = computed(() => cvaMenu({ openDirection: props.openDirection }));
10
19
 
11
20
  const wrapperAttrs = getAttrs("wrapper");
12
21
  const buttonWrapperAttrsRaw = getAttrs("buttonWrapper");
@@ -57,7 +66,7 @@ export default function useAttrs(props, { isShownMenu }) {
57
66
  return isShownMenu.value ? inputActiveAttrs.value : inputBlurAttrs.value;
58
67
  });
59
68
 
60
- const menuAttrs = getAttrs("menu");
69
+ const menuAttrs = getAttrs("menu", { classes: menuClasses });
61
70
  const periodsRowAttrs = getAttrs("periodsRow");
62
71
  const rangeSwitchWrapperAttrs = getAttrs("rangeSwitchWrapper");
63
72
  const nextIconAttrs = getAttrs("nextIcon");
@@ -19,7 +19,15 @@ export default /*tw*/ {
19
19
  hover:bg-zinc-200 hover:ring-brand-600/[.15] focus:border-0 focus:ring-0 focus:ring-brand-600/[.15] active:bg-zinc-200
20
20
  disabled:cursor-not-allowed last:rounded-l-none last:rounded-r-lg first:rounded-l-lg first:rounded-r-none
21
21
  `,
22
- menu: "absolute z-40 mt-2 w-80 overflow-hidden rounded-lg border border-brand-300 bg-white p-2 shadow focus:outline-none",
22
+ menu: {
23
+ base: "absolute z-40 mt-2 w-80 overflow-hidden rounded-lg border border-brand-300 bg-white p-2 shadow focus:outline-none",
24
+ variants: {
25
+ openDirection: {
26
+ left: "left-0",
27
+ right: "right-0",
28
+ },
29
+ },
30
+ },
23
31
  menuTransition: {
24
32
  enterFromClass: "opacity-0 scale-95",
25
33
  enterActiveClass: "transition transform ease-out duration-100",
@@ -185,6 +193,7 @@ export default /*tw*/ {
185
193
  defaultVariants: {
186
194
  size: "md",
187
195
  variant: "button",
196
+ openDirection: "left",
188
197
  timepicker: false,
189
198
  disabled: false,
190
199
  dateFormat: "d.m.Y",
@@ -18,5 +18,5 @@ export const PERIOD = {
18
18
  quarter: "quarter",
19
19
  year: "year",
20
20
  ownRange: "ownRange",
21
- lastThirtyDays: "lastThirtyDays",
21
+ custom: "custom",
22
22
  };
@@ -79,12 +79,37 @@ const VariantsTemplate = (args, { argTypes } = {}) => ({
79
79
  `,
80
80
  });
81
81
 
82
+ const OpenDirectionTemplate = (args, { argTypes } = {}) => ({
83
+ components: { UDatePickerRange, URow },
84
+ setup() {
85
+ return {
86
+ args,
87
+ directions: argTypes.openDirection.options,
88
+ };
89
+ },
90
+ template: `
91
+ <URow class="!flex-col">
92
+ <UDatePickerRange
93
+ class="w-full"
94
+ v-for="(direction, index) in directions"
95
+ :open-direction="direction"
96
+ v-bind="args"
97
+ v-model="args.value"
98
+ :key="index"
99
+ />
100
+ </URow>
101
+ `,
102
+ });
103
+
82
104
  export const Default = DefaultTemplate.bind({});
83
105
  Default.args = {};
84
106
 
85
107
  export const variants = VariantsTemplate.bind({});
86
108
  variants.args = {};
87
109
 
110
+ export const openDirection = OpenDirectionTemplate.bind({});
111
+ openDirection.args = {};
112
+
88
113
  export const disabled = VariantsTemplate.bind({});
89
114
  disabled.args = { disabled: true };
90
115
 
@@ -272,6 +272,15 @@ const props = defineProps({
272
272
  }),
273
273
  },
274
274
 
275
+ /**
276
+ * Datepicker open direction.
277
+ * @values left, right
278
+ */
279
+ openDirection: {
280
+ type: String,
281
+ default: UIService.get(defaultConfig, UDatePickerRange).default.openDirection,
282
+ },
283
+
275
284
  /**
276
285
  * The variant of the date picker.
277
286
  * @values button, input
@@ -860,8 +869,11 @@ function onInputRangeInput(value, type) {
860
869
  setDefaultPeriodForButton();
861
870
 
862
871
  function setDefaultPeriodForButton() {
863
- const from = utcToGMT(getDateFromUnixTimestamp(props.modelValue.to || new Date()));
864
- const to = utcToGMT(getDateFromUnixTimestamp(props.modelValue.from || new Date()));
872
+ const from = utcToGMT(getDateFromUnixTimestamp(props.modelValue.from || new Date()));
873
+ const to = utcToGMT(getDateFromUnixTimestamp(props.modelValue.to || new Date()));
874
+
875
+ const customFrom = utcToGMT(getDateFromUnixTimestamp(props.customRangeButton.range.from));
876
+ const customTo = utcToGMT(getDateFromUnixTimestamp(props.customRangeButton.range.to));
865
877
 
866
878
  const isWeekPeriod =
867
879
  String(from) === String(getStartOfWeek(from, { weekStartsOn: 1 })) &&
@@ -874,6 +886,7 @@ function setDefaultPeriodForButton() {
874
886
  String(from) === String(getStartOfQuarter(from)) && String(to) === String(getEndOfQuarter(to));
875
887
  const isYearPeriod =
876
888
  String(from) === String(getStartOfYear(from)) && String(to) === String(getEndOfYear(to));
889
+ const isCustomPeriod = String(from) === String(customFrom) && String(to) === String(customTo);
877
890
 
878
891
  if (!props.modelValue.from && !props.modelValue.to) {
879
892
  period.value = PERIOD.ownRange;
@@ -885,6 +898,8 @@ function setDefaultPeriodForButton() {
885
898
  period.value = PERIOD.quarter;
886
899
  } else if (isWeekPeriod) {
887
900
  period.value = PERIOD.week;
901
+ } else if (isCustomPeriod) {
902
+ period.value = PERIOD.custom;
888
903
  } else {
889
904
  period.value = PERIOD.ownRange;
890
905
  }
@@ -93,12 +93,10 @@ export function getWeekDateList(date, monthShortLocales = {}) {
93
93
  const isLastWeek = week + day === weeksInMonth;
94
94
 
95
95
  let monthFirstDayOfWeek = "";
96
- let monthLastDayOfWeek = endOfWeekDate.toLocaleString("en-us", { month: "long" }).toLowerCase();
96
+ let monthLastDayOfWeek = endOfWeekDate.getMonth();
97
97
 
98
98
  if (isDayInPreviousMonth || isLastWeek) {
99
- monthFirstDayOfWeek = startOfWeekDate
100
- .toLocaleString("en-us", { month: "long" })
101
- .toLowerCase();
99
+ monthFirstDayOfWeek = startOfWeekDate.getMonth();
102
100
  }
103
101
 
104
102
  const title = `${firstDayOfWeek} ${
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.151",
4
+ "version": "0.0.153",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
@@ -1530,6 +1530,15 @@
1530
1530
  },
1531
1531
  "default": "null"
1532
1532
  },
1533
+ {
1534
+ "name": "openDirection",
1535
+ "description": "Datepicker open direction.",
1536
+ "value": {
1537
+ "kind": "expression",
1538
+ "type": "'left' | 'right'"
1539
+ },
1540
+ "default": "left"
1541
+ },
1533
1542
  {
1534
1543
  "name": "minDate",
1535
1544
  "description": "Min date in format date string or Date.",
@@ -1683,6 +1692,15 @@
1683
1692
  },
1684
1693
  "default": "{\n range: { from: 0, to: 0 },\n label: \"\",\n description: \"\"\n}"
1685
1694
  },
1695
+ {
1696
+ "name": "openDirection",
1697
+ "description": "Datepicker open direction.",
1698
+ "value": {
1699
+ "kind": "expression",
1700
+ "type": "'left' | 'right'"
1701
+ },
1702
+ "default": "left"
1703
+ },
1686
1704
  {
1687
1705
  "name": "variant",
1688
1706
  "description": "The variant of the date picker.",
@@ -7002,15 +7020,6 @@
7002
7020
  },
7003
7021
  "default": "() => (!this.multiple ? \"\" : [])"
7004
7022
  },
7005
- {
7006
- "name": "variant",
7007
- "description": "Toggle variant.",
7008
- "value": {
7009
- "kind": "expression",
7010
- "type": "'primary' | 'secondary' | 'thirdary'"
7011
- },
7012
- "default": "primary"
7013
- },
7014
7023
  {
7015
7024
  "name": "options",
7016
7025
  "description": "Toggle item options.",
@@ -7021,13 +7030,13 @@
7021
7030
  "default": "[]"
7022
7031
  },
7023
7032
  {
7024
- "name": "name",
7025
- "required": true,
7026
- "description": "Toggle name.",
7033
+ "name": "variant",
7034
+ "description": "Toggle variant.",
7027
7035
  "value": {
7028
7036
  "kind": "expression",
7029
- "type": "string"
7030
- }
7037
+ "type": "'primary' | 'secondary' | 'thirdary'"
7038
+ },
7039
+ "default": "primary"
7031
7040
  },
7032
7041
  {
7033
7042
  "name": "size",
@@ -7038,6 +7047,15 @@
7038
7047
  },
7039
7048
  "default": "md"
7040
7049
  },
7050
+ {
7051
+ "name": "labelAlign",
7052
+ "description": "Label placement.",
7053
+ "value": {
7054
+ "kind": "expression",
7055
+ "type": "'top' | 'topInside' | 'topWithDesc' | 'bottom' | 'left' | 'right'"
7056
+ },
7057
+ "default": "top"
7058
+ },
7041
7059
  {
7042
7060
  "name": "label",
7043
7061
  "description": "Toggle label.",
@@ -7057,22 +7075,13 @@
7057
7075
  "default": "\"\""
7058
7076
  },
7059
7077
  {
7060
- "name": "labelAlign",
7061
- "description": "Label placement.",
7062
- "value": {
7063
- "kind": "expression",
7064
- "type": "'top' | 'topInside' | 'topWithDesc' | 'bottom' | 'left' | 'right'"
7065
- },
7066
- "default": "top"
7067
- },
7068
- {
7069
- "name": "block",
7070
- "description": "Make the toggle fill the width with its container.",
7078
+ "name": "name",
7079
+ "required": true,
7080
+ "description": "Toggle name.",
7071
7081
  "value": {
7072
7082
  "kind": "expression",
7073
- "type": "boolean"
7074
- },
7075
- "default": "false"
7083
+ "type": "string"
7084
+ }
7076
7085
  },
7077
7086
  {
7078
7087
  "name": "multiple",
@@ -7083,15 +7092,6 @@
7083
7092
  },
7084
7093
  "default": "false"
7085
7094
  },
7086
- {
7087
- "name": "color",
7088
- "description": "Button color.",
7089
- "value": {
7090
- "kind": "expression",
7091
- "type": "'brand' | 'grayscale' | 'gray' | 'red' | 'orange' | 'amber' | 'yellow' | 'lime' | 'green' | 'emerald' | 'teal' | 'cyan' | 'sky' | 'blue' | 'indigo' | 'violet' | 'purple' | 'fuchsia' | 'pink' | 'rose' | 'white'"
7092
- },
7093
- "default": "brand"
7094
- },
7095
7095
  {
7096
7096
  "name": "separated",
7097
7097
  "description": "Separate toggle items.",
@@ -7111,8 +7111,8 @@
7111
7111
  "default": "false"
7112
7112
  },
7113
7113
  {
7114
- "name": "filled",
7115
- "description": "Fill the background for thirdary variant.",
7114
+ "name": "block",
7115
+ "description": "Make the toggle fill the width with its container.",
7116
7116
  "value": {
7117
7117
  "kind": "expression",
7118
7118
  "type": "boolean"