@tuya-sat/micro-dev-component 3.3.4 → 3.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/dist/index.js +0 -420
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-sat/micro-dev-component",
3
- "version": "3.3.4",
3
+ "version": "3.3.5",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "scripts": {
package/dist/index.js DELETED
@@ -1,420 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- /**
6
- * List of known SVG tag names.
7
- *
8
- * @type {Array<string>}
9
- */
10
- const svgTagNames = [
11
- 'a',
12
- 'altGlyph',
13
- 'altGlyphDef',
14
- 'altGlyphItem',
15
- 'animate',
16
- 'animateColor',
17
- 'animateMotion',
18
- 'animateTransform',
19
- 'animation',
20
- 'audio',
21
- 'canvas',
22
- 'circle',
23
- 'clipPath',
24
- 'color-profile',
25
- 'cursor',
26
- 'defs',
27
- 'desc',
28
- 'discard',
29
- 'ellipse',
30
- 'feBlend',
31
- 'feColorMatrix',
32
- 'feComponentTransfer',
33
- 'feComposite',
34
- 'feConvolveMatrix',
35
- 'feDiffuseLighting',
36
- 'feDisplacementMap',
37
- 'feDistantLight',
38
- 'feDropShadow',
39
- 'feFlood',
40
- 'feFuncA',
41
- 'feFuncB',
42
- 'feFuncG',
43
- 'feFuncR',
44
- 'feGaussianBlur',
45
- 'feImage',
46
- 'feMerge',
47
- 'feMergeNode',
48
- 'feMorphology',
49
- 'feOffset',
50
- 'fePointLight',
51
- 'feSpecularLighting',
52
- 'feSpotLight',
53
- 'feTile',
54
- 'feTurbulence',
55
- 'filter',
56
- 'font',
57
- 'font-face',
58
- 'font-face-format',
59
- 'font-face-name',
60
- 'font-face-src',
61
- 'font-face-uri',
62
- 'foreignObject',
63
- 'g',
64
- 'glyph',
65
- 'glyphRef',
66
- 'handler',
67
- 'hkern',
68
- 'iframe',
69
- 'image',
70
- 'line',
71
- 'linearGradient',
72
- 'listener',
73
- 'marker',
74
- 'mask',
75
- 'metadata',
76
- 'missing-glyph',
77
- 'mpath',
78
- 'path',
79
- 'pattern',
80
- 'polygon',
81
- 'polyline',
82
- 'prefetch',
83
- 'radialGradient',
84
- 'rect',
85
- 'script',
86
- 'set',
87
- 'solidColor',
88
- 'stop',
89
- 'style',
90
- 'svg',
91
- 'switch',
92
- 'symbol',
93
- 'tbreak',
94
- 'text',
95
- 'textArea',
96
- 'textPath',
97
- 'title',
98
- 'tref',
99
- 'tspan',
100
- 'unknown',
101
- 'use',
102
- 'video',
103
- 'view',
104
- 'vkern'
105
- ];
106
-
107
- const svgTags = new Set(svgTagNames);
108
- svgTags.delete('a');
109
- svgTags.delete('audio');
110
- svgTags.delete('canvas');
111
- svgTags.delete('iframe');
112
- svgTags.delete('script');
113
- svgTags.delete('video');
114
- // Copied from Preact
115
- // https://github.com/preactjs/preact/blob/1bbd687c13c1fd16f0d6393e79ea6232f55fbec4/src/constants.js#L3
116
- const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;
117
- const isFragment = (type) => type === DocumentFragment;
118
- const setCSSProps = (element, style) => {
119
- for (const [name, value] of Object.entries(style)) {
120
- if (name.startsWith('-')) {
121
- element.style.setProperty(name, value);
122
- }
123
- else if (typeof value === 'number' && !IS_NON_DIMENSIONAL.test(name)) {
124
- element.style[name] = `${value}px`;
125
- }
126
- else {
127
- element.style[name] = value;
128
- }
129
- }
130
- };
131
- const create = (type) => {
132
- if (typeof type === 'string') {
133
- if (svgTags.has(type)) {
134
- return document.createElementNS('http://www.w3.org/2000/svg', type);
135
- }
136
- return document.createElement(type);
137
- }
138
- if (isFragment(type)) {
139
- return document.createDocumentFragment();
140
- }
141
- return type(type.defaultProps);
142
- };
143
- const setAttribute = (element, name, value) => {
144
- if (value === undefined || value === null) {
145
- return;
146
- }
147
- // Naive support for xlink namespace
148
- // Full list: https://github.com/facebook/react/blob/1843f87/src/renderers/dom/shared/SVGDOMPropertyConfig.js#L258-L264
149
- if (/^xlink[AHRST]/.test(name)) {
150
- element.setAttributeNS('http://www.w3.org/1999/xlink', name.replace('xlink', 'xlink:').toLowerCase(), value);
151
- }
152
- else {
153
- element.setAttribute(name, value);
154
- }
155
- };
156
- const addChildren = (parent, children) => {
157
- for (const child of children) {
158
- if (child instanceof Node) {
159
- parent.appendChild(child);
160
- }
161
- else if (Array.isArray(child)) {
162
- addChildren(parent, child);
163
- }
164
- else if (typeof child !== 'boolean'
165
- && typeof child !== 'undefined'
166
- && child !== null) {
167
- parent.appendChild(document.createTextNode(child));
168
- }
169
- }
170
- };
171
- // These attributes allow "false" as a valid value
172
- // https://github.com/facebook/react/blob/3f8990898309c61c817fbf663f5221d9a00d0eaa/packages/react-dom/src/shared/DOMProperty.js#L288-L322
173
- const booleanishAttributes = new Set([
174
- // These attributes allow "false" as a valid value
175
- 'contentEditable',
176
- 'draggable',
177
- 'spellCheck',
178
- 'value',
179
- // SVG-specific
180
- 'autoReverse',
181
- 'externalResourcesRequired',
182
- 'focusable',
183
- 'preserveAlpha',
184
- ]);
185
- const h = (type, attributes, ...children) => {
186
- var _a;
187
- const element = create(type);
188
- addChildren(element, children);
189
- if (element instanceof DocumentFragment || !attributes) {
190
- return element;
191
- }
192
- // Set attributes
193
- for (let [name, value] of Object.entries(attributes)) {
194
- if (name === 'htmlFor') {
195
- name = 'for';
196
- }
197
- if (name === 'class' || name === 'className') {
198
- const existingClassname = (_a = element.getAttribute('class')) !== null && _a !== void 0 ? _a : '';
199
- setAttribute(element, 'class', (existingClassname + ' ' + String(value)).trim());
200
- }
201
- else if (name === 'style') {
202
- setCSSProps(element, value);
203
- }
204
- else if (name.startsWith('on')) {
205
- const eventName = name.slice(2).toLowerCase().replace(/^-/, '');
206
- element.addEventListener(eventName, value);
207
- }
208
- else if (name === 'dangerouslySetInnerHTML' && '__html' in value) {
209
- element.innerHTML = value.__html;
210
- }
211
- else if (name !== 'key' && (booleanishAttributes.has(name) || value !== false)) {
212
- setAttribute(element, name, value === true ? '' : value);
213
- }
214
- }
215
- return element;
216
- };
217
- // eslint-disable-next-line @typescript-eslint/no-redeclare -- Ur rong.
218
- const Fragment = (typeof DocumentFragment === 'function' ? DocumentFragment : () => { });
219
- // Improve TypeScript support for DocumentFragment
220
- // https://github.com/Microsoft/TypeScript/issues/20469
221
- const React = {
222
- createElement: h,
223
- Fragment,
224
- };
225
-
226
- function styleInject(css, ref) {
227
- if ( ref === void 0 ) ref = {};
228
- var insertAt = ref.insertAt;
229
-
230
- if (!css || typeof document === 'undefined') { return; }
231
-
232
- var head = document.head || document.getElementsByTagName('head')[0];
233
- var style = document.createElement('style');
234
- style.type = 'text/css';
235
-
236
- if (insertAt === 'top') {
237
- if (head.firstChild) {
238
- head.insertBefore(style, head.firstChild);
239
- } else {
240
- head.appendChild(style);
241
- }
242
- } else {
243
- head.appendChild(style);
244
- }
245
-
246
- if (style.styleSheet) {
247
- style.styleSheet.cssText = css;
248
- } else {
249
- style.appendChild(document.createTextNode(css));
250
- }
251
- }
252
-
253
- var css_248z$1 = ".ruleModal-module_cover__dkT6q {\n display: none;\n position: fixed;\n left: 0;\n top: 0;\n width: 100vw;\n height: 100vh;\n background-color: rgba(0, 0, 0, 0.5);\n z-index: 10000;\n}\n.ruleModal-module_modal__I0Xxp {\n position: fixed;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -68%);\n width: 438px;\n max-height: 400px;\n background-color: #fff;\n background-clip: padding-box;\n border: 0;\n border-radius: 2px;\n box-shadow: 0 3px 6px -4px #0000001f, 0 6px 16px #00000014, 0 9px 28px 8px #0000000d;\n pointer-events: auto;\n}\n.ruleModal-module_modal__I0Xxp .ruleModal-module_header__omUo2 {\n height: 53px;\n padding-left: 20px;\n line-height: 53px;\n border-bottom: 1px solid #f0f0f0;\n}\n.ruleModal-module_modal__I0Xxp .ruleModal-module_footer__yuYWv {\n border-top: 1px solid #f0f0f0;\n padding: 10px 10px 10px 0px;\n text-align: right;\n}\n.ruleModal-module_modal__I0Xxp .ruleModal-module_footer__yuYWv .ruleModal-module_cancel__O3x0P {\n display: inline-block;\n padding: 4px 14px;\n background: #fff;\n color: #333;\n border-radius: 4px;\n margin-right: 10px;\n cursor: pointer;\n border: 1px solid #d9d9d9;\n}\n.ruleModal-module_modal__I0Xxp .ruleModal-module_footer__yuYWv .ruleModal-module_ok__KQc0K {\n display: inline-block;\n padding: 5px 15px;\n background: #1890ff;\n color: #fff;\n border-radius: 4px;\n cursor: pointer;\n}\n@media (max-width: 488px) {\n .ruleModal-module_modal__I0Xxp {\n width: 80%;\n }\n}\n";
254
- var styles$1 = {"cover":"ruleModal-module_cover__dkT6q","modal":"ruleModal-module_modal__I0Xxp","header":"ruleModal-module_header__omUo2","footer":"ruleModal-module_footer__yuYWv","cancel":"ruleModal-module_cancel__O3x0P","ok":"ruleModal-module_ok__KQc0K"};
255
- styleInject(css_248z$1);
256
-
257
- class RuleModal {
258
- constructor({ handleClose }) {
259
- this.formItems = [...window._allCodesStatusMap.entries()].map(([code, value]) => {
260
- return {
261
- label: code,
262
- name: code,
263
- value,
264
- };
265
- });
266
- this.handleClose = handleClose;
267
- this.init();
268
- }
269
- handleOk() {
270
- const roleItem = [...this.element.querySelectorAll("input")];
271
- const roleChecked = roleItem
272
- .map(({ attributes, checked }) => checked ? attributes["data-role"].value : null)
273
- .filter(Boolean);
274
- window._authedCodeInfoProxy.authedCode = roleChecked;
275
- this.handleClose();
276
- }
277
- render() {
278
- return (React.createElement("div", { className: styles$1.cover },
279
- React.createElement("div", { className: styles$1.modal },
280
- React.createElement("div", { className: styles$1.header }, "\u89D2\u8272\u6743\u9650"),
281
- React.createElement("div", { style: {
282
- paddingTop: "2em",
283
- paddingBottom: "1em",
284
- } }, this.formItems.map(({ label, name, value }) => (React.createElement("p", { style: {
285
- paddingLeft: "30px",
286
- } },
287
- React.createElement("input", { type: "checkbox", style: { marginRight: "6px", cursor: "pointer" }, "data-role": name, id: name }),
288
- React.createElement("label", { htmlFor: name, style: { cursor: "pointer" } }, label))))),
289
- React.createElement("div", { className: styles$1.footer },
290
- React.createElement("div", { className: styles$1.cancel, onClick: this.handleClose }, "\u53D6\u6D88"),
291
- React.createElement("div", { className: styles$1.ok, onClick: this.handleOk.bind(this) }, "\u786E\u5B9A")))));
292
- }
293
- init() {
294
- const dom = this.render();
295
- this.element = dom;
296
- document.body.appendChild(this.element);
297
- }
298
- }
299
-
300
- var css_248z = ".fixed-module_container__yByz5 {\n position: fixed;\n z-index: 9999;\n transform: translate(50%, 50%);\n color: #fff;\n border-radius: 50%;\n}\n.fixed-module_mainIcon__bwrzu {\n display: flex;\n align-items: center;\n justify-content: center;\n position: relative;\n width: 50px;\n height: 50px;\n border-radius: 50%;\n background-color: #fff;\n cursor: pointer;\n user-select: none;\n box-shadow: 0 3px 6px -4px #0000001f, 0 6px 16px #00000014, 0 9px 28px 8px #0000000d;\n}\n.fixed-module_mIcon__TTq3k,\n.fixed-module_rIcon__RIGhf {\n position: absolute;\n left: 10px;\n top: 10px;\n width: 30px;\n height: 30px;\n text-align: center;\n line-height: 30px;\n border-radius: 50%;\n transform-origin: 50% 50%;\n background-color: #1890ff;\n transition: all 0.5s;\n cursor: pointer;\n user-select: none;\n}\n.fixed-module_mIconActive__-zslY {\n transform: translate(-60px, 0px);\n}\n.fixed-module_rIconActive__kupXn {\n transform: translate(0px, -60px);\n}\n";
301
- var styles = {"container":"fixed-module_container__yByz5","mainIcon":"fixed-module_mainIcon__bwrzu","mIcon":"fixed-module_mIcon__TTq3k","rIcon":"fixed-module_rIcon__RIGhf","mIconActive":"fixed-module_mIconActive__-zslY","rIconActive":"fixed-module_rIconActive__kupXn"};
302
- styleInject(css_248z);
303
-
304
- class Fixed {
305
- constructor(container) {
306
- this.isMove = false;
307
- this.dowmTime = 0;
308
- this.windowSize = {
309
- width: window.innerWidth,
310
- height: window.innerHeight,
311
- };
312
- this.container = container;
313
- this.proxyData = this.observable({
314
- position: {
315
- right: 80,
316
- bottom: 80,
317
- },
318
- visible: false,
319
- }, [
320
- "position",
321
- ({ right, bottom }) => {
322
- this.element.style.right = `${right}px`;
323
- this.element.style.bottom = `${bottom}px`;
324
- },
325
- ], [
326
- "visible",
327
- (visible) => {
328
- this.children.element.style.display = visible ? "block" : "none";
329
- },
330
- ]);
331
- this.children = new RuleModal({
332
- handleClose: function () {
333
- this.proxyData.visible = false;
334
- }.bind(this),
335
- });
336
- this.addResizeListener();
337
- this.addGlobalListener();
338
- this.init();
339
- }
340
- init() {
341
- const { right, bottom } = this.proxyData.position;
342
- const start = () => {
343
- this.isMove = true;
344
- this.dowmTime = new Date().valueOf();
345
- };
346
- const end = () => {
347
- const upTime = new Date().valueOf();
348
- const leftTime = upTime - this.dowmTime;
349
- if (leftTime > 238) {
350
- return;
351
- }
352
- this.proxyData.visible = !this.proxyData.visible;
353
- };
354
- const fixedDom = (React.createElement("div", { className: styles.container, style: {
355
- right: right,
356
- bottom: bottom,
357
- }, onTouchStart: start, onTouchEnd: end, onMouseDown: start, onMouseUp: end },
358
- React.createElement("div", { className: styles.mainIcon },
359
- React.createElement("svg", { viewBox: "0 0 1024 1024", version: "1.1", xmlns: "http://www.w3.org/2000/svg", "p-id": "2748", width: "27", height: "27" },
360
- React.createElement("path", { d: "M951.4 797.5L563.8 409.9c10.2-11 9.9-28.1-0.8-38.8l-32.4-32.4c12.1-74.4-11.9-149.4-65.6-203.1C420.8 91.4 362 67 299.4 67c-29.3 0-57.9 5.4-85.1 15.9-8.8 3.4-15.3 11.1-17.3 20.3-1.9 9.3 0.9 18.9 7.6 25.6l126.7 126.7-74.4 74.4-128.1-128.1c-6.6-6.6-16-9.5-25.2-7.7-9.2 1.8-16.8 8.1-20.4 16.7-37 88.1-17.2 188.8 50.4 256.3 44.2 44.3 103.1 68.6 165.7 68.6 14.2 0 28.5-1.3 42.4-3.8l30.3 30.3c10.7 10.7 27.8 10.9 38.8 0.8l387.6 387.6c5.5 5.5 12.6 8.2 19.8 8.2 7.2 0 14.3-2.7 19.8-8.2l113.4-113.4c10.9-11 10.9-28.8 0-39.7z m-133.2 93.6L435.9 508.9l37.6-37.6c7.3-7.3 7.3-19.1 0-26.4-7.3-7.3-19.1-7.3-26.4 0l-56.6 56.6-20-20c-7-7-17.2-9.8-26.7-7.3-14.5 3.7-29.5 5.6-44.5 5.6-47.6 0-92.4-18.5-126.1-52.2-40.8-40.8-58.7-97.4-50.4-152.5l114.3 114.3c10.9 11 28.6 11 39.6 0L390.2 276l0.7-0.7c10.8-10.9 10.7-28.6-0.2-39.4L279.2 124.2c6.7-0.7 13.4-1.1 20.2-1.1 47.6 0 92.4 18.5 126.1 52.2 43.8 43.8 61.5 106 47.6 166.5-2.1 9.4 0.7 19.3 7.5 26.1l23.2 23.1c-10.2 11-9.9 28.1 0.8 38.8L892 817.3 868.3 841 565.8 538.5c-7.3-7.3-19.1-7.3-26.4 0-7.3 7.3-7.3 19.1 0 26.4l302.5 302.5-23.7 23.7z", fill: "#4F4F4F", "p-id": "2749" }),
361
- React.createElement("path", { d: "M395.3 321.8l-74.4 74.4c-7.3 7.3-7.3 19.1 0 26.4 3.7 3.6 8.4 5.5 13.2 5.5s9.5-1.8 13.2-5.5l74.4-74.4c7.3-7.3 7.3-19.1 0-26.4-7.4-7.3-19.2-7.3-26.4 0z", fill: "#4F4F4F", "p-id": "2750" })))));
362
- this.element = fixedDom;
363
- }
364
- observable(target, ...cbs) {
365
- const cbsMap = new Map(cbs);
366
- return new Proxy(target, {
367
- get(target, prop) {
368
- return target[prop];
369
- },
370
- set(target, prop, value) {
371
- target[prop] = value;
372
- if (cbsMap.has(prop)) {
373
- cbsMap.get(prop)(value);
374
- }
375
- return true;
376
- },
377
- });
378
- }
379
- addResizeListener() {
380
- let resize = ({ target }) => {
381
- this.windowSize = {
382
- width: target.innerWidth,
383
- height: target.innerHeight,
384
- };
385
- };
386
- window.addEventListener("resize", resize);
387
- }
388
- addGlobalListener() {
389
- const bodyDom = document.querySelector("body");
390
- const moveup = () => {
391
- this.isMove = false;
392
- };
393
- const move = (e) => {
394
- if (this.isMove) {
395
- let { clientX, clientY } = e;
396
- if (clientX === undefined || clientY === undefined) {
397
- ({ clientX, clientY } = e.changedTouches[0]);
398
- }
399
- const { width, height } = this.windowSize;
400
- this.proxyData.position = {
401
- right: width - clientX,
402
- bottom: height - clientY,
403
- };
404
- }
405
- };
406
- bodyDom.addEventListener("mouseup", moveup);
407
- bodyDom.addEventListener("touchend", moveup);
408
- bodyDom.addEventListener("mousemove", move);
409
- bodyDom.addEventListener("touchmove", move);
410
- }
411
- render() {
412
- this.container.appendChild(this.element);
413
- }
414
- }
415
-
416
- const insertDom = (container) => {
417
- new Fixed(container).render();
418
- };
419
-
420
- exports.insertDom = insertDom;