@pisell/materials 1.0.381 → 1.0.382

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 (36) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +2 -2
  6. package/build/lowcode/preview.js +7 -7
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +4 -4
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +4 -4
  11. package/dist/umd/materials.min.css +1 -0
  12. package/dist/umd/materials.min.js +1 -0
  13. package/dist/umd/static/DotsSix.57d66266.svg +1 -0
  14. package/dist/umd/static/arrow-left.e542294f.svg +1 -0
  15. package/dist/umd/static/arrow-right.763f03e0.svg +1 -0
  16. package/dist/umd/static/filter-lines.04a54ae9.svg +1 -0
  17. package/dist/umd/static/help-circle.31c9be40.svg +1 -0
  18. package/dist/umd/static/switch-vertical-01.7ebe3ba8.svg +1 -0
  19. package/es/components/pisellTags/index.d.ts +13 -0
  20. package/es/components/pisellTags/index.js +84 -0
  21. package/es/components/pisellTags/index.less +17 -0
  22. package/es/components/pisellTags/utils.d.ts +1 -0
  23. package/es/components/pisellTags/utils.js +89 -0
  24. package/es/index.d.ts +3 -2
  25. package/es/index.js +2 -1
  26. package/lib/components/pisellTags/index.d.ts +13 -0
  27. package/lib/components/pisellTags/index.js +114 -0
  28. package/lib/components/pisellTags/index.less +17 -0
  29. package/lib/components/pisellTags/utils.d.ts +1 -0
  30. package/lib/components/pisellTags/utils.js +86 -0
  31. package/lib/index.d.ts +3 -2
  32. package/lib/index.js +3 -0
  33. package/lowcode/pisell-tags/__screenshots__/tag-1.png +0 -0
  34. package/lowcode/pisell-tags/meta.ts +123 -0
  35. package/lowcode/pisell-tags/snippets.ts +14 -0
  36. package/package.json +3 -3
