aio-tree 1.0.1 → 1.1.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/index.js +20 -45
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -318,14 +318,13 @@ export const Indent = (props) => {
|
|
|
318
318
|
if (toggleIcon === false) {
|
|
319
319
|
return false;
|
|
320
320
|
}
|
|
321
|
-
const getIcon = new GetSvg('em').getIcon;
|
|
322
321
|
if (isLeaf) {
|
|
323
|
-
return toggleIcon.leaf ||
|
|
322
|
+
return toggleIcon.leaf || _jsx(CircleSmall, {});
|
|
324
323
|
}
|
|
325
324
|
if (open) {
|
|
326
|
-
return toggleIcon.open ||
|
|
325
|
+
return toggleIcon.open || _jsx(ChevronDown, {});
|
|
327
326
|
}
|
|
328
|
-
return toggleIcon.close ||
|
|
327
|
+
return toggleIcon.close || (rtl ? _jsx(ChevronLeft, {}) : _jsx(ChevronRight, {}));
|
|
329
328
|
};
|
|
330
329
|
function getIndentIcons() {
|
|
331
330
|
const list = new Array(level).fill(0);
|
|
@@ -344,7 +343,19 @@ export const Indent = (props) => {
|
|
|
344
343
|
}
|
|
345
344
|
return (_jsxs("div", { className: `ai-indents`, children: [indentPathes, toggleIcon] }));
|
|
346
345
|
};
|
|
347
|
-
|
|
346
|
+
const ChevronLeft = () => {
|
|
347
|
+
return (_jsx("svg", { viewBox: "0 0 24 24", role: "presentation", style: { width: '1.5em', height: '1.5em' }, children: _jsx("path", { d: "M15.41,16.58L10.83,12L15.41,7.41L14,6L8,12L14,18L15.41,16.58Z", style: { fill: 'currentcolor' } }) }));
|
|
348
|
+
};
|
|
349
|
+
const ChevronRight = () => {
|
|
350
|
+
return (_jsx("svg", { viewBox: "0 0 24 24", role: "presentation", style: { width: '1.5em', height: '1.5em' }, children: _jsx("path", { d: "M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z", style: { fill: 'currentcolor' } }) }));
|
|
351
|
+
};
|
|
352
|
+
const ChevronDown = () => {
|
|
353
|
+
return (_jsx("svg", { viewBox: "0 0 24 24", role: "presentation", style: { width: '1.5em', height: '1.5em' }, children: _jsx("path", { d: "M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z", style: { fill: 'currentcolor' } }) }));
|
|
354
|
+
};
|
|
355
|
+
const CircleSmall = () => {
|
|
356
|
+
return (_jsx("svg", { viewBox: "0 0 24 24", role: "presentation", style: { width: '1.5em', height: '1.5em' }, children: _jsx("path", { d: "M12,10A2,2 0 0,0 10,12C10,13.11 10.9,14 12,14C13.11,14 14,13.11 14,12A2,2 0 0,0 12,10Z", style: { fill: 'currentcolor' } }) }));
|
|
357
|
+
};
|
|
358
|
+
const ClassListToString = (classes) => {
|
|
348
359
|
let list = [];
|
|
349
360
|
const getClasses = (cls) => {
|
|
350
361
|
if (Array.isArray(cls)) {
|
|
@@ -360,47 +371,11 @@ function classListToString(classes) {
|
|
|
360
371
|
list = [...list, ...getClasses(cls)];
|
|
361
372
|
}
|
|
362
373
|
return list.length ? list.join(' ') : '';
|
|
363
|
-
}
|
|
364
|
-
|
|
374
|
+
};
|
|
375
|
+
const AddToAttrs = (attrs, p) => {
|
|
365
376
|
attrs = attrs || {};
|
|
366
|
-
const className =
|
|
377
|
+
const className = ClassListToString([attrs.className, p === null || p === void 0 ? void 0 : p.className]);
|
|
367
378
|
let newStyle = Object.assign(Object.assign({}, attrs.style), p === null || p === void 0 ? void 0 : p.style);
|
|
368
379
|
const res = Object.assign(Object.assign(Object.assign({}, attrs), { className, style: newStyle }), p === null || p === void 0 ? void 0 : p.attrs);
|
|
369
380
|
return res;
|
|
370
|
-
}
|
|
371
|
-
class GetSvg {
|
|
372
|
-
constructor(unit) {
|
|
373
|
-
this.getStyle = (color) => ({ fill: color || "currentcolor" });
|
|
374
|
-
this.getSvgStyle = (size) => {
|
|
375
|
-
size = size || 1;
|
|
376
|
-
return { width: `${size * 1.5}${this.unit}`, height: `${size * 1.5}${this.unit}` };
|
|
377
|
-
};
|
|
378
|
-
this.fixSvgContent = (content, size, p) => {
|
|
379
|
-
const { spin } = p || {};
|
|
380
|
-
let res = null;
|
|
381
|
-
if (spin) {
|
|
382
|
-
res = (_jsxs(_Fragment, { children: [_jsx("style", { children: `@keyframes spin { from { transform: rotate(0deg) } to { transform: rotate(360deg) } }` }), _jsx("g", { style: { animation: `${spin}s linear 0s infinite normal none running spin`, transformOrigin: 'center center' }, children: content })] }));
|
|
383
|
-
}
|
|
384
|
-
else {
|
|
385
|
-
res = content;
|
|
386
|
-
}
|
|
387
|
-
return (_jsx("svg", { viewBox: "0 0 24 24", role: "presentation", style: this.getSvgStyle(size), children: res }));
|
|
388
|
-
};
|
|
389
|
-
this.getIcon = (path, size, p) => {
|
|
390
|
-
const { color } = p || {};
|
|
391
|
-
const fn = this[path];
|
|
392
|
-
if (!fn) {
|
|
393
|
-
alert(`${path} is not valid`);
|
|
394
|
-
return null;
|
|
395
|
-
}
|
|
396
|
-
const content = fn(color);
|
|
397
|
-
return this.fixSvgContent(content, size, p);
|
|
398
|
-
};
|
|
399
|
-
this.mdiChevronDown = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z", style: this.getStyle(color) }) }));
|
|
400
|
-
this.mdiChevronUp = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z", style: this.getStyle(color) }) }));
|
|
401
|
-
this.mdiChevronLeft = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M15.41,16.58L10.83,12L15.41,7.41L14,6L8,12L14,18L15.41,16.58Z", style: this.getStyle(color) }) }));
|
|
402
|
-
this.mdiChevronRight = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z", style: this.getStyle(color) }) }));
|
|
403
|
-
this.mdiCircleSmall = (color) => (_jsx(_Fragment, { children: _jsx("path", { d: "M12,10A2,2 0 0,0 10,12C10,13.11 10.9,14 12,14C13.11,14 14,13.11 14,12A2,2 0 0,0 12,10Z", style: this.getStyle(color) }) }));
|
|
404
|
-
this.unit = unit || 'rem';
|
|
405
|
-
}
|
|
406
|
-
}
|
|
381
|
+
};
|