vueless 0.0.105 → 0.0.106

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.105",
3
+ "version": "0.0.106",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -6,6 +6,7 @@ export default /*tw*/ {
6
6
  `,
7
7
  toggleItem: "",
8
8
  defaultVariants: {
9
+ variant: "primary",
9
10
  size: "md",
10
11
  block: false,
11
12
  multiple: false,
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div ref="wrapperRef" :data-cy="dataCy" v-bind="wrapperAttrs">
2
+ <div :data-cy="dataCy" v-bind="wrapperAttrs">
3
3
  <slot>
4
4
  <UToggleItem
5
5
  v-for="(item, index) in options"
@@ -16,7 +16,7 @@
16
16
  </template>
17
17
 
18
18
  <script setup>
19
- import { computed, provide, readonly, ref } from "vue";
19
+ import { computed, provide, readonly } from "vue";
20
20
 
21
21
  import UToggleItem from "../ui.button-toggle-item";
22
22
  import UIService from "../service.ui";
@@ -30,39 +30,40 @@ defineOptions({ name: "UToggle", inheritAttrs: false });
30
30
 
31
31
  const props = defineProps({
32
32
  /**
33
- * Set buttons name.
33
+ * Selected value.
34
34
  */
35
- name: {
36
- type: String,
37
- required: true,
35
+ modelValue: {
36
+ type: [String, Number, Array],
37
+ default: () => (!this.multiple ? "" : []),
38
38
  },
39
39
 
40
40
  /**
41
- * Set data for buttons.
41
+ * Toggle variants.
42
+ * @values primary, secondary, thirdary
42
43
  */
43
- options: {
44
- type: Array,
45
- default: () => [],
44
+ variant: {
45
+ type: String,
46
+ default: UIService.get(defaultConfig, UToggle).default.variant,
46
47
  },
47
48
 
48
49
  /**
49
- * Set current value.
50
+ * Toggle item options.
50
51
  */
51
- modelValue: {
52
- type: [String, Number, Array],
53
- default: () => (!this.multiple ? "" : []),
52
+ options: {
53
+ type: Array,
54
+ default: () => [],
54
55
  },
55
56
 
56
57
  /**
57
- * Allow to select a few options and return them as array.
58
+ * Toggle name.
58
59
  */
59
- multiple: {
60
- type: Boolean,
61
- default: UIService.get(defaultConfig, UToggle).default.multiple,
60
+ name: {
61
+ type: String,
62
+ required: true,
62
63
  },
63
64
 
64
65
  /**
65
- * The size of the buttons.
66
+ * Toggle size.
66
67
  * @values xs, sm, md, lg
67
68
  */
68
69
  size: {
@@ -78,6 +79,14 @@ const props = defineProps({
78
79
  default: UIService.get(defaultConfig, UToggle).default.block,
79
80
  },
80
81
 
82
+ /**
83
+ * Allow selecting a few options and return them as an array.
84
+ */
85
+ multiple: {
86
+ type: Boolean,
87
+ default: UIService.get(defaultConfig, UToggle).default.multiple,
88
+ },
89
+
81
90
  /**
82
91
  * Sets data-cy attribute for automated testing.
83
92
  */
@@ -91,14 +100,14 @@ const emit = defineEmits(["update:modelValue"]);
91
100
 
92
101
  const { wrapperAttrs, toggleItemAttrs } = useAttrs(props);
93
102
 
94
- const wrapperRef = ref();
95
-
96
103
  const selectedValue = computed({
97
104
  get: () => props.modelValue,
98
105
  set: (value) => emit("update:modelValue", value),
99
106
  });
100
107
 
101
- const type = computed(() => (props.multiple ? TYPE_CHECKBOX : TYPE_RADIO));
108
+ const type = computed(() => {
109
+ return props.multiple ? TYPE_CHECKBOX : TYPE_RADIO;
110
+ });
102
111
 
103
112
  function updateSelectedValue(value, checked) {
104
113
  if (type.value === TYPE_RADIO) {
@@ -114,14 +123,11 @@ function updateSelectedValue(value, checked) {
114
123
  }
115
124
  }
116
125
 
126
+ provide("toggleType", readonly(type));
117
127
  provide("toggleName", () => props.name);
118
-
119
128
  provide("toggleSize", () => props.size);
120
-
121
129
  provide("toggleBlock", () => props.block);
122
-
123
- provide("toggleType", readonly(type));
124
-
130
+ provide("toggleVariant", () => props.variant);
125
131
  provide("toggleSelectedValue", {
126
132
  selectedValue: readonly(selectedValue),
127
133
  updateSelectedValue,
@@ -4,7 +4,7 @@ import { cva } from "../../service.ui";
4
4
 
5
5
  import defaultConfig from "../configs/default.config";
6
6
 
7
- export function useAttrs(props, { size, block }) {
7
+ export function useAttrs(props, { size, block, variant }) {
8
8
  const { config, getAttrs, hasSlotContent } = useUI(defaultConfig, () => props.config);
9
9
  const { label, labelText, wrapper } = config.value;
10
10
 
@@ -33,7 +33,7 @@ export function useAttrs(props, { size, block }) {
33
33
  const labelClasses = computed(() =>
34
34
  cvaLabel({
35
35
  size: toValue(size),
36
- variant: props.variant,
36
+ variant: toValue(variant),
37
37
  disabled: props.disabled,
38
38
  }),
39
39
  );
@@ -3,10 +3,10 @@
3
3
  <input
4
4
  :id="id"
5
5
  v-model="selectedItem"
6
- :disabled="disabled"
7
- :value="value"
8
6
  :name="name"
9
7
  :type="type"
8
+ :value="value"
9
+ :disabled="disabled"
10
10
  v-bind="inputAttrs"
11
11
  />
12
12
  <label tabindex="0" :for="id" v-bind="labelAttrs" @click="onClickSetValue">
@@ -42,7 +42,7 @@ defineOptions({ name: "UToggleItem", inheritAttrs: false });
42
42
 
43
43
  const props = defineProps({
44
44
  /**
45
- * Set data for button.
45
+ * Selected value.
46
46
  */
47
47
  modelValue: {
48
48
  type: [String, Number, Array],
@@ -50,7 +50,7 @@ const props = defineProps({
50
50
  },
51
51
 
52
52
  /**
53
- * Set value for checkbox state.
53
+ * Value for checkbox state.
54
54
  */
55
55
  value: {
56
56
  type: [String, Number],
@@ -58,7 +58,7 @@ const props = defineProps({
58
58
  },
59
59
 
60
60
  /**
61
- * Set label.
61
+ * Toggle item label.
62
62
  */
63
63
  label: {
64
64
  type: String,
@@ -66,22 +66,13 @@ const props = defineProps({
66
66
  },
67
67
 
68
68
  /**
69
- * Make item disabled.
69
+ * Make toggle item disabled.
70
70
  */
71
71
  disabled: {
72
72
  type: Boolean,
73
73
  default: UIService.get(defaultConfig, UToggleItem).default.disabled,
74
74
  },
75
75
 
76
- /**
77
- * The variant of the button.
78
- * @values primary, secondary, thirdary
79
- */
80
- variant: {
81
- type: String,
82
- default: UIService.get(defaultConfig, UToggleItem).default.variant,
83
- },
84
-
85
76
  /**
86
77
  * Generates unique element id.
87
78
  * @ignore
@@ -92,7 +83,7 @@ const props = defineProps({
92
83
  },
93
84
 
94
85
  /**
95
- * Sets component ui config object.
86
+ * Component ui config object.
96
87
  */
97
88
  config: {
98
89
  type: Object,
@@ -100,7 +91,7 @@ const props = defineProps({
100
91
  },
101
92
 
102
93
  /**
103
- * Sets data-cy attribute for automated testing.
94
+ * Data-cy attribute for automated testing.
104
95
  */
105
96
  dataCy: {
106
97
  type: String,
@@ -110,15 +101,17 @@ const props = defineProps({
110
101
 
111
102
  const emit = defineEmits(["update:modelValue"]);
112
103
 
104
+ const name = inject("toggleName", () => "toggle");
113
105
  const type = inject("toggleType", UIService.get(defaultConfig, UToggleItem).default.type);
114
- const name = inject("toggleName", "toggle");
115
106
  const size = inject("toggleSize", UIService.get(defaultConfig, UToggleItem).default.size);
116
107
  const block = inject("toggleBlock", UIService.get(defaultConfig, UToggleItem).default.block);
108
+ const variant = inject("toggleVariant", UIService.get(defaultConfig, UToggleItem).default.variant);
117
109
  const { selectedValue, updateSelectedValue } = inject("toggleSelectedValue", {});
118
110
 
119
111
  const { wrapperAttrs, labelTextAttrs, labelAttrs, inputAttrs, hasSlotContent } = useAttrs(props, {
120
112
  size,
121
113
  block,
114
+ variant,
122
115
  });
123
116
 
124
117
  const selectedItem = ref("");
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.105",
4
+ "version": "0.0.106",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
@@ -6952,44 +6952,44 @@
6952
6952
  "description": "",
6953
6953
  "attributes": [
6954
6954
  {
6955
- "name": "name",
6956
- "required": true,
6957
- "description": "Set buttons name.",
6955
+ "name": "modelValue",
6956
+ "description": "Selected value.",
6958
6957
  "value": {
6959
6958
  "kind": "expression",
6960
- "type": "string"
6961
- }
6959
+ "type": "string|number|array"
6960
+ },
6961
+ "default": "() => (!this.multiple ? \"\" : [])"
6962
6962
  },
6963
6963
  {
6964
- "name": "options",
6965
- "description": "Set data for buttons.",
6964
+ "name": "variant",
6965
+ "description": "Toggle variants.",
6966
6966
  "value": {
6967
6967
  "kind": "expression",
6968
- "type": "array"
6968
+ "type": "'primary' | 'secondary' | 'thirdary'"
6969
6969
  },
6970
- "default": "[]"
6970
+ "default": "primary"
6971
6971
  },
6972
6972
  {
6973
- "name": "modelValue",
6974
- "description": "Set current value.",
6973
+ "name": "options",
6974
+ "description": "Toggle item options.",
6975
6975
  "value": {
6976
6976
  "kind": "expression",
6977
- "type": "string|number|array"
6977
+ "type": "array"
6978
6978
  },
6979
- "default": "() => (!this.multiple ? \"\" : [])"
6979
+ "default": "[]"
6980
6980
  },
6981
6981
  {
6982
- "name": "multiple",
6983
- "description": "Allow to select a few options and return them as array.",
6982
+ "name": "name",
6983
+ "required": true,
6984
+ "description": "Toggle name.",
6984
6985
  "value": {
6985
6986
  "kind": "expression",
6986
- "type": "boolean"
6987
- },
6988
- "default": "false"
6987
+ "type": "string"
6988
+ }
6989
6989
  },
6990
6990
  {
6991
6991
  "name": "size",
6992
- "description": "The size of the buttons.",
6992
+ "description": "Toggle size.",
6993
6993
  "value": {
6994
6994
  "kind": "expression",
6995
6995
  "type": "'xs' | 'sm' | 'md' | 'lg'"
@@ -7005,6 +7005,15 @@
7005
7005
  },
7006
7006
  "default": "false"
7007
7007
  },
7008
+ {
7009
+ "name": "multiple",
7010
+ "description": "Allow selecting a few options and return them as an array.",
7011
+ "value": {
7012
+ "kind": "expression",
7013
+ "type": "boolean"
7014
+ },
7015
+ "default": "false"
7016
+ },
7008
7017
  {
7009
7018
  "name": "dataCy",
7010
7019
  "description": "Sets data-cy attribute for automated testing.",
@@ -7036,7 +7045,7 @@
7036
7045
  "attributes": [
7037
7046
  {
7038
7047
  "name": "modelValue",
7039
- "description": "Set data for button.",
7048
+ "description": "Selected value.",
7040
7049
  "value": {
7041
7050
  "kind": "expression",
7042
7051
  "type": "string|number|array"
@@ -7045,7 +7054,7 @@
7045
7054
  },
7046
7055
  {
7047
7056
  "name": "value",
7048
- "description": "Set value for checkbox state.",
7057
+ "description": "Value for checkbox state.",
7049
7058
  "value": {
7050
7059
  "kind": "expression",
7051
7060
  "type": "string|number"
@@ -7054,7 +7063,7 @@
7054
7063
  },
7055
7064
  {
7056
7065
  "name": "label",
7057
- "description": "Set label.",
7066
+ "description": "Toggle item label.",
7058
7067
  "value": {
7059
7068
  "kind": "expression",
7060
7069
  "type": "string"
@@ -7063,22 +7072,13 @@
7063
7072
  },
7064
7073
  {
7065
7074
  "name": "disabled",
7066
- "description": "Make item disabled.",
7075
+ "description": "Make toggle item disabled.",
7067
7076
  "value": {
7068
7077
  "kind": "expression",
7069
7078
  "type": "boolean"
7070
7079
  },
7071
7080
  "default": "false"
7072
7081
  },
7073
- {
7074
- "name": "variant",
7075
- "description": "The variant of the button.",
7076
- "value": {
7077
- "kind": "expression",
7078
- "type": "'primary' | 'secondary' | 'thirdary'"
7079
- },
7080
- "default": "primary"
7081
- },
7082
7082
  {
7083
7083
  "name": "id",
7084
7084
  "description": "@ignore: Generates unique element id.",
@@ -7090,7 +7090,7 @@
7090
7090
  },
7091
7091
  {
7092
7092
  "name": "config",
7093
- "description": "Sets component ui config object.",
7093
+ "description": "Component ui config object.",
7094
7094
  "value": {
7095
7095
  "kind": "expression",
7096
7096
  "type": "object"
@@ -7099,7 +7099,7 @@
7099
7099
  },
7100
7100
  {
7101
7101
  "name": "dataCy",
7102
- "description": "Sets data-cy attribute for automated testing.",
7102
+ "description": "Data-cy attribute for automated testing.",
7103
7103
  "value": {
7104
7104
  "kind": "expression",
7105
7105
  "type": "string"