@opentiny/tiny-robot 0.3.0-alpha.9 → 0.3.0-rc.1

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.
@@ -0,0 +1,83 @@
1
+ import { defineComponent as C, mergeModels as O, useModel as f, ref as S, onUnmounted as D, computed as _, provide as m, watchEffect as w, watch as g, renderSlot as b, inject as u, readonly as v } from "vue";
2
+ const k = "data-tr-theme", A = "data-tr-color-mode", y = Symbol("theme"), E = Symbol("colorMode"), T = Symbol("resolvedColorMode"), p = Symbol("systemColorMode"), i = /* @__PURE__ */ C({
3
+ __name: "index",
4
+ props: /* @__PURE__ */ O({
5
+ colorMode: {},
6
+ targetElement: { default: "html" },
7
+ theme: {},
8
+ storage: {},
9
+ storageKey: { default: "tiny-robot-theme-data" }
10
+ }, {
11
+ theme: { default: "" },
12
+ themeModifiers: {},
13
+ colorMode: {
14
+ default: "auto",
15
+ validator: (o) => ["light", "dark", "auto"].includes(o)
16
+ },
17
+ colorModeModifiers: {}
18
+ }),
19
+ emits: ["update:theme", "update:colorMode"],
20
+ setup(o) {
21
+ const t = o, r = () => {
22
+ if (!t.storage) return {};
23
+ let e = {};
24
+ try {
25
+ e = JSON.parse(t.storage.getItem(t.storageKey) || "{}");
26
+ } catch {
27
+ }
28
+ return e;
29
+ }, d = (e) => {
30
+ if (!t.storage) return;
31
+ const h = { ...r(), ...e };
32
+ t.storage.setItem(t.storageKey, JSON.stringify(h));
33
+ }, n = f(o, "theme"), a = f(o, "colorMode");
34
+ if (t.storage) {
35
+ const e = r();
36
+ typeof e.theme == "string" && (n.value = e.theme), (e.colorMode === "auto" || e.colorMode === "light" || e.colorMode === "dark") && (a.value = e.colorMode);
37
+ }
38
+ const s = S("light");
39
+ if (typeof window < "u") {
40
+ const e = window.matchMedia("(prefers-color-scheme: dark)");
41
+ s.value = e.matches ? "dark" : "light";
42
+ const c = (h) => {
43
+ s.value = h.matches ? "dark" : "light";
44
+ };
45
+ e.addEventListener("change", c), D(() => {
46
+ e.removeEventListener("change", c);
47
+ });
48
+ }
49
+ const l = _(() => a.value === "auto" ? s.value : a.value);
50
+ return m(y, n), m(E, a), m(T, l), m(p, s), w(
51
+ () => {
52
+ if (typeof document > "u") return;
53
+ const e = document.querySelector(t.targetElement);
54
+ e && (e.setAttribute(k, n.value), e.setAttribute(A, l.value));
55
+ },
56
+ { flush: "post" }
57
+ ), g(n, (e) => {
58
+ d({ theme: e });
59
+ }), g(a, (e) => {
60
+ d({ colorMode: e });
61
+ }), (e, c) => b(e.$slots, "default");
62
+ }
63
+ }), M = "Theme context not available, cannot set theme data. Consider using ThemeProvider to wrap your app.", N = () => {
64
+ const o = u(y), t = u(E), r = u(T), d = u(p), n = (l) => o ? (o.value = l, !0) : (console.warn(M), !1), a = () => !t || !r ? (console.warn(M), !1) : (t.value = r.value === "light" ? "dark" : "light", !0), s = (l) => t ? (t.value = l, !0) : (console.warn(M), !1);
65
+ return {
66
+ theme: o,
67
+ colorMode: t,
68
+ resolvedColorMode: r ? v(r) : void 0,
69
+ systemColorMode: d ? v(d) : void 0,
70
+ setTheme: n,
71
+ toggleColorMode: a,
72
+ setColorMode: s
73
+ };
74
+ };
75
+ i.name = "TrThemeProvider";
76
+ const R = function(o) {
77
+ o.component(i.name, i);
78
+ };
79
+ i.install = R;
80
+ export {
81
+ i as default,
82
+ N as useTheme
83
+ };
@@ -1,12 +1,12 @@
1
- import { d } from "./index2.js";
2
- import { computed as f, Fragment as v, ref as h, watch as p } from "vue";
3
- function E(l, i) {
1
+ import { b as v } from "./index2.js";
2
+ import { computed as f, Fragment as d, ref as h, watch as p } from "vue";
3
+ function b(l, i) {
4
4
  const u = f(() => {
5
5
  const t = (l == null ? void 0 : l()) || [];
6
6
  let o = 0;
7
7
  const s = (e) => typeof e == "symbol" || e == null ? e : `fg${o}-${e}`;
8
8
  return t.map((e) => {
9
- if (e.type === v && Array.isArray(e.children)) {
9
+ if (e.type === d && Array.isArray(e.children)) {
10
10
  for (const r of e.children)
11
11
  r && typeof r == "object" && "key" in r && (r.key = s(r.key));
12
12
  return o++, e.children;
@@ -14,7 +14,7 @@ function E(l, i) {
14
14
  return e;
15
15
  }).flat();
16
16
  }), c = f(() => i ? u.value.length : 1), m = f(() => u.value.slice(0, c.value)), n = h([]), a = (t, o) => {
17
- const s = d(t);
17
+ const s = v(t);
18
18
  s instanceof Element && (n.value[o] = s);
19
19
  };
20
20
  return p(
@@ -32,5 +32,5 @@ function E(l, i) {
32
32
  };
33
33
  }
34
34
  export {
35
- E as u
35
+ b as u
36
36
  };
package/dist/utils.js CHANGED
@@ -1,8 +1,14 @@
1
- function n(t) {
1
+ import { i } from "./index2.js";
2
+ function e(t) {
2
3
  if (typeof t == "number") return `${t}px`;
3
4
  const r = t == null ? void 0 : t.trim();
4
5
  return r ? /^-?\d+(\.\d+)?$/.test(r) ? `${r}px` : r : "0px";
5
6
  }
7
+ let n = null;
8
+ function s() {
9
+ return n || (n = i()), { x: n.x, y: n.y };
10
+ }
6
11
  export {
7
- n as t
12
+ e as t,
13
+ s as u
8
14
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentiny/tiny-robot",
3
- "version": "0.3.0-alpha.9",
3
+ "version": "0.3.0-rc.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -20,17 +20,13 @@
20
20
  "vue": "^3.3.11"
21
21
  },
22
22
  "dependencies": {
23
- "@opentiny/tiny-robot-svgs": "0.3.0-alpha.9",
24
- "@opentiny/vue": "^3.21.0",
25
- "@opentiny/vue-button": "^3.21.0",
26
- "@opentiny/vue-icon": "^3.22.0",
27
- "@opentiny/vue-input": "^3.21.0",
28
- "@opentiny/vue-tooltip": "^3.22.0",
23
+ "@opentiny/tiny-robot-svgs": "0.3.0-rc.1",
24
+ "@opentiny/vue": "^3.20.0",
29
25
  "@vueuse/core": "^13.1.0",
26
+ "dompurify": "^3.2.6",
30
27
  "markdown-it": "^14.1.0"
31
28
  },
32
29
  "devDependencies": {
33
- "@opentiny/vue-vite-import": "^1.3.0",
34
30
  "@types/dom-speech-recognition": "^0.0.6",
35
31
  "@types/lodash-es": "^4.17.12",
36
32
  "@types/markdown-it": "^14.1.2",
@@ -44,5 +40,5 @@
44
40
  "vue": "^3.3.11",
45
41
  "vue-tsc": "^2.2.8"
46
42
  },
47
- "gitHead": "e712c09e6a218b895f64ca284e2b2c2731e56707"
43
+ "gitHead": "b13a1f0beb7148d219a590f00521246dfcc69a55"
48
44
  }
package/dist/close.js DELETED
@@ -1,29 +0,0 @@
1
- import { s as o } from "./index7.js";
2
- import { createElementBlock as n, openBlock as r, createElementVNode as t } from "vue";
3
- var c = {
4
- viewBox: "0 0 16 16",
5
- xmlns: "http://www.w3.org/2000/svg"
6
- }, a = /* @__PURE__ */ t(
7
- "path",
8
- {
9
- d: "M12.49 3.3a.5.5 0 0 1 .05.62L8.58 7.89l3.91 3.88c.21.19.23.48.05.71-.17.19-.49.24-.71.06L7.88 8.58 4 12.49c-.18.17-.5.18-.68.01a.496.496 0 0 1-.08-.67l3.93-3.94L3.29 4a.524.524 0 0 1 .04-.71c.17-.14.42-.16.58-.05l3.97 3.93 3.9-3.87c.18-.22.51-.22.71 0Z",
10
- "fill-rule": "evenodd"
11
- },
12
- null,
13
- -1
14
- /* HOISTED */
15
- ), l = [a];
16
- function i(e, d) {
17
- return r(), n("svg", c, [].concat(l));
18
- }
19
- var s = {
20
- render: i
21
- }, _ = function() {
22
- return o({
23
- name: "IconClose",
24
- component: s
25
- })();
26
- };
27
- export {
28
- _ as i
29
- };
package/dist/index4.js DELETED
@@ -1,315 +0,0 @@
1
- import { A as B, s as C, d as k, a as _, p as O, b as $, c as A, f as j } from "./index7.js";
2
- import { createElementBlock as w, openBlock as f, createElementVNode as r, resolveComponent as D, mergeProps as I, createBlock as h, createCommentVNode as T, renderSlot as E, resolveDynamicComponent as L, normalizeClass as M, toDisplayString as U } from "vue";
3
- const z = ({ emit: e, props: t, state: n, designConfig: o }) => (d) => {
4
- var s, l;
5
- const i = B.filterUrl(t.href), u = 1e3;
6
- let a = u;
7
- t.resetTime !== u ? a = t.resetTime : a = (l = (s = o == null ? void 0 : o.props) == null ? void 0 : s.resetTime) != null ? l : t.resetTime, i ? location.href = i : t.nativeType === "button" && a > 0 && (n.disabled = !0, n.timer = window.setTimeout(() => {
8
- n.disabled = !1;
9
- }, a)), e("click", d);
10
- }, F = (e) => () => clearTimeout(e.timer), N = ["state", "handleClick"], G = (e, { computed: t, onBeforeUnmount: n, reactive: o, watch: d, inject: s }, { emit: l, parent: i, designConfig: u }) => {
11
- i.tinyForm = i.tinyForm || s("form", null);
12
- const a = o({
13
- timer: 0,
14
- disabled: e.disabled,
15
- plain: t(() => e.plain || (i.buttonGroup || {}).plain),
16
- round: t(() => {
17
- var c, v, g;
18
- return (g = (v = e.round) != null ? v : (c = u == null ? void 0 : u.props) == null ? void 0 : c.round) != null ? g : !1;
19
- }),
20
- formDisabled: t(() => (i.tinyForm || {}).disabled),
21
- buttonDisabled: t(
22
- () => e.disabled || a.disabled || (i.buttonGroup || {}).disabled || a.formDisabled
23
- )
24
- });
25
- d(
26
- () => e.disabled,
27
- (c) => {
28
- a.disabled = c;
29
- },
30
- { immediate: !0 }
31
- );
32
- const b = {
33
- state: a,
34
- clearTimer: F(a),
35
- handleClick: z({ emit: l, props: e, state: a, designConfig: u })
36
- };
37
- return n(b.clearTimer), b;
38
- };
39
- var H = {
40
- xmlns: "http://www.w3.org/2000/svg",
41
- viewBox: "0 0 32 32"
42
- }, V = /* @__PURE__ */ r(
43
- "defs",
44
- {
45
- fill: "none"
46
- },
47
- [/* @__PURE__ */ r("linearGradient", {
48
- id: "loading-shadow_svg__a",
49
- x1: "-1285.88",
50
- y1: "25.63",
51
- x2: "-1286.89",
52
- y2: "25.13",
53
- gradientTransform: "matrix(29.6 0 0 29.6 38096.4 -732.8)",
54
- gradientUnits: "userSpaceOnUse"
55
- }, [/* @__PURE__ */ r("stop", {
56
- offset: "0",
57
- "stop-color": "#191919",
58
- "stop-opacity": "0"
59
- }), /* @__PURE__ */ r("stop", {
60
- offset: "1",
61
- "stop-color": "#191919"
62
- })])],
63
- -1
64
- /* HOISTED */
65
- ), P = /* @__PURE__ */ r(
66
- "mask",
67
- {
68
- fill: "none",
69
- id: "loading-shadow_svg__b",
70
- "mask-type": "alpha",
71
- maskUnits: "userSpaceOnUse",
72
- x: "0",
73
- y: "0"
74
- },
75
- [/* @__PURE__ */ r("path", {
76
- fill: "url(#loading-shadow_svg__a)",
77
- d: "M16 1.2c1 0 1.8.8 1.8 1.8S17 4.8 16 4.8C9.8 4.8 4.8 9.8 4.8 16s5 11.2 11.2 11.2 11.2-5 11.2-11.2c0-1 .8-1.8 1.8-1.8s1.8.8 1.8 1.8c0 8.2-6.6 14.8-14.8 14.8S1.2 24.2 1.2 16 7.8 1.2 16 1.2Z"
78
- }, [/* @__PURE__ */ r("animateTransform", {
79
- attributeName: "transform",
80
- attributeType: "XML",
81
- type: "rotate",
82
- from: "0 16 16",
83
- to: "360 16 16",
84
- dur: "1s",
85
- repeatCount: "indefinite"
86
- })])],
87
- -1
88
- /* HOISTED */
89
- ), Z = /* @__PURE__ */ r(
90
- "g",
91
- {
92
- mask: "url(#loading-shadow_svg__b)"
93
- },
94
- [/* @__PURE__ */ r("path", {
95
- d: "M-.1 32H32V-.11H-.1V32Z",
96
- "fill-rule": "evenodd"
97
- })],
98
- -1
99
- /* HOISTED */
100
- ), R = [V, P, Z];
101
- function X(e, t) {
102
- return f(), w("svg", H, [].concat(R));
103
- }
104
- var Y = {
105
- render: X
106
- }, q = function() {
107
- return C({
108
- name: "IconLoadingShadow",
109
- component: Y
110
- })();
111
- };
112
- function J(e, t) {
113
- var n = typeof Symbol < "u" && e[Symbol.iterator] || e["@@iterator"];
114
- if (n) return (n = n.call(e)).next.bind(n);
115
- if (Array.isArray(e) || (n = K(e)) || t) {
116
- n && (e = n);
117
- var o = 0;
118
- return function() {
119
- return o >= e.length ? { done: !0 } : { done: !1, value: e[o++] };
120
- };
121
- }
122
- throw new TypeError(`Invalid attempt to iterate non-iterable instance.
123
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
124
- }
125
- function K(e, t) {
126
- if (e) {
127
- if (typeof e == "string") return S(e, t);
128
- var n = {}.toString.call(e).slice(8, -1);
129
- return n === "Object" && e.constructor && (n = e.constructor.name), n === "Map" || n === "Set" ? Array.from(e) : n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? S(e, t) : void 0;
130
- }
131
- }
132
- function S(e, t) {
133
- (t == null || t > e.length) && (t = e.length);
134
- for (var n = 0, o = Array(t); n < t; n++) o[n] = e[n];
135
- return o;
136
- }
137
- var Q = function(t, n) {
138
- for (var o = t.__vccOpts || t, d = J(n), s; !(s = d()).done; ) {
139
- var l = s.value, i = l[0], u = l[1];
140
- o[i] = u;
141
- }
142
- return o;
143
- }, W = k({
144
- emits: ["click"],
145
- props: [].concat(O, ["type", "text", "size", "icon", "resetTime", "nativeType", "loading", "disabled", "plain", "autofocus", "round", "circle", "tabindex", "customClass", "ghost", "customStyle"]),
146
- components: {
147
- IconLoading: q()
148
- },
149
- setup: function(t, n) {
150
- return _({
151
- props: t,
152
- context: n,
153
- renderless: G,
154
- api: N
155
- });
156
- }
157
- }), x = ["disabled", "autofocus", "type", "tabindex"];
158
- function ee(e, t, n, o, d, s) {
159
- var l = D("icon-loading");
160
- return f(), w("button", I({
161
- class: ["tiny-button", [e.type ? "tiny-button--" + e.type : "", e.size ? "tiny-button--" + e.size : "", {
162
- "is-disabled": e.state.buttonDisabled,
163
- "is-loading": e.loading,
164
- "is-plain": e.state.plain,
165
- "is-ghost": e.ghost,
166
- "is-round": e.state.round,
167
- "is-circle": e.circle,
168
- "is-icon": e.icon && !e.loading && (e.text || e.slots.default),
169
- "is-only-icon": e.icon && !e.loading && !(e.text || e.slots.default)
170
- }]],
171
- onClick: t[0] || (t[0] = function() {
172
- return e.handleClick && e.handleClick.apply(e, arguments);
173
- }),
174
- disabled: e.state.buttonDisabled || e.loading,
175
- autofocus: e.autofocus,
176
- type: e.nativeType,
177
- style: e.customStyle,
178
- tabindex: e.tabindex
179
- }, e.a(e.$attrs, ["class", "style", "title", "id"], !0)), [e.loading ? (f(), h(l, {
180
- key: 0,
181
- class: "tiny-icon-loading tiny-svg-size"
182
- })) : T("v-if", !0), e.icon && !e.loading ? (f(), h(L(e.icon), {
183
- key: 1,
184
- class: M({
185
- "is-text": e.text || e.slots.default
186
- })
187
- }, null, 8, ["class"])) : T("v-if", !0), E(e.$slots, "default", {}, function() {
188
- return [r(
189
- "span",
190
- null,
191
- U(e.text),
192
- 1
193
- /* TEXT */
194
- )];
195
- })], 16, x);
196
- }
197
- var m = /* @__PURE__ */ Q(W, [["render", ee]]);
198
- function y() {
199
- return y = Object.assign ? Object.assign.bind() : function(e) {
200
- for (var t = 1; t < arguments.length; t++) {
201
- var n = arguments[t];
202
- for (var o in n) ({}).hasOwnProperty.call(n, o) && (e[o] = n[o]);
203
- }
204
- return e;
205
- }, y.apply(null, arguments);
206
- }
207
- var te = function(t) {
208
- var n, o = typeof process == "object" ? (n = process.env) == null ? void 0 : n.TINY_MODE : null;
209
- return m;
210
- }, ne = y({}, j, {
211
- /** 展示按钮不同的状态,设置为text则展示为文本按钮。可取值为:'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text' */
212
- type: {
213
- type: String,
214
- default: "default"
215
- },
216
- /** 设置原生的tabindex属性 */
217
- tabindex: {
218
- type: String,
219
- default: "0"
220
- },
221
- /** 按钮左侧展示的图标,接收为Icon组件 */
222
- icon: {
223
- type: [Object, String],
224
- default: ""
225
- },
226
- /** 按钮显示的文本 */
227
- text: {
228
- type: String,
229
- default: ""
230
- },
231
- /** 设置按钮禁用时间,防止重复提交,单位毫秒 */
232
- resetTime: {
233
- type: Number,
234
- default: 1e3
235
- },
236
- /** 对应按钮原生 type 属性 */
237
- nativeType: {
238
- type: String,
239
- default: "button"
240
- },
241
- /** 当配置href后,点击按钮则更新 location.href 进行页面跳转 */
242
- href: {
243
- type: String,
244
- default: ""
245
- },
246
- /** 定义按钮尺寸 */
247
- size: {
248
- type: String,
249
- default: "",
250
- validator: function(t) {
251
- return ["large", "medium", "small", "mini", ""].includes(t);
252
- }
253
- },
254
- /** 是否圆角按钮 */
255
- round: {
256
- type: Boolean,
257
- default: void 0
258
- },
259
- /** 是否朴素按钮 */
260
- plain: Boolean,
261
- /** 是否圆形按钮 */
262
- circle: Boolean,
263
- /** 是否加载中状态 */
264
- loading: Boolean,
265
- /** 是否被禁用按钮 */
266
- disabled: Boolean,
267
- /** 是否默认聚焦 */
268
- autofocus: Boolean,
269
- /** 自定义类名, 仅 mobile-first 模板时有效 */
270
- customClass: {
271
- type: String,
272
- default: ""
273
- },
274
- /** 设置通栏按钮,宽度充满水平方向, 仅 mobile-first 模板时有效 */
275
- banner: {
276
- type: Boolean,
277
- default: !1
278
- },
279
- /** 自定义样式 */
280
- customStyle: {
281
- type: Object,
282
- default: function() {
283
- return {};
284
- }
285
- },
286
- /** 是否幽灵按钮 */
287
- ghost: Boolean,
288
- /** 点击事件 */
289
- onClick: {
290
- type: Function
291
- }
292
- }), p = k({
293
- name: A + "Button",
294
- inject: {
295
- buttonGroup: {
296
- default: ""
297
- }
298
- },
299
- props: ne,
300
- slots: Object,
301
- setup: function(t, n) {
302
- return $({
303
- props: t,
304
- context: n,
305
- template: te
306
- });
307
- }
308
- }), oe = "3.undefined";
309
- p.install = function(e) {
310
- e.component(p.name, p);
311
- };
312
- p.version = oe;
313
- export {
314
- p as B
315
- };