@opentinyvue/vue-checkbox 2.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 - present TinyVue Authors.
4
+ Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/index.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright (c) 2022 - present TinyVue Authors.
3
+ * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license.
6
+ *
7
+ * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8
+ * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9
+ * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10
+ *
11
+ */
12
+ import Checkbox from './src/index';
13
+ export default Checkbox;
package/lib/index.js ADDED
@@ -0,0 +1,117 @@
1
+ function _extends() {
2
+ return _extends = Object.assign ? Object.assign.bind() : function(n) {
3
+ for (var e = 1; e < arguments.length; e++) {
4
+ var t = arguments[e];
5
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
6
+ }
7
+ return n;
8
+ }, _extends.apply(null, arguments);
9
+ }
10
+ import { defineComponent, $prefix, $setup, $props } from "@opentinyvue/vue-common";
11
+ import PcTemplate from "./pc.js";
12
+ import MobileTemplate from "./mobile.js";
13
+ import MobileFirstTemplate from "./mobile-first.js";
14
+ var template = function template2(mode) {
15
+ var _process$env;
16
+ var tinyMode = typeof process === "object" ? (_process$env = process.env) == null ? void 0 : _process$env.TINY_MODE : null;
17
+ if ("pc" === (tinyMode || mode)) {
18
+ return PcTemplate;
19
+ }
20
+ if ("mobile" === (tinyMode || mode)) {
21
+ return MobileTemplate;
22
+ }
23
+ if ("mobile-first" === (tinyMode || mode)) {
24
+ return MobileFirstTemplate;
25
+ }
26
+ return PcTemplate;
27
+ };
28
+ var $constants = {
29
+ FORM_ITEM: "FormItem",
30
+ FORM_CHANGE: "form.change",
31
+ CHECKBOX: $prefix + "Checkbox",
32
+ CHECKBOX_GROUP: "CheckboxGroup"
33
+ };
34
+ var checkboxProps = _extends({}, $props, {
35
+ _constants: {
36
+ type: Object,
37
+ default: function _default() {
38
+ return $constants;
39
+ }
40
+ },
41
+ modelValue: {
42
+ type: [String, Number, Boolean],
43
+ // Tiny新增,因为类型有Boolean类型,所以默认值需要显示设置成 undefined 才可以保持逻辑正确
44
+ default: void 0
45
+ },
46
+ label: {
47
+ type: [String, Number, Boolean],
48
+ default: ""
49
+ },
50
+ indeterminate: Boolean,
51
+ disabled: Boolean,
52
+ checked: Boolean,
53
+ name: String,
54
+ trueLabel: [String, Number],
55
+ falseLabel: [String, Number],
56
+ /*
57
+ * 当indeterminate为真时,为controls提供相关连的checkbox的id,表明元素间的控制关系
58
+ */
59
+ id: String,
60
+ /*
61
+ * 当indeterminate为真时,为controls提供相关连的checkbox的id,表明元素间的控制关系
62
+ */
63
+ controls: {
64
+ type: String,
65
+ default: ""
66
+ },
67
+ border: Boolean,
68
+ size: String,
69
+ text: String,
70
+ customClass: [String, Object, Array],
71
+ validateEvent: {
72
+ type: Boolean,
73
+ default: true
74
+ },
75
+ events: {
76
+ type: Object,
77
+ default: function _default2() {
78
+ return {};
79
+ }
80
+ },
81
+ displayOnly: {
82
+ type: Boolean,
83
+ default: false
84
+ },
85
+ iconPosition: String,
86
+ shape: {
87
+ type: String,
88
+ default: ""
89
+ },
90
+ tabindex: {
91
+ type: String,
92
+ default: "0"
93
+ }
94
+ });
95
+ var Checkbox = defineComponent({
96
+ name: $prefix + "Checkbox",
97
+ props: checkboxProps,
98
+ setup: function setup(props, context) {
99
+ return $setup({
100
+ props,
101
+ context,
102
+ template
103
+ });
104
+ }
105
+ });
106
+ var version = "2.21.0";
107
+ Checkbox.model = {
108
+ prop: "modelValue",
109
+ event: "update:modelValue"
110
+ };
111
+ Checkbox.install = function(Vue) {
112
+ Vue.component(Checkbox.name, Checkbox);
113
+ };
114
+ Checkbox.version = version;
115
+ export {
116
+ Checkbox as default
117
+ };
@@ -0,0 +1,203 @@
1
+ import { renderless, api } from '@opentinyvue/vue-renderless/checkbox/vue';
2
+ import { defineComponent, props, setup } from '@opentinyvue/vue-common';
3
+ import { iconHalfselect, iconCheckedSur, iconCheck } from '@opentinyvue/vue-icon';
4
+
5
+ function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
6
+ var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
7
+ if (render) {
8
+ options.render = render;
9
+ options.staticRenderFns = staticRenderFns;
10
+ options._compiled = true;
11
+ }
12
+ var hook;
13
+ if (injectStyles) {
14
+ hook = injectStyles;
15
+ }
16
+ if (hook) {
17
+ if (options.functional) {
18
+ options._injectStyles = hook;
19
+ var originalRender = options.render;
20
+ options.render = function renderWithStyleInjection(h, context) {
21
+ hook.call(context);
22
+ return originalRender(h, context);
23
+ };
24
+ } else {
25
+ var existing = options.beforeCreate;
26
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
27
+ }
28
+ }
29
+ return {
30
+ exports: scriptExports,
31
+ options
32
+ };
33
+ }
34
+
35
+ var __vue2_script = defineComponent({
36
+ inheritAttrs: false,
37
+ emits: ["update:modelValue", "change", "complete"],
38
+ props: [].concat(props, ["modelValue", "text", "events", "label", "indeterminate", "disabled", "checked", "name", "trueLabel", "falseLabel", "id", "controls", "size", "border", "validateEvent", "customClass", "displayOnly"]),
39
+ components: {
40
+ IconHalfselect: iconHalfselect(),
41
+ IconCheckedSur: iconCheckedSur(),
42
+ IconCheck: iconCheck()
43
+ },
44
+ setup: function setup$1(props2, context) {
45
+ return setup({
46
+ props: props2,
47
+ context,
48
+ renderless,
49
+ api
50
+ });
51
+ }
52
+ });
53
+ var render = function render2() {
54
+ var _vm = this;
55
+ var _h = _vm.$createElement;
56
+ var _c = _vm._self._c || _h;
57
+ return _c("label", _vm._b({
58
+ class: _vm.m("inline-flex sm:items-center text-sm leading-5 cursor-pointer", _vm.state.size !== "mini" ? "sm:text-sm" : "sm:text-xs", {
59
+ "sm:py-2": _vm.state.vertical
60
+ }, _vm.state.isDisplayOnly || _vm.state.isGroupDisplayOnly ? _vm.state.isChecked ? "cursor-default after:content-[';'] after:inline-block last:after:content-['']" : "hidden" : "", _vm.state.showLabel ? "inline-flex" : "", _vm.customClass),
61
+ attrs: {
62
+ "data-tag": "tiny-checkbox",
63
+ "id": _vm.id,
64
+ "tabindex": "-1"
65
+ }
66
+ }, "label", _vm.a(_vm.$attrs, ["class", "style", "onClick"], true), false), [_c("span", {
67
+ class: ["relative w-7 h-7 mr-2 sm:mr-0 sm:p-0", _vm.state.size === "medium" ? "sm:w-6 sm:h-6" : "sm:h-4 sm:w-4", _vm.state.isDisplayOnly || _vm.state.isGroupDisplayOnly ? "hidden" : ""],
68
+ attrs: {
69
+ "role": _vm.indeterminate ? "checkbox" : false,
70
+ "aria-checked": _vm.indeterminate ? "mixed" : false
71
+ }
72
+ }, [_c("span", {
73
+ attrs: {
74
+ "tabindex": "1"
75
+ }
76
+ }, [_c("icon-check", {
77
+ class: _vm.m("w-5 h-5 absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-0", _vm.state.size === "medium" ? "sm:w-6 sm:h-6" : "sm:w-4 sm:h-4", _vm.state.isDisabled ? "[&_path:nth-of-type(2)]:fill-color-icon-disabled [&_path:nth-of-type(1)]:fill-color-bg-3 cursor-not-allowed" : "[&_path:nth-of-type(1)]:fill-color-icon-inverse [&_path:nth-of-type(2)]:fill-color-none-hover"),
78
+ attrs: {
79
+ "data-tag": "icon-check"
80
+ }
81
+ }), _c("icon-halfselect", {
82
+ class: _vm.m("w-5 h-5 absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 transition-all [&_path:nth-of-type(2)]:fill-color-icon-inverse", _vm.indeterminate ? "opacity-100 scale-100 z-10" : "opacity-0 scale-0 z-0", _vm.state.isDisabled ? "[&_path:nth-of-type(1)]:fill-color-brand-disabled cursor-not-allowed" : "[&_path:nth-of-type(1)]:fill-color-brand [&_path:nth-of-type(1)]:shadow-xsm", _vm.state.size === "medium" ? "sm:w-6 sm:h-6" : "sm:w-4 sm:h-4"),
83
+ attrs: {
84
+ "data-tag": "icon-halfselect"
85
+ }
86
+ }), _c("icon-checked-sur", {
87
+ class: _vm.m("w-5 h-5", _vm.state.size === "medium" ? "sm:w-6 sm:h-6" : "sm:w-4 sm:h-4", "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 transition-all [&_path:nth-of-type(2)]:fill-color-icon-inverse", _vm.state.isChecked && !_vm.indeterminate ? "opacity-100 scale-100 z-10" : "opacity-0 scale-0 z-0", _vm.state.isDisabled ? "[&_path:nth-of-type(1)]:fill-color-brand-disabled cursor-not-allowed" : "[&_path:nth-of-type(1)]:fill-color-brand [&_path:nth-of-type(2)]:shadow-xsm"),
88
+ attrs: {
89
+ "data-tag": "icon-checked-sur"
90
+ }
91
+ })], 1), _vm.trueLabel || _vm.falseLabel ? _c("input", {
92
+ directives: [{
93
+ name: "model",
94
+ rawName: "v-model",
95
+ value: _vm.state.model,
96
+ expression: "state.model"
97
+ }],
98
+ staticClass: "absolute left-0 right-0 top-0 bottom-0 w-0 h-0 -z-10 opacity-0",
99
+ attrs: {
100
+ "type": "checkbox",
101
+ "aria-hidden": _vm.indeterminate ? "true" : "false",
102
+ "name": _vm.name,
103
+ "disabled": _vm.state.inputDisabled,
104
+ "true-value": _vm.trueLabel,
105
+ "false-value": _vm.falseLabel
106
+ },
107
+ domProps: {
108
+ "checked": Array.isArray(_vm.state.model) ? _vm._i(_vm.state.model, null) > -1 : _vm._q(_vm.state.model, _vm.trueLabel)
109
+ },
110
+ on: {
111
+ "change": [function($event) {
112
+ var $$a = _vm.state.model, $$el = $event.target, $$c = $$el.checked ? _vm.trueLabel : _vm.falseLabel;
113
+ if (Array.isArray($$a)) {
114
+ var $$v = null, $$i = _vm._i($$a, $$v);
115
+ if ($$el.checked) {
116
+ $$i < 0 && _vm.$set(_vm.state, "model", $$a.concat([$$v]));
117
+ } else {
118
+ $$i > -1 && _vm.$set(_vm.state, "model", $$a.slice(0, $$i).concat($$a.slice($$i + 1)));
119
+ }
120
+ } else {
121
+ _vm.$set(_vm.state, "model", $$c);
122
+ }
123
+ }, function($event) {
124
+ $event.stopPropagation();
125
+ return _vm.handleChange.apply(null, arguments);
126
+ }],
127
+ "focus": function focus($event) {
128
+ _vm.state.focus = true;
129
+ },
130
+ "blur": function blur($event) {
131
+ _vm.state.focus = false;
132
+ },
133
+ "click": function click($event) {
134
+ $event.stopPropagation();
135
+ }
136
+ }
137
+ }) : _c("input", {
138
+ directives: [{
139
+ name: "model",
140
+ rawName: "v-model",
141
+ value: _vm.state.model,
142
+ expression: "state.model"
143
+ }],
144
+ staticClass: "absolute left-0 right-0 top-0 bottom-0 w-0 h-0 -z-10 opacity-0",
145
+ attrs: {
146
+ "type": "checkbox",
147
+ "aria-hidden": _vm.indeterminate ? "true" : "false",
148
+ "disabled": _vm.state.inputDisabled,
149
+ "name": _vm.name
150
+ },
151
+ domProps: {
152
+ "value": _vm.label,
153
+ "checked": Array.isArray(_vm.state.model) ? _vm._i(_vm.state.model, _vm.label) > -1 : _vm.state.model
154
+ },
155
+ on: {
156
+ "change": [function($event) {
157
+ var $$a = _vm.state.model, $$el = $event.target, $$c = $$el.checked ? true : false;
158
+ if (Array.isArray($$a)) {
159
+ var $$v = _vm.label, $$i = _vm._i($$a, $$v);
160
+ if ($$el.checked) {
161
+ $$i < 0 && _vm.$set(_vm.state, "model", $$a.concat([$$v]));
162
+ } else {
163
+ $$i > -1 && _vm.$set(_vm.state, "model", $$a.slice(0, $$i).concat($$a.slice($$i + 1)));
164
+ }
165
+ } else {
166
+ _vm.$set(_vm.state, "model", $$c);
167
+ }
168
+ }, function($event) {
169
+ $event.stopPropagation();
170
+ return _vm.handleChange.apply(null, arguments);
171
+ }],
172
+ "focus": function focus($event) {
173
+ _vm.state.focus = true;
174
+ },
175
+ "blur": function blur($event) {
176
+ _vm.state.focus = false;
177
+ },
178
+ "click": function click($event) {
179
+ $event.stopPropagation();
180
+ }
181
+ }
182
+ })]), _vm.slots.default && _vm.slots.default() || _vm.text || _vm.label ? _c("span", {
183
+ ref: "label",
184
+ class: _vm.m("py-0 pl-0 sm:pl-2 mr-5 flex-1 leading-7 sm:leading-none", _vm.state.isDisabled ? "cursor-not-allowed text-color-text-secondary" : "text-color-text-primary", _vm.state.isDisplayOnly || _vm.state.isGroupDisplayOnly ? "p-0 sm:p-0 m-0 text-color-text-primary cursor-default" : "")
185
+ }, [_vm._t("default", function() {
186
+ return [_vm._v(_vm._s(_vm.text || _vm.label))];
187
+ })], 2) : [_vm.state.isDisplayOnly ? _c("span", {
188
+ staticClass: "text-color-text-primary cursor-default"
189
+ }, [_vm._v(" " + _vm._s(_vm.state.displayLabel))]) : _vm._e()]], 2);
190
+ };
191
+ var staticRenderFns = [];
192
+ var __cssModules = {};
193
+ var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles);
194
+ function __vue2_injectStyles(context) {
195
+ for (var o in __cssModules) {
196
+ this[o] = __cssModules[o];
197
+ }
198
+ }
199
+ var mobileFirst = /* @__PURE__ */ function() {
200
+ return __component__.exports;
201
+ }();
202
+
203
+ export { mobileFirst as default };
package/lib/mobile.js ADDED
@@ -0,0 +1,175 @@
1
+ import { renderless, api } from '@opentinyvue/vue-renderless/checkbox/vue';
2
+ import { defineComponent, props, setup } from '@opentinyvue/vue-common';
3
+ import '@opentinyvue/vue-theme-mobile/checkbox/index.css';
4
+
5
+ function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
6
+ var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
7
+ if (render) {
8
+ options.render = render;
9
+ options.staticRenderFns = staticRenderFns;
10
+ options._compiled = true;
11
+ }
12
+ var hook;
13
+ if (injectStyles) {
14
+ hook = injectStyles;
15
+ }
16
+ if (hook) {
17
+ if (options.functional) {
18
+ options._injectStyles = hook;
19
+ var originalRender = options.render;
20
+ options.render = function renderWithStyleInjection(h, context) {
21
+ hook.call(context);
22
+ return originalRender(h, context);
23
+ };
24
+ } else {
25
+ var existing = options.beforeCreate;
26
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
27
+ }
28
+ }
29
+ return {
30
+ exports: scriptExports,
31
+ options
32
+ };
33
+ }
34
+
35
+ var __vue2_script = defineComponent({
36
+ props: [].concat(props, ["modelValue", "text", "events", "label", "indeterminate", "disabled", "checked", "name", "trueLabel", "falseLabel", "id", "iconPosition"]),
37
+ emits: ["update:modelValue", "change", "complete", "click"],
38
+ setup: function setup$1(props2, context) {
39
+ return setup({
40
+ props: props2,
41
+ context,
42
+ renderless,
43
+ api
44
+ });
45
+ }
46
+ });
47
+ var render = function render2() {
48
+ var _vm = this;
49
+ var _h = _vm.$createElement;
50
+ var _c = _vm._self._c || _h;
51
+ return _c("label", {
52
+ staticClass: "tiny-mobile-checkbox",
53
+ class: {
54
+ "is-disabled": _vm.state.isDisabled,
55
+ "is-checked": _vm.state.isChecked,
56
+ "is-indeterminate": _vm.indeterminate,
57
+ "is-focus": _vm.state.focus,
58
+ "icon-position-top": _vm.state.iconPosition === "top"
59
+ },
60
+ attrs: {
61
+ "id": _vm.id
62
+ }
63
+ }, [_c("span", {
64
+ staticClass: "tiny-mobile-checkbox__input",
65
+ attrs: {
66
+ "tabindex": _vm.indeterminate ? 0 : false,
67
+ "role": _vm.indeterminate ? "checkbox" : false,
68
+ "aria-checked": _vm.indeterminate ? "mixed" : false
69
+ }
70
+ }, [_c("span", {
71
+ staticClass: "tiny-mobile-checkbox__inner"
72
+ }), _vm.trueLabel || _vm.falseLabel ? _c("input", {
73
+ directives: [{
74
+ name: "model",
75
+ rawName: "v-model",
76
+ value: _vm.state.model,
77
+ expression: "state.model"
78
+ }],
79
+ staticClass: "tiny-mobile-checkbox__original",
80
+ attrs: {
81
+ "type": "checkbox",
82
+ "aria-hidden": _vm.indeterminate ? "true" : "false",
83
+ "name": _vm.name,
84
+ "disabled": _vm.state.isDisabled,
85
+ "true-value": _vm.trueLabel,
86
+ "false-value": _vm.falseLabel
87
+ },
88
+ domProps: {
89
+ "checked": Array.isArray(_vm.state.model) ? _vm._i(_vm.state.model, null) > -1 : _vm._q(_vm.state.model, _vm.trueLabel)
90
+ },
91
+ on: {
92
+ "change": [function($event) {
93
+ var $$a = _vm.state.model, $$el = $event.target, $$c = $$el.checked ? _vm.trueLabel : _vm.falseLabel;
94
+ if (Array.isArray($$a)) {
95
+ var $$v = null, $$i = _vm._i($$a, $$v);
96
+ if ($$el.checked) {
97
+ $$i < 0 && _vm.$set(_vm.state, "model", $$a.concat([$$v]));
98
+ } else {
99
+ $$i > -1 && _vm.$set(_vm.state, "model", $$a.slice(0, $$i).concat($$a.slice($$i + 1)));
100
+ }
101
+ } else {
102
+ _vm.$set(_vm.state, "model", $$c);
103
+ }
104
+ }, function($event) {
105
+ $event.stopPropagation();
106
+ return _vm.handleChange.apply(null, arguments);
107
+ }],
108
+ "focus": function focus($event) {
109
+ _vm.state.focus = true;
110
+ },
111
+ "blur": function blur($event) {
112
+ _vm.state.focus = false;
113
+ }
114
+ }
115
+ }) : _c("input", {
116
+ directives: [{
117
+ name: "model",
118
+ rawName: "v-model",
119
+ value: _vm.state.model,
120
+ expression: "state.model"
121
+ }],
122
+ staticClass: "tiny-mobile-checkbox__original",
123
+ attrs: {
124
+ "type": "checkbox",
125
+ "aria-hidden": _vm.indeterminate ? "true" : "false",
126
+ "disabled": _vm.state.isDisabled,
127
+ "name": _vm.name
128
+ },
129
+ domProps: {
130
+ "value": _vm.label,
131
+ "checked": Array.isArray(_vm.state.model) ? _vm._i(_vm.state.model, _vm.label) > -1 : _vm.state.model
132
+ },
133
+ on: {
134
+ "change": [function($event) {
135
+ var $$a = _vm.state.model, $$el = $event.target, $$c = $$el.checked ? true : false;
136
+ if (Array.isArray($$a)) {
137
+ var $$v = _vm.label, $$i = _vm._i($$a, $$v);
138
+ if ($$el.checked) {
139
+ $$i < 0 && _vm.$set(_vm.state, "model", $$a.concat([$$v]));
140
+ } else {
141
+ $$i > -1 && _vm.$set(_vm.state, "model", $$a.slice(0, $$i).concat($$a.slice($$i + 1)));
142
+ }
143
+ } else {
144
+ _vm.$set(_vm.state, "model", $$c);
145
+ }
146
+ }, function($event) {
147
+ $event.stopPropagation();
148
+ return _vm.handleChange.apply(null, arguments);
149
+ }],
150
+ "focus": function focus($event) {
151
+ _vm.state.focus = true;
152
+ },
153
+ "blur": function blur($event) {
154
+ _vm.state.focus = false;
155
+ }
156
+ }
157
+ })]), _vm.slots.default && _vm.slots.default() || _vm.state.isShowText ? _c("span", {
158
+ staticClass: "tiny-mobile-checkbox__label"
159
+ }, [_vm._t("default", function() {
160
+ return [_vm._v(_vm._s(_vm.state.showText))];
161
+ })], 2) : _vm._e()]);
162
+ };
163
+ var staticRenderFns = [];
164
+ var __cssModules = {};
165
+ var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles);
166
+ function __vue2_injectStyles(context) {
167
+ for (var o in __cssModules) {
168
+ this[o] = __cssModules[o];
169
+ }
170
+ }
171
+ var mobile = /* @__PURE__ */ function() {
172
+ return __component__.exports;
173
+ }();
174
+
175
+ export { mobile as default };
package/lib/pc.js ADDED
@@ -0,0 +1,216 @@
1
+ import { renderless, api } from '@opentinyvue/vue-renderless/checkbox/vue';
2
+ import { defineComponent, props, setup } from '@opentinyvue/vue-common';
3
+ import '@opentinyvue/vue-theme/checkbox/index.css';
4
+ import { iconHalfselect, iconCheckedSur, iconCheck } from '@opentinyvue/vue-icon';
5
+ import { AutoTip } from '@opentinyvue/vue-directive';
6
+
7
+ function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
8
+ var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
9
+ if (render) {
10
+ options.render = render;
11
+ options.staticRenderFns = staticRenderFns;
12
+ options._compiled = true;
13
+ }
14
+ var hook;
15
+ if (injectStyles) {
16
+ hook = injectStyles;
17
+ }
18
+ if (hook) {
19
+ if (options.functional) {
20
+ options._injectStyles = hook;
21
+ var originalRender = options.render;
22
+ options.render = function renderWithStyleInjection(h, context) {
23
+ hook.call(context);
24
+ return originalRender(h, context);
25
+ };
26
+ } else {
27
+ var existing = options.beforeCreate;
28
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
29
+ }
30
+ }
31
+ return {
32
+ exports: scriptExports,
33
+ options
34
+ };
35
+ }
36
+
37
+ var __vue2_script = defineComponent({
38
+ // tiny 新增。 renderless中,没有emit('click')的地方。 此处勿声明,否则会造成丢失click事件。
39
+ emits: ["update:modelValue", "change", "complete"],
40
+ directives: {
41
+ AutoTip
42
+ },
43
+ props: [].concat(props, ["modelValue", "text", "events", "label", "indeterminate", "disabled", "checked", "name", "trueLabel", "falseLabel", "id", "controls", "size", "border", "validateEvent", "displayOnly", "shape", "tabindex"]),
44
+ components: {
45
+ IconHalfselect: iconHalfselect(),
46
+ IconCheckedSur: iconCheckedSur(),
47
+ IconCheck: iconCheck()
48
+ },
49
+ setup: function setup$1(props2, context) {
50
+ return setup({
51
+ props: props2,
52
+ context,
53
+ renderless,
54
+ api
55
+ });
56
+ }
57
+ });
58
+ var render = function render2() {
59
+ var _vm = this;
60
+ var _h = _vm.$createElement;
61
+ var _c = _vm._self._c || _h;
62
+ return _c("label", _vm._b({
63
+ staticClass: "tiny-checkbox",
64
+ class: [_vm.border && _vm.state.checkboxSize ? "tiny-checkbox--" + _vm.state.checkboxSize : "", {
65
+ "is-disabled": _vm.state.isDisabled || _vm.state.isDisplayOnly
66
+ }, {
67
+ "is-bordered": _vm.border
68
+ }, {
69
+ "is-checked": _vm.state.isChecked
70
+ }, {
71
+ "is-group-display-only": _vm.state.isGroupDisplayOnly
72
+ }, {
73
+ "is-display-only": _vm.state.isDisplayOnly
74
+ }, {
75
+ "is-filter": _vm.state.shape === "filter"
76
+ }],
77
+ attrs: {
78
+ "id": _vm.id,
79
+ "tabindex": "-1"
80
+ }
81
+ }, "label", _vm.a(_vm.$attrs, ["class", "style", "onClick"], true), false), [_c("span", {
82
+ staticClass: "tiny-checkbox__input",
83
+ class: {
84
+ "is-disabled": _vm.state.isDisabled || _vm.state.isDisplayOnly,
85
+ "is-checked": _vm.state.isChecked,
86
+ "is-indeterminate": _vm.indeterminate,
87
+ "is-focus": _vm.state.focus
88
+ },
89
+ attrs: {
90
+ "role": _vm.indeterminate ? "checkbox" : void 0,
91
+ "aria-checked": _vm.indeterminate ? "mixed" : false
92
+ }
93
+ }, [_vm.trueLabel || _vm.falseLabel ? _c("input", {
94
+ directives: [{
95
+ name: "model",
96
+ rawName: "v-model",
97
+ value: _vm.state.model,
98
+ expression: "state.model"
99
+ }],
100
+ staticClass: "tiny-checkbox__original",
101
+ attrs: {
102
+ "type": "checkbox",
103
+ "tabindex": _vm.tabindex,
104
+ "aria-hidden": _vm.indeterminate ? "true" : "false",
105
+ "name": _vm.name,
106
+ "disabled": _vm.state.isDisabled || _vm.state.isDisplayOnly,
107
+ "true-value": _vm.trueLabel,
108
+ "false-value": _vm.falseLabel
109
+ },
110
+ domProps: {
111
+ "checked": Array.isArray(_vm.state.model) ? _vm._i(_vm.state.model, null) > -1 : _vm._q(_vm.state.model, _vm.trueLabel)
112
+ },
113
+ on: {
114
+ "change": [function($event) {
115
+ var $$a = _vm.state.model, $$el = $event.target, $$c = $$el.checked ? _vm.trueLabel : _vm.falseLabel;
116
+ if (Array.isArray($$a)) {
117
+ var $$v = null, $$i = _vm._i($$a, $$v);
118
+ if ($$el.checked) {
119
+ $$i < 0 && _vm.$set(_vm.state, "model", $$a.concat([$$v]));
120
+ } else {
121
+ $$i > -1 && _vm.$set(_vm.state, "model", $$a.slice(0, $$i).concat($$a.slice($$i + 1)));
122
+ }
123
+ } else {
124
+ _vm.$set(_vm.state, "model", $$c);
125
+ }
126
+ }, function($event) {
127
+ $event.stopPropagation();
128
+ return _vm.handleChange.apply(null, arguments);
129
+ }],
130
+ "focus": function focus($event) {
131
+ _vm.state.focus = true;
132
+ },
133
+ "blur": function blur($event) {
134
+ _vm.state.focus = false;
135
+ },
136
+ "click": function click($event) {
137
+ $event.stopPropagation();
138
+ }
139
+ }
140
+ }) : _c("input", {
141
+ directives: [{
142
+ name: "model",
143
+ rawName: "v-model",
144
+ value: _vm.state.model,
145
+ expression: "state.model"
146
+ }],
147
+ staticClass: "tiny-checkbox__original",
148
+ attrs: {
149
+ "type": "checkbox",
150
+ "tabindex": _vm.tabindex,
151
+ "aria-hidden": _vm.indeterminate ? "true" : "false",
152
+ "disabled": _vm.state.isDisabled || _vm.state.isDisplayOnly,
153
+ "name": _vm.name
154
+ },
155
+ domProps: {
156
+ "value": _vm.label,
157
+ "checked": Array.isArray(_vm.state.model) ? _vm._i(_vm.state.model, _vm.label) > -1 : _vm.state.model
158
+ },
159
+ on: {
160
+ "change": [function($event) {
161
+ var $$a = _vm.state.model, $$el = $event.target, $$c = $$el.checked ? true : false;
162
+ if (Array.isArray($$a)) {
163
+ var $$v = _vm.label, $$i = _vm._i($$a, $$v);
164
+ if ($$el.checked) {
165
+ $$i < 0 && _vm.$set(_vm.state, "model", $$a.concat([$$v]));
166
+ } else {
167
+ $$i > -1 && _vm.$set(_vm.state, "model", $$a.slice(0, $$i).concat($$a.slice($$i + 1)));
168
+ }
169
+ } else {
170
+ _vm.$set(_vm.state, "model", $$c);
171
+ }
172
+ }, function($event) {
173
+ $event.stopPropagation();
174
+ return _vm.handleChange.apply(null, arguments);
175
+ }],
176
+ "focus": function focus($event) {
177
+ _vm.state.focus = true;
178
+ },
179
+ "blur": function blur($event) {
180
+ _vm.state.focus = false;
181
+ },
182
+ "click": function click($event) {
183
+ $event.stopPropagation();
184
+ }
185
+ }
186
+ }), _c("span", {
187
+ staticClass: "tiny-checkbox__inner"
188
+ }, [_vm.indeterminate && _vm.state.shape !== "filter" ? _c("icon-halfselect", {
189
+ staticClass: "tiny-svg-size icon-halfselect"
190
+ }) : _vm.state.isChecked ? _c("icon-checked-sur", {
191
+ staticClass: "tiny-svg-size icon-checked-sur"
192
+ }) : _c("icon-check", {
193
+ staticClass: "tiny-svg-size icon-check"
194
+ })], 1)]), _vm.slots.default && _vm.slots.default() || _vm.state.isShowText ? _c("span", {
195
+ directives: [{
196
+ name: "auto-tip",
197
+ rawName: "v-auto-tip"
198
+ }],
199
+ staticClass: "tiny-checkbox__label tiny-checkbox-display-only"
200
+ }, [_vm._t("default", function() {
201
+ return [_vm._v(_vm._s(_vm.state.showText))];
202
+ })], 2) : _vm._e()]);
203
+ };
204
+ var staticRenderFns = [];
205
+ var __cssModules = {};
206
+ var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles);
207
+ function __vue2_injectStyles(context) {
208
+ for (var o in __cssModules) {
209
+ this[o] = __cssModules[o];
210
+ }
211
+ }
212
+ var pc = /* @__PURE__ */ function() {
213
+ return __component__.exports;
214
+ }();
215
+
216
+ export { pc as default };
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@opentinyvue/vue-checkbox",
3
+ "version": "2.21.0",
4
+ "description": "",
5
+ "main": "./lib/index.js",
6
+ "module": "./lib/index.js",
7
+ "sideEffects": false,
8
+ "type": "module",
9
+ "dependencies": {
10
+ "@opentinyvue/vue-common": "~2.21.0",
11
+ "@opentinyvue/vue-renderless": "~3.21.0",
12
+ "@opentinyvue/vue-directive": "~2.21.0",
13
+ "@opentinyvue/vue-icon": "~2.21.0",
14
+ "@opentinyvue/vue-theme-mobile": "~3.21.0",
15
+ "@opentinyvue/vue-theme": "~3.21.0"
16
+ },
17
+ "license": "MIT",
18
+ "types": "index.d.ts",
19
+ "scripts": {
20
+ "build": "pnpm -w build:ui $npm_package_name",
21
+ "//postversion": "pnpm build"
22
+ }
23
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,71 @@
1
+ import type { PropType } from '@opentinyvue/vue-common';
2
+ export type IconPosition = 'center' | 'top';
3
+ export declare const $constants: {
4
+ FORM_ITEM: string;
5
+ FORM_CHANGE: string;
6
+ CHECKBOX: string;
7
+ CHECKBOX_GROUP: string;
8
+ };
9
+ export declare const checkboxProps: {
10
+ _constants: {
11
+ type: ObjectConstructor;
12
+ default: () => {
13
+ FORM_ITEM: string;
14
+ FORM_CHANGE: string;
15
+ CHECKBOX: string;
16
+ CHECKBOX_GROUP: string;
17
+ };
18
+ };
19
+ modelValue: {
20
+ type: (StringConstructor | BooleanConstructor | NumberConstructor)[];
21
+ default: undefined;
22
+ };
23
+ label: {
24
+ type: (StringConstructor | BooleanConstructor | NumberConstructor)[];
25
+ default: string;
26
+ };
27
+ indeterminate: BooleanConstructor;
28
+ disabled: BooleanConstructor;
29
+ checked: BooleanConstructor;
30
+ name: StringConstructor;
31
+ trueLabel: (StringConstructor | NumberConstructor)[];
32
+ falseLabel: (StringConstructor | NumberConstructor)[];
33
+ id: StringConstructor;
34
+ controls: {
35
+ type: StringConstructor;
36
+ default: string;
37
+ };
38
+ border: BooleanConstructor;
39
+ size: StringConstructor;
40
+ text: StringConstructor;
41
+ customClass: (StringConstructor | ArrayConstructor | ObjectConstructor)[];
42
+ validateEvent: {
43
+ type: BooleanConstructor;
44
+ default: boolean;
45
+ };
46
+ events: {
47
+ type: ObjectConstructor;
48
+ default: () => {};
49
+ };
50
+ displayOnly: {
51
+ type: BooleanConstructor;
52
+ default: boolean;
53
+ };
54
+ iconPosition: PropType<IconPosition>;
55
+ shape: {
56
+ type: StringConstructor;
57
+ default: string;
58
+ };
59
+ tabindex: {
60
+ type: StringConstructor;
61
+ default: string;
62
+ };
63
+ tiny_mode: StringConstructor;
64
+ tiny_mode_root: BooleanConstructor;
65
+ tiny_template: (ObjectConstructor | FunctionConstructor)[];
66
+ tiny_renderless: FunctionConstructor;
67
+ tiny_theme: StringConstructor;
68
+ tiny_chart_theme: ObjectConstructor;
69
+ };
70
+ declare const _default: any;
71
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;