@nutui/icons-react-taro 3.0.2-beta.5 → 3.0.2-beta.ios.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.
@@ -70,6 +70,300 @@ const Icon$1 = (props) => {
70
70
  }, children);
71
71
  };
72
72
  const Icon$2 = Icon$1;
73
+ const isComplexType = (o) => {
74
+ o = typeof o;
75
+ return o === "object" || o === "function";
76
+ };
77
+ const h = (nodeName, vnodeData, ...children) => {
78
+ let child = null;
79
+ let key = null;
80
+ let slotName = null;
81
+ let simple = false;
82
+ let lastSimple = false;
83
+ const vNodeChildren = [];
84
+ const walk = (c) => {
85
+ for (let i = 0; i < c.length; i++) {
86
+ child = c[i];
87
+ if (Array.isArray(child)) {
88
+ walk(child);
89
+ } else if (child != null && typeof child !== "boolean") {
90
+ if (simple = typeof nodeName !== "function" && !isComplexType(child)) {
91
+ child = String(child);
92
+ }
93
+ if (simple && lastSimple) {
94
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
95
+ } else {
96
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
97
+ }
98
+ lastSimple = simple;
99
+ }
100
+ }
101
+ };
102
+ walk(children);
103
+ if (vnodeData) {
104
+ if (vnodeData.key) {
105
+ key = vnodeData.key;
106
+ }
107
+ if (vnodeData.name) {
108
+ slotName = vnodeData.name;
109
+ }
110
+ {
111
+ const classData = vnodeData.className || vnodeData.class;
112
+ if (classData) {
113
+ vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
114
+ }
115
+ }
116
+ }
117
+ if (typeof nodeName === "function") {
118
+ return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
119
+ }
120
+ const vnode = newVNode(nodeName, null);
121
+ vnode.$attrs$ = vnodeData;
122
+ if (vNodeChildren.length > 0) {
123
+ vnode.$children$ = vNodeChildren;
124
+ }
125
+ {
126
+ vnode.$key$ = key;
127
+ }
128
+ {
129
+ vnode.$name$ = slotName;
130
+ }
131
+ return vnode;
132
+ };
133
+ const newVNode = (tag, text) => {
134
+ const vnode = {
135
+ $flags$: 0,
136
+ $tag$: tag,
137
+ $text$: text,
138
+ $elm$: null,
139
+ $children$: null
140
+ };
141
+ {
142
+ vnode.$attrs$ = null;
143
+ }
144
+ {
145
+ vnode.$key$ = null;
146
+ }
147
+ {
148
+ vnode.$name$ = null;
149
+ }
150
+ return vnode;
151
+ };
152
+ const Host = {};
153
+ const vdomFnUtils = {
154
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
155
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate)
156
+ };
157
+ const convertToPublic = (node) => ({
158
+ vattrs: node.$attrs$,
159
+ vchildren: node.$children$,
160
+ vkey: node.$key$,
161
+ vname: node.$name$,
162
+ vtag: node.$tag$,
163
+ vtext: node.$text$
164
+ });
165
+ const convertToPrivate = (node) => {
166
+ if (typeof node.vtag === "function") {
167
+ const vnodeData = Object.assign({}, node.vattrs);
168
+ if (node.vkey) {
169
+ vnodeData.key = node.vkey;
170
+ }
171
+ if (node.vname) {
172
+ vnodeData.name = node.vname;
173
+ }
174
+ return h(node.vtag, vnodeData, ...node.vchildren || []);
175
+ }
176
+ const vnode = newVNode(node.vtag, node.vtext);
177
+ vnode.$attrs$ = node.vattrs;
178
+ vnode.$children$ = node.vchildren;
179
+ vnode.$key$ = node.vkey;
180
+ vnode.$name$ = node.vname;
181
+ return vnode;
182
+ };
183
+ const getElement = (ref) => getHostRef(ref).$hostElement$;
184
+ const createEvent = (ref, name, flags) => {
185
+ const elm = getElement(ref);
186
+ return {
187
+ emit: (detail) => {
188
+ return emitEvent(elm, name, {
189
+ bubbles: !!(flags & 4),
190
+ composed: !!(flags & 2),
191
+ cancelable: !!(flags & 1),
192
+ detail
193
+ });
194
+ }
195
+ };
196
+ };
197
+ const emitEvent = (elm, name, opts) => {
198
+ const ev = plt.ce(name, opts);
199
+ elm.dispatchEvent(ev);
200
+ return ev;
201
+ };
202
+ const hostRefs = /* @__PURE__ */ new WeakMap();
203
+ const getHostRef = (ref) => hostRefs.get(ref);
204
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set(hostRef.$lazyInstance$ = lazyInstance, hostRef);
205
+ const plt = {
206
+ $flags$: 0,
207
+ $resourcesUrl$: "",
208
+ jmp: (h2) => h2(),
209
+ raf: (h2) => requestAnimationFrame(h2),
210
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
211
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
212
+ ce: (eventName, opts) => new CustomEvent(eventName, opts)
213
+ };
214
+ function createCommonjsModule(fn, basedir, module) {
215
+ return module = {
216
+ path: basedir,
217
+ exports: {},
218
+ require: function(path, base) {
219
+ return commonjsRequire();
220
+ }
221
+ }, fn(module, module.exports), module.exports;
222
+ }
223
+ function commonjsRequire() {
224
+ throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs");
225
+ }
226
+ var classnames = createCommonjsModule(function(module) {
227
+ /*!
228
+ Copyright (c) 2018 Jed Watson.
229
+ Licensed under the MIT License (MIT), see
230
+ http://jedwatson.github.io/classnames
231
+ */
232
+ (function() {
233
+ var hasOwn = {}.hasOwnProperty;
234
+ function classNames() {
235
+ var classes = "";
236
+ for (var i = 0; i < arguments.length; i++) {
237
+ var arg = arguments[i];
238
+ if (arg) {
239
+ classes = appendClass(classes, parseValue(arg));
240
+ }
241
+ }
242
+ return classes;
243
+ }
244
+ function parseValue(arg) {
245
+ if (typeof arg === "string" || typeof arg === "number") {
246
+ return arg;
247
+ }
248
+ if (typeof arg !== "object") {
249
+ return "";
250
+ }
251
+ if (Array.isArray(arg)) {
252
+ return classNames.apply(null, arg);
253
+ }
254
+ if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
255
+ return arg.toString();
256
+ }
257
+ var classes = "";
258
+ for (var key in arg) {
259
+ if (hasOwn.call(arg, key) && arg[key]) {
260
+ classes = appendClass(classes, key);
261
+ }
262
+ }
263
+ return classes;
264
+ }
265
+ function appendClass(value, newClass) {
266
+ if (!newClass) {
267
+ return value;
268
+ }
269
+ if (value) {
270
+ return value + " " + newClass;
271
+ }
272
+ return value + newClass;
273
+ }
274
+ if (module.exports) {
275
+ classNames.default = classNames;
276
+ module.exports = classNames;
277
+ } else {
278
+ window.classNames = classNames;
279
+ }
280
+ })();
281
+ });
282
+ const indexCss = 'img[src=""]{opacity:0}taro-image-core{width:320px;height:240px;font-size:0;display:inline-block;position:relative;overflow:hidden}.taro-img.taro-img__widthfix{height:100%}.taro-img__mode-scaletofill{width:100%;height:100%}.taro-img__mode-aspectfit{max-width:100%;max-height:100%;position:absolute;top:50%;transform:translateY(-50%)}.taro-img__mode-aspectfill{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.taro-img__mode-aspectfill--width{min-width:100%;height:100%}.taro-img__mode-aspectfill--height{width:100%;min-height:100%}.taro-img__mode-widthfix{width:100%}.taro-img__mode-heightfix{height:100%}.taro-img__mode-top{position:absolute;left:50%;transform:translate(-50%)}.taro-img__mode-bottom{position:absolute;bottom:0;left:50%;transform:translate(-50%)}.taro-img__mode-center{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.taro-img__mode-left{position:absolute;top:50%;transform:translateY(-50%)}.taro-img__mode-right{position:absolute;top:50%;right:0;transform:translateY(-50%)}.taro-img__mode-topright{position:absolute;right:0}.taro-img__mode-bottomleft{position:absolute;bottom:0}.taro-img__mode-bottomright{position:absolute;bottom:0;right:0}';
283
+ const LEGO_CDN_URL = "http://ossin.jd.com/swm-plus/h5Tag/tag.js";
284
+ const isLegoScriptLoaded = () => {
285
+ return document.querySelector(`script[src="${LEGO_CDN_URL}"]`) !== null;
286
+ };
287
+ const insertLegoScript = () => {
288
+ if (isLegoScriptLoaded())
289
+ return;
290
+ const script = document.createElement("script");
291
+ script.type = "module";
292
+ script.src = LEGO_CDN_URL;
293
+ document.head.appendChild(script);
294
+ };
295
+ const parseLegoUrl = (src) => {
296
+ if (!src.startsWith("lego://"))
297
+ return null;
298
+ try {
299
+ const urlWithoutProtocol = src.substring(7);
300
+ const [tagId, params] = urlWithoutProtocol.split("?");
301
+ const text = params ? new URLSearchParams(params).get("text") || "" : "";
302
+ return { tagId, text };
303
+ } catch (error) {
304
+ console.warn("Failed to parse lego URL:", src, error);
305
+ return null;
306
+ }
307
+ };
308
+ const Image = class {
309
+ constructor(hostRef) {
310
+ registerInstance(this, hostRef);
311
+ this.onLoad = createEvent(this, "load", 7);
312
+ this.onError = createEvent(this, "error", 7);
313
+ this.src = void 0;
314
+ this.mode = "scaleToFill";
315
+ this.lazyLoad = false;
316
+ this.nativeProps = {};
317
+ this.lang = void 0;
318
+ this.aspectFillMode = "width";
319
+ this.didLoad = false;
320
+ }
321
+ componentDidLoad() {
322
+ const legoData = parseLegoUrl(this.src);
323
+ if (legoData !== null) {
324
+ insertLegoScript();
325
+ }
326
+ if (!this.lazyLoad)
327
+ return;
328
+ const lazyImg = new IntersectionObserver((entries) => {
329
+ if (entries[entries.length - 1].isIntersecting) {
330
+ lazyImg.unobserve(this.imgRef);
331
+ this.didLoad = true;
332
+ }
333
+ }, {
334
+ rootMargin: "300px 0px"
335
+ });
336
+ lazyImg.observe(this.imgRef);
337
+ }
338
+ imageOnLoad() {
339
+ const { width, height, naturalWidth, naturalHeight } = this.imgRef;
340
+ this.onLoad.emit({
341
+ width,
342
+ height
343
+ });
344
+ this.aspectFillMode = naturalWidth > naturalHeight ? "width" : "height";
345
+ }
346
+ imageOnError(e) {
347
+ this.onError.emit(e);
348
+ }
349
+ render() {
350
+ const { src, lazyLoad = false, aspectFillMode = "width", imageOnLoad, imageOnError, nativeProps, didLoad, lang } = this;
351
+ const mode = this.mode || "scaleToFill";
352
+ const legoData = parseLegoUrl(src);
353
+ const isLegoMode = legoData !== null;
354
+ const cls = classnames({
355
+ "taro-img__widthfix": mode === "widthFix"
356
+ });
357
+ const imgCls = classnames(`taro-img__mode-${mode.toLowerCase().replace(/\s/g, "")}`, {
358
+ [`taro-img__mode-aspectfill--${aspectFillMode}`]: mode === "aspectFill"
359
+ });
360
+ if (isLegoMode && legoData) {
361
+ return h(Host, { class: cls }, h("canvas-tag", Object.assign({ tagId: legoData.tagId, text: legoData.text, lang }, nativeProps)));
362
+ }
363
+ return h(Host, { class: cls }, src ? h("img", Object.assign({ ref: (img) => this.imgRef = img, class: imgCls, src: lazyLoad && !didLoad ? void 0 : src, onLoad: imageOnLoad.bind(this), onError: imageOnError.bind(this) }, nativeProps)) : "");
364
+ }
365
+ };
366
+ Image.style = indexCss;
73
367
  const defaultProps = {
74
368
  className: "",
75
369
  style: void 0,
@@ -124,13 +418,17 @@ const Icon = (props) => {
124
418
  color
125
419
  };
126
420
  };
127
- return React.createElement("Image", {
128
- src: svgSrc,
129
- className: classes(),
130
- style: getStyle(),
131
- onClick: handleClick,
132
- svg: true
133
- }, children);
421
+ return React.createElement(
422
+ Image,
423
+ {
424
+ src: svgSrc,
425
+ className: classes(),
426
+ style: getStyle(),
427
+ onClick: handleClick,
428
+ svg: true
429
+ },
430
+ children
431
+ );
134
432
  };
135
433
  const Icon2 = Icon;
136
434
  export {