@@ -0,0 +1 @@
1
+ <svg width="24" height="24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M8 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM8 6a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM8 20a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM16 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM16 6a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM16 20a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
@@ -0,0 +1 @@
1
+ <svg width="24" height="24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.707 4.293a1 1 0 0 1 0 1.414L7.414 11H19a1 1 0 1 1 0 2H7.414l5.293 5.293a1 1 0 0 1-1.414 1.414l-7-7a1 1 0 0 1 0-1.414l7-7a1 1 0 0 1 1.414 0Z"/></svg>
@@ -0,0 +1 @@
1
+ <svg width="24" height="24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M11.293 4.293a1 1 0 0 1 1.414 0l7 7a1 1 0 0 1 0 1.414l-7 7a1 1 0 0 1-1.414-1.414L16.586 13H5a1 1 0 1 1 0-2h11.586l-5.293-5.293a1 1 0 0 1 0-1.414Z"/></svg>
@@ -0,0 +1 @@
1
+ <svg width="24" height="24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 6a1 1 0 0 1 1-1h18a1 1 0 1 1 0 2H3a1 1 0 0 1-1-1Zm3 6a1 1 0 0 1 1-1h12a1 1 0 1 1 0 2H6a1 1 0 0 1-1-1Zm3 6a1 1 0 0 1 1-1h6a1 1 0 1 1 0 2H9a1 1 0 0 1-1-1Z"/></svg>
@@ -0,0 +1 @@
1
+ <svg width="24" height="24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18ZM1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11.258-3.976a2 2 0 0 0-2.225 1.308 1 1 0 1 1-1.886-.664 4 4 0 0 1 7.773 1.333c0 1.53-1.135 2.54-1.945 3.081a8.044 8.044 0 0 1-1.686.848l-.035.013-.011.003-.004.002h-.002L11.92 13l.316.949a1 1 0 0 1-.633-1.897l.016-.006.074-.027a6.051 6.051 0 0 0 1.172-.6c.69-.46 1.055-.95 1.055-1.419v-.001a2 2 0 0 0-1.662-1.975ZM11 17a1 1 0 0 1 1-1h.01a1 1 0 1 1 0 2H12a1 1 0 0 1-1-1Z"/></svg>
@@ -0,0 +1 @@
1
+ <svg width="24" height="24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M6.293 3.293a1 1 0 0 1 1.414 0l4 4a1 1 0 0 1-1.414 1.414L8 6.414V20a1 1 0 1 1-2 0V6.414L3.707 8.707a1 1 0 0 1-1.414-1.414l4-4ZM16 17.586V4a1 1 0 1 1 2 0v13.586l2.293-2.293a1 1 0 0 1 1.414 1.414l-4 4a1 1 0 0 1-1.414 0l-4-4a1 1 0 0 1 1.414-1.414L16 17.586Z"/></svg>
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ export declare type PisellTagsType = 'pill_color' | 'pill_outline';
4
+ export declare type PisellTagsColor = 'success' | 'warning' | 'error' | 'gray' | string;
5
+ export interface PisellTagsProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> {
6
+ children?: React.ReactNode;
7
+ others?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>;
8
+ type: PisellTagsType;
9
+ icon?: React.ReactNode;
10
+ color?: PisellTagsColor;
11
+ }
12
+ declare const PisellTags: (props: PisellTagsProps) => React.JSX.Element;
13
+ export default PisellTags;
@@ -0,0 +1,84 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ var _excluded = ["children", "type", "icon", "color", "style", "others"];
3
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
8
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
9
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
10
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
11
+ import React, { useMemo } from 'react';
12
+ import classNames from 'classnames';
13
+ import { generateColorShades } from "./utils";
14
+ import "./index.less";
15
+
16
+ // Pisell Tags 样式类型
17
+
18
+ // 预设颜色枚举
19
+ var pisellTagsColors = {
20
+ success: '#067647',
21
+ warning: '#B54708',
22
+ error: '#B42318',
23
+ gray: '#344054'
24
+ };
25
+
26
+ /**
27
+ * @title: 获取颜色
28
+ * @description:
29
+ * @param {PisellTagsColor} _color
30
+ * @return {*}
31
+ * @Author: zhiwei.Wang
32
+ * @Date: 2024-08-23 16:07
33
+ */
34
+ var getColor = function getColor(_color) {
35
+ if (_color) {
36
+ return pisellTagsColors[_color] || _color;
37
+ }
38
+ return '#344054';
39
+ };
40
+ var getPillColorStyles = function getPillColorStyles(_color) {
41
+ var colorShades = generateColorShades(_color);
42
+ return {
43
+ '--pisell-tags-bg-color': colorShades['color_50'],
44
+ '--pisell-tags-font-color': colorShades['color_700'],
45
+ '--pisell-tags-border-color': colorShades['color_200']
46
+ };
47
+ };
48
+ var getPillOutlineStyles = function getPillOutlineStyles(_color) {
49
+ var colorShades = generateColorShades(_color);
50
+ return {
51
+ '--pisell-tags-bg-color': 'transparent',
52
+ '--pisell-tags-font-color': colorShades['color_700'],
53
+ '--pisell-tags-border-color': colorShades['color_600']
54
+ };
55
+ };
56
+ var PisellTags = function PisellTags(props) {
57
+ var children = props.children,
58
+ type = props.type,
59
+ icon = props.icon,
60
+ color = props.color,
61
+ _props$style = props.style,
62
+ style = _props$style === void 0 ? {} : _props$style,
63
+ _props$others = props.others,
64
+ others = _props$others === void 0 ? {} : _props$others,
65
+ otherProps = _objectWithoutProperties(props, _excluded);
66
+ document.body.id = 'body';
67
+ var styles = useMemo(function () {
68
+ var obj = _objectSpread(_objectSpread({}, style), others.style);
69
+ var _color = getColor(props.color);
70
+ if (type === 'pill_color') {
71
+ obj = _objectSpread(_objectSpread({}, obj), getPillColorStyles(_color));
72
+ }
73
+ if (type === 'pill_outline') {
74
+ obj = _objectSpread(_objectSpread({}, obj), getPillOutlineStyles(_color));
75
+ }
76
+ return obj;
77
+ }, [color, style, others.style, type]);
78
+ return /*#__PURE__*/React.createElement("span", _extends({
79
+ style: _objectSpread(_objectSpread({}, styles), style)
80
+ }, others, otherProps, {
81
+ className: classNames('pisell-tags', others.className, otherProps.className)
82
+ }), icon ? icon : null, children);
83
+ };
84
+ export default PisellTags;
@@ -0,0 +1,17 @@
1
+ .pisell-tags {
2
+ --pisell-tags-bg-color: #F9FAFB;
3
+ --pisell-tags-font-color: #344054;
4
+ --pisell-tags-border-color: #EAECF0;
5
+ border-radius: 16px;
6
+ border: 1px solid var(--pisell-tags-border-color);
7
+ background: var(--pisell-tags-bg-color);
8
+ display: inline-flex;
9
+ padding: 4px 12px;
10
+ align-items: center;
11
+ gap: 6px;
12
+
13
+ color: var(--pisell-tags-font-color);
14
+ font-size: 14px;
15
+ font-style: normal;
16
+ font-weight: 500;
17
+ }
@@ -0,0 +1 @@
1
+ export declare const generateColorShades: (color: string) => Record<string, string>;
@@ -0,0 +1,89 @@
1
+ // 定义 RGB 类型,包括 r, g, b 和可选的 a(透明度)分量
2
+
3
+ // 辅助函数:将 16 进制颜色转换为 RGB
4
+ var hexToRgb = function hexToRgb(hex) {
5
+ hex = hex.replace(/^#/, ''); // 去掉开头的 #
6
+ if (hex.length === 3) {
7
+ // 处理三位颜色码,扩展为六位颜色码
8
+ hex = hex.split('').map(function (h) {
9
+ return h + h;
10
+ }).join('');
11
+ }
12
+ var intVal = parseInt(hex, 16); // 将 16 进制转换为整数
13
+ return {
14
+ r: intVal >> 16 & 255,
15
+ // 提取红色分量
16
+ g: intVal >> 8 & 255,
17
+ // 提取绿色分量
18
+ b: intVal & 255 // 提取蓝色分量
19
+ };
20
+ };
21
+
22
+ // 辅助函数:将 RGB 转换为 16 进制颜色
23
+ var rgbToHex = function rgbToHex(r, g, b) {
24
+ return '#' + [r, g, b].map(function (x) {
25
+ var hex = x.toString(16); // 将数值转换为 16 进制字符串
26
+ return hex.length === 1 ? '0' + hex : hex; // 确保每个分量都是两位
27
+ }).join(''); // 将 RGB 分量组合为 16 进制颜色码
28
+ };
29
+
30
+ // 辅助函数:解析输入的颜色字符串,并返回 RGB 或 RGBA 对象
31
+ var parseColor = function parseColor(color) {
32
+ if (color.startsWith('#')) {
33
+ return hexToRgb(color); // 处理 16 进制颜色
34
+ } else if (color.startsWith('rgb')) {
35
+ // 处理 RGB 或 RGBA 颜色
36
+ var rgba = color.replace(/rgba?\(|\s+|\)/g, '').split(',').map(Number);
37
+ return {
38
+ r: rgba[0],
39
+ g: rgba[1],
40
+ b: rgba[2],
41
+ a: rgba[3] !== undefined ? rgba[3] : 1
42
+ };
43
+ } else {
44
+ throw new Error('无效的颜色格式');
45
+ }
46
+ };
47
+
48
+ // 生成颜色阶梯的函数
49
+ export var generateColorShades = function generateColorShades(color) {
50
+ var _parseColor = parseColor(color),
51
+ r = _parseColor.r,
52
+ g = _parseColor.g,
53
+ b = _parseColor.b,
54
+ a = _parseColor.a;
55
+ var max = 700;
56
+ var gap = 1 / max;
57
+
58
+ // 定义相对于 700 阶梯的 50, 200, 500 阶梯的比例
59
+ var ratios = {
60
+ 50: gap * 50,
61
+ 200: gap * 200,
62
+ 500: gap * 500,
63
+ 600: gap * 600,
64
+ 700: gap * 700
65
+ };
66
+
67
+ // 调整颜色分量的函数,基于比例计算新的分量值
68
+ var adjustColorComponent = function adjustColorComponent(component, ratio) {
69
+ return Math.round(component * ratio + 255 * (1 - ratio));
70
+ };
71
+
72
+ // 生成不同阶梯的颜色
73
+ var shades = {
74
+ 'color_50': rgbToHex(adjustColorComponent(r, ratios[50]), adjustColorComponent(g, ratios[50]), adjustColorComponent(b, ratios[50])),
75
+ 'color_200': rgbToHex(adjustColorComponent(r, ratios[200]), adjustColorComponent(g, ratios[200]), adjustColorComponent(b, ratios[200])),
76
+ 'color_500': rgbToHex(adjustColorComponent(r, ratios[500]), adjustColorComponent(g, ratios[500]), adjustColorComponent(b, ratios[500])),
77
+ 'color_600': rgbToHex(adjustColorComponent(r, ratios[600]), adjustColorComponent(g, ratios[600]), adjustColorComponent(b, ratios[600])),
78
+ 'color_700': color
79
+ };
80
+
81
+ // 如果原始颜色带有透明度 (RGBA),在返回结果中包含透明度信息
82
+ if (a !== undefined) {
83
+ shades['color_50'] = "rgba(".concat(adjustColorComponent(r, ratios[50]), ", ").concat(adjustColorComponent(g, ratios[50]), ", ").concat(adjustColorComponent(b, ratios[50]), ", ").concat(a, ")");
84
+ shades['color_200'] = "rgba(".concat(adjustColorComponent(r, ratios[200]), ", ").concat(adjustColorComponent(g, ratios[200]), ", ").concat(adjustColorComponent(b, ratios[200]), ", ").concat(a, ")");
85
+ shades['color_500'] = "rgba(".concat(adjustColorComponent(r, ratios[500]), ", ").concat(adjustColorComponent(g, ratios[500]), ", ").concat(adjustColorComponent(b, ratios[500]), ", ").concat(a, ")");
86
+ shades['color_600'] = "rgba(".concat(adjustColorComponent(r, ratios[600]), ", ").concat(adjustColorComponent(g, ratios[600]), ", ").concat(adjustColorComponent(b, ratios[600]), ", ").concat(a, ")");
87
+ }
88
+ return shades;
89
+ };
package/es/index.d.ts CHANGED
@@ -72,7 +72,7 @@ export { default as List } from './components/list';
72
72
  export { default as Sort } from './components/sort';
73
73
  export { default as InputNumberRange } from './components/input-number-range';
74
74
  export { default as LowCodePage } from './components/lowCodePage';
75
- export { default as PickerView } from "./components/picker-view";
75
+ export { default as PickerView } from './components/picker-view';
76
76
  export { default as Segmented } from './components/segmented';
77
77
  export { default as VirtualKeyboard } from './components/virtual-keyboard';
78
78
  export { default as VirtualKeyboardTime } from './components/virtual-keyboard/Time';
@@ -102,4 +102,5 @@ export { default as PisellAlert } from './components/pisellAlert';
102
102
  export { default as PisellCard } from './components/pisellCard';
103
103
  export { default as PisellInformationEntry } from './components/pisellInformationEntry';
104
104
  export { default as usePisellConfig } from './components/pisell-config-provider/hooks/usePisellConfig';
105
- export { globalConfig, default as PisellContext } from './components/pisell-config-provider/context';
105
+ export { globalConfig, default as PisellContext, } from './components/pisell-config-provider/context';
106
+ export { default as PisellTags } from './components/pisellTags';
package/es/index.js CHANGED
@@ -124,4 +124,5 @@ export { default as PisellAlert } from "./components/pisellAlert";
124
124
  export { default as PisellCard } from "./components/pisellCard";
125
125
  export { default as PisellInformationEntry } from "./components/pisellInformationEntry";
126
126
  export { default as usePisellConfig } from "./components/pisell-config-provider/hooks/usePisellConfig";
127
- export { globalConfig, default as PisellContext } from "./components/pisell-config-provider/context";
127
+ export { globalConfig, default as PisellContext } from "./components/pisell-config-provider/context";
128
+ export { default as PisellTags } from "./components/pisellTags";
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ export declare type PisellTagsType = 'pill_color' | 'pill_outline';
4
+ export declare type PisellTagsColor = 'success' | 'warning' | 'error' | 'gray' | string;
5
+ export interface PisellTagsProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> {
6
+ children?: React.ReactNode;
7
+ others?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>;
8
+ type: PisellTagsType;
9
+ icon?: React.ReactNode;
10
+ color?: PisellTagsColor;
11
+ }
12
+ declare const PisellTags: (props: PisellTagsProps) => React.JSX.Element;
13
+ export default PisellTags;
@@ -0,0 +1,114 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/components/pisellTags/index.tsx
30
+ var pisellTags_exports = {};
31
+ __export(pisellTags_exports, {
32
+ default: () => pisellTags_default
33
+ });
34
+ module.exports = __toCommonJS(pisellTags_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var import_classnames = __toESM(require("classnames"));
37
+ var import_utils = require("./utils");
38
+ var import_index = require("./index.less");
39
+ var pisellTagsColors = {
40
+ success: "#067647",
41
+ warning: "#B54708",
42
+ error: "#B42318",
43
+ gray: "#344054"
44
+ };
45
+ var getColor = (_color) => {
46
+ if (_color) {
47
+ return pisellTagsColors[_color] || _color;
48
+ }
49
+ return "#344054";
50
+ };
51
+ var getPillColorStyles = (_color) => {
52
+ const colorShades = (0, import_utils.generateColorShades)(_color);
53
+ return {
54
+ "--pisell-tags-bg-color": colorShades["color_50"],
55
+ "--pisell-tags-font-color": colorShades["color_700"],
56
+ "--pisell-tags-border-color": colorShades["color_200"]
57
+ };
58
+ };
59
+ var getPillOutlineStyles = (_color) => {
60
+ const colorShades = (0, import_utils.generateColorShades)(_color);
61
+ return {
62
+ "--pisell-tags-bg-color": "transparent",
63
+ "--pisell-tags-font-color": colorShades["color_700"],
64
+ "--pisell-tags-border-color": colorShades["color_600"]
65
+ };
66
+ };
67
+ var PisellTags = (props) => {
68
+ const {
69
+ children,
70
+ type,
71
+ icon,
72
+ color,
73
+ style = {},
74
+ others = {},
75
+ ...otherProps
76
+ } = props;
77
+ document.body.id = "body";
78
+ const styles = (0, import_react.useMemo)(() => {
79
+ let obj = {
80
+ ...style,
81
+ ...others.style
82
+ };
83
+ const _color = getColor(props.color);
84
+ if (type === "pill_color") {
85
+ obj = {
86
+ ...obj,
87
+ ...getPillColorStyles(_color)
88
+ };
89
+ }
90
+ if (type === "pill_outline") {
91
+ obj = {
92
+ ...obj,
93
+ ...getPillOutlineStyles(_color)
94
+ };
95
+ }
96
+ return obj;
97
+ }, [color, style, others.style, type]);
98
+ return /* @__PURE__ */ import_react.default.createElement(
99
+ "span",
100
+ {
101
+ style: { ...styles, ...style },
102
+ ...others,
103
+ ...otherProps,
104
+ className: (0, import_classnames.default)(
105
+ "pisell-tags",
106
+ others.className,
107
+ otherProps.className
108
+ )
109
+ },
110
+ icon ? icon : null,
111
+ children
112
+ );
113
+ };
114
+ var pisellTags_default = PisellTags;
@@ -0,0 +1,17 @@
1
+ .pisell-tags {
2
+ --pisell-tags-bg-color: #F9FAFB;
3
+ --pisell-tags-font-color: #344054;
4
+ --pisell-tags-border-color: #EAECF0;
5
+ border-radius: 16px;
6
+ border: 1px solid var(--pisell-tags-border-color);
7
+ background: var(--pisell-tags-bg-color);
8
+ display: inline-flex;
9
+ padding: 4px 12px;
10
+ align-items: center;
11
+ gap: 6px;
12
+
13
+ color: var(--pisell-tags-font-color);
14
+ font-size: 14px;
15
+ font-style: normal;
16
+ font-weight: 500;
17
+ }
@@ -0,0 +1 @@
1
+ export declare const generateColorShades: (color: string) => Record<string, string>;
@@ -0,0 +1,86 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/components/pisellTags/utils.ts
20
+ var utils_exports = {};
21
+ __export(utils_exports, {
22
+ generateColorShades: () => generateColorShades
23
+ });
24
+ module.exports = __toCommonJS(utils_exports);
25
+ var hexToRgb = (hex) => {
26
+ hex = hex.replace(/^#/, "");
27
+ if (hex.length === 3) {
28
+ hex = hex.split("").map((h) => h + h).join("");
29
+ }
30
+ const intVal = parseInt(hex, 16);
31
+ return {
32
+ r: intVal >> 16 & 255,
33
+ // 提取红色分量
34
+ g: intVal >> 8 & 255,
35
+ // 提取绿色分量
36
+ b: intVal & 255
37
+ // 提取蓝色分量
38
+ };
39
+ };
40
+ var rgbToHex = (r, g, b) => {
41
+ return "#" + [r, g, b].map((x) => {
42
+ const hex = x.toString(16);
43
+ return hex.length === 1 ? "0" + hex : hex;
44
+ }).join("");
45
+ };
46
+ var parseColor = (color) => {
47
+ if (color.startsWith("#")) {
48
+ return hexToRgb(color);
49
+ } else if (color.startsWith("rgb")) {
50
+ const rgba = color.replace(/rgba?\(|\s+|\)/g, "").split(",").map(Number);
51
+ return { r: rgba[0], g: rgba[1], b: rgba[2], a: rgba[3] !== void 0 ? rgba[3] : 1 };
52
+ } else {
53
+ throw new Error("无效的颜色格式");
54
+ }
55
+ };
56
+ var generateColorShades = (color) => {
57
+ const { r, g, b, a } = parseColor(color);
58
+ const max = 700;
59
+ const gap = 1 / max;
60
+ const ratios = {
61
+ 50: gap * 50,
62
+ 200: gap * 200,
63
+ 500: gap * 500,
64
+ 600: gap * 600,
65
+ 700: gap * 700
66
+ };
67
+ const adjustColorComponent = (component, ratio) => Math.round(component * ratio + 255 * (1 - ratio));
68
+ const shades = {
69
+ "color_50": rgbToHex(adjustColorComponent(r, ratios[50]), adjustColorComponent(g, ratios[50]), adjustColorComponent(b, ratios[50])),
70
+ "color_200": rgbToHex(adjustColorComponent(r, ratios[200]), adjustColorComponent(g, ratios[200]), adjustColorComponent(b, ratios[200])),
71
+ "color_500": rgbToHex(adjustColorComponent(r, ratios[500]), adjustColorComponent(g, ratios[500]), adjustColorComponent(b, ratios[500])),
72
+ "color_600": rgbToHex(adjustColorComponent(r, ratios[600]), adjustColorComponent(g, ratios[600]), adjustColorComponent(b, ratios[600])),
73
+ "color_700": color
74
+ };
75
+ if (a !== void 0) {
76
+ shades["color_50"] = `rgba(${adjustColorComponent(r, ratios[50])}, ${adjustColorComponent(g, ratios[50])}, ${adjustColorComponent(b, ratios[50])}, ${a})`;
77
+ shades["color_200"] = `rgba(${adjustColorComponent(r, ratios[200])}, ${adjustColorComponent(g, ratios[200])}, ${adjustColorComponent(b, ratios[200])}, ${a})`;
78
+ shades["color_500"] = `rgba(${adjustColorComponent(r, ratios[500])}, ${adjustColorComponent(g, ratios[500])}, ${adjustColorComponent(b, ratios[500])}, ${a})`;
79
+ shades["color_600"] = `rgba(${adjustColorComponent(r, ratios[600])}, ${adjustColorComponent(g, ratios[600])}, ${adjustColorComponent(b, ratios[600])}, ${a})`;
80
+ }
81
+ return shades;
82
+ };
83
+ // Annotate the CommonJS export names for ESM import in node:
84
+ 0 && (module.exports = {
85
+ generateColorShades
86
+ });
package/lib/index.d.ts CHANGED
@@ -72,7 +72,7 @@ export { default as List } from './components/list';
72
72
  export { default as Sort } from './components/sort';
73
73
  export { default as InputNumberRange } from './components/input-number-range';
74
74
  export { default as LowCodePage } from './components/lowCodePage';
75
- export { default as PickerView } from "./components/picker-view";
75
+ export { default as PickerView } from './components/picker-view';
76
76
  export { default as Segmented } from './components/segmented';
77
77
  export { default as VirtualKeyboard } from './components/virtual-keyboard';
78
78
  export { default as VirtualKeyboardTime } from './components/virtual-keyboard/Time';
@@ -102,4 +102,5 @@ export { default as PisellAlert } from './components/pisellAlert';
102
102
  export { default as PisellCard } from './components/pisellCard';
103
103
  export { default as PisellInformationEntry } from './components/pisellInformationEntry';
104
104
  export { default as usePisellConfig } from './components/pisell-config-provider/hooks/usePisellConfig';
105
- export { globalConfig, default as PisellContext } from './components/pisell-config-provider/context';
105
+ export { globalConfig, default as PisellContext, } from './components/pisell-config-provider/context';
106
+ export { default as PisellTags } from './components/pisellTags';
package/lib/index.js CHANGED
@@ -90,6 +90,7 @@ __export(src_exports, {
90
90
  PisellModal: () => import_pisellModal.default,
91
91
  PisellRow: () => import_pisellRow.default,
92
92
  PisellScan: () => import_pisellScan.default,
93
+ PisellTags: () => import_pisellTags.default,
93
94
  PisellText: () => import_pisellText.default,
94
95
  PisellToast: () => import_pisellToast.default,
95
96
  PisellTooltip: () => import_pisellTooltip.default,
@@ -242,6 +243,7 @@ var import_pisellCard = __toESM(require("./components/pisellCard"));
242
243
  var import_pisellInformationEntry = __toESM(require("./components/pisellInformationEntry"));
243
244
  var import_usePisellConfig = __toESM(require("./components/pisell-config-provider/hooks/usePisellConfig"));
244
245
  var import_context = __toESM(require("./components/pisell-config-provider/context"));
246
+ var import_pisellTags = __toESM(require("./components/pisellTags"));
245
247
  // Annotate the CommonJS export names for ESM import in node:
246
248
  0 && (module.exports = {
247
249
  Affix,
@@ -305,6 +307,7 @@ var import_context = __toESM(require("./components/pisell-config-provider/contex
305
307
  PisellModal,
306
308
  PisellRow,
307
309
  PisellScan,
310
+ PisellTags,
308
311
  PisellText,
309
312
  PisellToast,
310
313
  PisellTooltip,
@@ -0,0 +1,123 @@
1
+ import snippets from "./snippets";
2
+
3
+ export default {
4
+ snippets,
5
+ componentName: "PisellTags",
6
+ title: "标签",
7
+ category: "数据展示",
8
+ docUrl: "",
9
+ screenshot: "",
10
+ devMode: "proCode",
11
+ npm: {
12
+ package: "@pisell/materials",
13
+ version: "1.0.1",
14
+ exportName: "PisellTags",
15
+ main: "src/index.tsx",
16
+ destructuring: true,
17
+ subName: "",
18
+ },
19
+ props: [
20
+ {
21
+ name: "children",
22
+ title: { label: "内容" },
23
+ propType: { type: "oneOfType", value: ["string", "node"] },
24
+ setter: ['PisellI18nSetter', 'SlotSetter']
25
+ },
26
+ {
27
+ name: 'type',
28
+ title: { label: '展示类型' },
29
+ setter: {
30
+ componentName: 'RadioGroupSetter',
31
+ props: {
32
+ options: [
33
+ {
34
+ title: '填充',
35
+ value: 'pill_color',
36
+ },
37
+ {
38
+ title: '边框',
39
+ value: 'pill_outline',
40
+ },
41
+ ],
42
+ },
43
+ },
44
+ propType: { type: 'oneOf', value: ['pill_color', 'pill_outline'] },
45
+ defaultValue: 'pill_color',
46
+ },
47
+ {
48
+ name: "icon",
49
+ title: {
50
+ label: {
51
+ type: "i18n",
52
+ "en-US": "icon",
53
+ "zh-CN": "图标",
54
+ },
55
+ tip: "icon | Set the icon component of the button",
56
+ },
57
+ propType: { type: "oneOfType", value: ["node"] },
58
+ setter: [{
59
+ componentName: "SlotSetter",
60
+ initialValue: {
61
+ type: "JSSlot",
62
+ value: [
63
+ {
64
+ componentName: "Icon",
65
+ props: {
66
+ type: "SmileOutlined",
67
+ size: 20,
68
+ rotate: 0,
69
+ spin: false,
70
+ },
71
+ },
72
+ ],
73
+ },
74
+ defaultValue: null
75
+ }],
76
+ },
77
+ {
78
+ name: 'color',
79
+ title: { label: '颜色' },
80
+ setter: [
81
+ {
82
+ componentName: 'RadioGroupSetter',
83
+ props: {
84
+ options: [
85
+ {
86
+ title: 'Success',
87
+ value: 'success',
88
+ },
89
+ {
90
+ title: 'Warning',
91
+ value: 'warning',
92
+ },
93
+ {
94
+ title: 'Error',
95
+ value: 'error',
96
+ },
97
+ {
98
+ title: 'Gray',
99
+ value: 'gray',
100
+ },
101
+ ],
102
+ },
103
+ },
104
+ 'ColorSetter', "StringSetter"
105
+ ],
106
+ propType: { type: 'oneOf', value: ['success', 'warning', 'error', 'gray'] },
107
+ defaultValue: 'success',
108
+ },
109
+ ],
110
+ configure: {
111
+ component: { isContainer: true },
112
+ supports: {
113
+ style: true,
114
+ events: [
115
+ {
116
+ name: "onClick",
117
+ template:
118
+ "onClick(event,${extParams}){\n// 点击时的回调\nconsole.log('onClick', event);}",
119
+ },
120
+ ],
121
+ },
122
+ },
123
+ };