@donglegeyu/company-ui 1.2.4 → 1.2.6

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 (37) hide show
  1. package/dist/cjs/basic-components/CompanyPagination/index.js +12 -1
  2. package/dist/cjs/shared-components/AccessibilityChecker/index.d.ts +7 -0
  3. package/dist/cjs/shared-components/AccessibilityChecker/index.js +171 -0
  4. package/dist/cjs/shared-components/AccessibilityChecker/index.scss +60 -0
  5. package/dist/cjs/shared-components/ColorScale/index.d.ts +21 -0
  6. package/dist/cjs/shared-components/ColorScale/index.js +493 -0
  7. package/dist/cjs/shared-components/ColorScale/index.scss +187 -0
  8. package/dist/cjs/shared-components/FilterOptionsDrawer/index.js +3 -3
  9. package/dist/cjs/shared-components/index.d.ts +2 -0
  10. package/dist/cjs/shared-components/index.js +6 -0
  11. package/dist/cjs/template-components/IconSelect/index.d.ts +12 -0
  12. package/dist/cjs/template-components/IconSelect/index.js +342 -0
  13. package/dist/cjs/template-components/IconSelect/index.scss +109 -0
  14. package/dist/cjs/template-components/SmartListTemplate/index.d.ts +4 -1
  15. package/dist/cjs/template-components/SmartListTemplate/index.js +57 -4
  16. package/dist/cjs/template-components/index.d.ts +1 -0
  17. package/dist/cjs/template-components/index.js +3 -0
  18. package/dist/cjs/theme/GlobalTheme.js +4 -4
  19. package/dist/es/basic-components/CompanyPagination/index.js +5 -1
  20. package/dist/es/shared-components/AccessibilityChecker/index.d.ts +7 -0
  21. package/dist/es/shared-components/AccessibilityChecker/index.js +216 -0
  22. package/dist/es/shared-components/AccessibilityChecker/index.scss +60 -0
  23. package/dist/es/shared-components/ColorScale/index.d.ts +21 -0
  24. package/dist/es/shared-components/ColorScale/index.js +557 -0
  25. package/dist/es/shared-components/ColorScale/index.scss +187 -0
  26. package/dist/es/shared-components/FilterOptionsDrawer/index.js +4 -3
  27. package/dist/es/shared-components/index.d.ts +2 -0
  28. package/dist/es/shared-components/index.js +3 -1
  29. package/dist/es/template-components/IconSelect/index.d.ts +12 -0
  30. package/dist/es/template-components/IconSelect/index.js +545 -0
  31. package/dist/es/template-components/IconSelect/index.scss +109 -0
  32. package/dist/es/template-components/SmartListTemplate/index.d.ts +4 -1
  33. package/dist/es/template-components/SmartListTemplate/index.js +82 -12
  34. package/dist/es/template-components/index.d.ts +1 -0
  35. package/dist/es/template-components/index.js +2 -1
  36. package/dist/es/theme/GlobalTheme.js +4 -4
  37. package/package.json +1 -1
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
14
16
  }
15
17
  return to;
16
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
+ ));
17
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
28
 
19
29
  // src/basic-components/CompanyPagination/index.tsx
@@ -23,10 +33,11 @@ __export(CompanyPagination_exports, {
23
33
  });
24
34
  module.exports = __toCommonJS(CompanyPagination_exports);
25
35
  var import_antd = require("antd");
36
+ var import_zh_CN = __toESM(require("antd/locale/zh_CN"));
26
37
  var import_theme = require("../../theme");
27
38
  var import_jsx_runtime = require("react/jsx-runtime");
28
39
  var CompanyPagination = (props) => {
29
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.ConfigProvider, { theme: import_theme.companyTheme, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Pagination, { ...props }) });
40
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.ConfigProvider, { theme: import_theme.companyTheme, locale: import_zh_CN.default, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Pagination, { size: "small", ...props }) });
30
41
  };
31
42
  // Annotate the CommonJS export names for ESM import in node:
32
43
  0 && (module.exports = {
@@ -0,0 +1,7 @@
1
+ import './index.scss';
2
+ interface AccessibilityCheckerProps {
3
+ tokenName: string;
4
+ color: string;
5
+ }
6
+ export default function AccessibilityChecker({ tokenName, color }: AccessibilityCheckerProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,171 @@
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/shared-components/AccessibilityChecker/index.tsx
20
+ var AccessibilityChecker_exports = {};
21
+ __export(AccessibilityChecker_exports, {
22
+ default: () => AccessibilityChecker
23
+ });
24
+ module.exports = __toCommonJS(AccessibilityChecker_exports);
25
+ var import_react = require("react");
26
+ var import_basic_components = require("../../basic-components");
27
+ var import_index = require("./index.scss");
28
+ var import_jsx_runtime = require("react/jsx-runtime");
29
+ function hexToRgb(hex) {
30
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
31
+ return result ? {
32
+ r: parseInt(result[1], 16),
33
+ g: parseInt(result[2], 16),
34
+ b: parseInt(result[3], 16)
35
+ } : null;
36
+ }
37
+ function getLuminance(r, g, b) {
38
+ const [rs, gs, bs] = [r, g, b].map((c) => {
39
+ c = c / 255;
40
+ return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
41
+ });
42
+ return 0.2126 * rs + 0.7152 * gs + 0.0722 * bs;
43
+ }
44
+ function getContrastRatio(color1, color2) {
45
+ const rgb1 = hexToRgb(color1);
46
+ const rgb2 = hexToRgb(color2);
47
+ if (!rgb1 || !rgb2)
48
+ return 0;
49
+ const l1 = getLuminance(rgb1.r, rgb1.g, rgb1.b);
50
+ const l2 = getLuminance(rgb2.r, rgb2.g, rgb2.b);
51
+ const lighter = Math.max(l1, l2);
52
+ const darker = Math.min(l1, l2);
53
+ return (lighter + 0.05) / (darker + 0.05);
54
+ }
55
+ function getWcagLevel(ratio) {
56
+ if (ratio >= 7)
57
+ return "AAA";
58
+ if (ratio >= 4.5)
59
+ return "AA";
60
+ if (ratio >= 3)
61
+ return "AA (large & UI)";
62
+ return "Fail";
63
+ }
64
+ function sRGBtoY(sRGB) {
65
+ if (sRGB <= 0.04045)
66
+ return sRGB / 12.92;
67
+ return Math.pow((sRGB + 0.055) / 1.055, 2.4);
68
+ }
69
+ function getLuminanceApca(r, g, b) {
70
+ const rY = sRGBtoY(r / 255) * 0.2126729;
71
+ const gY = sRGBtoY(g / 255) * 0.7151522;
72
+ const bY = sRGBtoY(b / 255) * 0.072175;
73
+ return rY + gY + bY;
74
+ }
75
+ function getApcaContrast(txtColor, bgColor) {
76
+ const txtRgb = hexToRgb(txtColor);
77
+ const bgRgb = hexToRgb(bgColor);
78
+ if (!txtRgb || !bgRgb)
79
+ return 0;
80
+ const txtY = getLuminanceApca(txtRgb.r, txtRgb.g, txtRgb.b);
81
+ const bgY = getLuminanceApca(bgRgb.r, bgRgb.g, bgRgb.b);
82
+ const normBG = Math.pow(bgY, 0.56);
83
+ const normTXT = Math.pow(txtY, 0.57);
84
+ if (bgY > txtY)
85
+ return (normBG - normTXT) * 1.14 * 100;
86
+ else
87
+ return (normTXT - normBG) * 1.14 * 100 * -1;
88
+ }
89
+ function getApcaLevel(value) {
90
+ const absValue = Math.abs(value);
91
+ if (absValue >= 90)
92
+ return "Ok for text";
93
+ if (absValue >= 75)
94
+ return "Ok for large text";
95
+ if (absValue >= 60)
96
+ return "Ok for UI";
97
+ return "Not recommended";
98
+ }
99
+ function getResultStyle(level) {
100
+ if (level === "Fail" || level === "Not recommended") {
101
+ return { backgroundColor: "#FFF2F0" };
102
+ }
103
+ return { backgroundColor: "#F6FFED" };
104
+ }
105
+ function AccessibilityChecker({ tokenName, color }) {
106
+ const [compareColor, setCompareColor] = (0, import_react.useState)("white");
107
+ const colorMap = {
108
+ white: "#ffffff",
109
+ black: "#000000"
110
+ };
111
+ const results = (0, import_react.useMemo)(() => {
112
+ if (!color)
113
+ return null;
114
+ const bgColor = colorMap[compareColor] || "#ffffff";
115
+ const textOnWhite = getApcaContrast(color, bgColor);
116
+ const bgOnWhite = getApcaContrast(bgColor, color);
117
+ const wcagRatio = getContrastRatio(color, bgColor);
118
+ return {
119
+ textOnWhite: { value: textOnWhite, level: getApcaLevel(textOnWhite) },
120
+ bgOnWhite: { value: bgOnWhite, level: getApcaLevel(bgOnWhite) },
121
+ wcag: { value: wcagRatio, level: getWcagLevel(wcagRatio) }
122
+ };
123
+ }, [color, compareColor]);
124
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "accessibility-checker", children: [
125
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "checker-row", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "checker-label", children: [
126
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: tokenName }),
127
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "vs-text", children: "vs." }),
128
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
129
+ import_basic_components.CompanySelect,
130
+ {
131
+ value: compareColor,
132
+ onChange: setCompareColor,
133
+ style: { width: 160 },
134
+ options: [
135
+ { label: "--color-white", value: "white" },
136
+ { label: "--color-black", value: "black" }
137
+ ]
138
+ }
139
+ )
140
+ ] }) }),
141
+ results && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "checker-results", children: [
142
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "checker-item", children: [
143
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "checker-box", style: { backgroundColor: "#ffffff", color }, children: "APCA" }),
144
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "checker-result", style: getResultStyle(results.textOnWhite.level), children: [
145
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "value", children: results.textOnWhite.value.toFixed(0) }),
146
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "separator", children: "-" }),
147
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "level", children: results.textOnWhite.level })
148
+ ] })
149
+ ] }),
150
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "checker-item", children: [
151
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "checker-box", style: { backgroundColor: color, color: "#ffffff" }, children: "APCA" }),
152
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "checker-result", style: getResultStyle(results.bgOnWhite.level), children: [
153
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "value", children: results.bgOnWhite.value.toFixed(0) }),
154
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "separator", children: "-" }),
155
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "level", children: results.bgOnWhite.level })
156
+ ] })
157
+ ] }),
158
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "checker-item", children: [
159
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "checker-box", style: { backgroundColor: "#ffffff", color }, children: "WCAG" }),
160
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "checker-result", style: getResultStyle(results.wcag.level), children: [
161
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "value", children: [
162
+ results.wcag.value.toFixed(2),
163
+ ":1"
164
+ ] }),
165
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "separator", children: "-" }),
166
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "level", children: results.wcag.level })
167
+ ] })
168
+ ] })
169
+ ] })
170
+ ] });
171
+ }
@@ -0,0 +1,60 @@
1
+ .accessibility-checker {
2
+ width: 100%;
3
+ }
4
+
5
+ .checker-row {
6
+ margin-bottom: 12px;
7
+ }
8
+
9
+ .checker-label {
10
+ display: flex;
11
+ align-items: center;
12
+ gap: 8px;
13
+ font-weight: 600;
14
+ color: #1D2129;
15
+
16
+ .vs-text {
17
+ margin: 0 8px;
18
+ color: #1D2129;
19
+ }
20
+ }
21
+
22
+ .checker-results {
23
+ display: flex;
24
+ gap: 10px;
25
+ width: 560px;
26
+ }
27
+
28
+ .checker-item {
29
+ flex: 1;
30
+ }
31
+
32
+ .checker-box {
33
+ width: 100%;
34
+ height: 138px;
35
+ display: flex;
36
+ align-items: center;
37
+ justify-content: center;
38
+ font-weight: 600;
39
+ border-radius: 6px;
40
+ border: 1px solid #f0f0f0;
41
+ }
42
+
43
+ .checker-result {
44
+ height: 69px;
45
+ padding: 10px;
46
+ display: flex;
47
+ justify-content: center;
48
+ align-items: center;
49
+ border-radius: 6px;
50
+ margin-top: 8px;
51
+ font-size: 13px;
52
+
53
+ .value {
54
+ font-weight: 600;
55
+ }
56
+
57
+ .separator {
58
+ margin: 0 4px;
59
+ }
60
+ }
@@ -0,0 +1,21 @@
1
+ import './index.scss';
2
+ interface ColorScaleProps {
3
+ label?: string;
4
+ baseColor?: string;
5
+ colors?: string[];
6
+ customColors?: (string | undefined)[];
7
+ highlightIndex?: number;
8
+ tokenPrefix?: string;
9
+ selectedIndex?: number | null;
10
+ selectedGroupKey?: string;
11
+ hideHeader?: boolean;
12
+ hideBase?: boolean;
13
+ onSelect?: (payload: {
14
+ index: number;
15
+ color: string;
16
+ tokenName: string;
17
+ groupKey: string;
18
+ }) => void;
19
+ }
20
+ export default function ColorScale({ label, baseColor, colors, customColors, highlightIndex, tokenPrefix, selectedIndex, selectedGroupKey, hideHeader, hideBase, onSelect, }: ColorScaleProps): import("react/jsx-runtime").JSX.Element;
21
+ export {};