@tipp/ui 1.4.8 → 1.4.10
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/dist/atoms/button.cjs +35 -11
- package/dist/atoms/button.cjs.map +1 -1
- package/dist/atoms/button.d.cts +6 -9
- package/dist/atoms/button.d.ts +6 -9
- package/dist/atoms/button.js +2 -1
- package/dist/atoms/button.type.cjs +19 -0
- package/dist/atoms/button.type.cjs.map +1 -0
- package/dist/atoms/button.type.d.cts +11 -0
- package/dist/atoms/button.type.d.ts +11 -0
- package/dist/atoms/button.type.js +1 -0
- package/dist/atoms/button.type.js.map +1 -0
- package/dist/atoms/dialog.cjs +35 -11
- package/dist/atoms/dialog.cjs.map +1 -1
- package/dist/atoms/dialog.js +3 -2
- package/dist/atoms/drawer.cjs +35 -11
- package/dist/atoms/drawer.cjs.map +1 -1
- package/dist/atoms/drawer.js +3 -2
- package/dist/atoms/field-error-wrapper.js +2 -2
- package/dist/atoms/index.cjs +35 -11
- package/dist/atoms/index.cjs.map +1 -1
- package/dist/atoms/index.d.cts +2 -1
- package/dist/atoms/index.d.ts +2 -1
- package/dist/atoms/index.js +70 -69
- package/dist/atoms/pagination.js +2 -2
- package/dist/chunk-2FFOY3WE.js +63 -0
- package/dist/chunk-2FFOY3WE.js.map +1 -0
- package/dist/chunk-3YBBMDHJ.js +60 -0
- package/dist/chunk-3YBBMDHJ.js.map +1 -0
- package/dist/chunk-7YPMSAU3.js +164 -0
- package/dist/chunk-7YPMSAU3.js.map +1 -0
- package/dist/chunk-AX66E4SD.js +192 -0
- package/dist/chunk-AX66E4SD.js.map +1 -0
- package/dist/chunk-BDVTRPXG.js +88 -0
- package/dist/chunk-BDVTRPXG.js.map +1 -0
- package/dist/chunk-BSG2Q4XC.js +192 -0
- package/dist/chunk-BSG2Q4XC.js.map +1 -0
- package/dist/chunk-EIAK47TI.js +77 -0
- package/dist/chunk-EIAK47TI.js.map +1 -0
- package/dist/chunk-EQC3MBY2.js +164 -0
- package/dist/chunk-EQC3MBY2.js.map +1 -0
- package/dist/chunk-GIUL45NR.js +63 -0
- package/dist/chunk-GIUL45NR.js.map +1 -0
- package/dist/chunk-KK6EZCIU.js +192 -0
- package/dist/chunk-KK6EZCIU.js.map +1 -0
- package/dist/chunk-LGWPZRFJ.js +340 -0
- package/dist/chunk-LGWPZRFJ.js.map +1 -0
- package/dist/chunk-LQY4RKWI.js +37 -0
- package/dist/chunk-LQY4RKWI.js.map +1 -0
- package/dist/chunk-OCINOC2X.js +63 -0
- package/dist/chunk-OCINOC2X.js.map +1 -0
- package/dist/chunk-OU5D7QL4.js +340 -0
- package/dist/chunk-OU5D7QL4.js.map +1 -0
- package/dist/chunk-RIV3DRTO.js +340 -0
- package/dist/chunk-RIV3DRTO.js.map +1 -0
- package/dist/chunk-TSVUJJVY.js +340 -0
- package/dist/chunk-TSVUJJVY.js.map +1 -0
- package/dist/chunk-U7JPP7WJ.js +49 -0
- package/dist/chunk-U7JPP7WJ.js.map +1 -0
- package/dist/chunk-UC627KGO.js +60 -0
- package/dist/chunk-UC627KGO.js.map +1 -0
- package/dist/chunk-WIQMMFGJ.js +164 -0
- package/dist/chunk-WIQMMFGJ.js.map +1 -0
- package/dist/chunk-WM3XQMNK.js +88 -0
- package/dist/chunk-WM3XQMNK.js.map +1 -0
- package/dist/chunk-XXODW32Q.js +63 -0
- package/dist/chunk-XXODW32Q.js.map +1 -0
- package/dist/chunk-YL6LJBVF.js +164 -0
- package/dist/chunk-YL6LJBVF.js.map +1 -0
- package/dist/index.cjs +35 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +94 -93
- package/dist/molecules/date-picker/index.js +2 -2
- package/dist/molecules/expand-table/index.js +32 -31
- package/dist/molecules/expand-table/row.js +30 -29
- package/dist/molecules/index.cjs +35 -11
- package/dist/molecules/index.cjs.map +1 -1
- package/dist/molecules/index.js +39 -38
- package/dist/molecules/learning-post.cjs +35 -11
- package/dist/molecules/learning-post.cjs.map +1 -1
- package/dist/molecules/learning-post.js +6 -5
- package/dist/molecules/navigation.cjs +35 -11
- package/dist/molecules/navigation.cjs.map +1 -1
- package/dist/molecules/navigation.js +31 -30
- package/dist/molecules/stepper.js +3 -3
- package/dist/molecules/tag-selector.cjs +35 -11
- package/dist/molecules/tag-selector.cjs.map +1 -1
- package/dist/molecules/tag-selector.js +31 -30
- package/dist/test/button.test.cjs +53 -0
- package/dist/test/button.test.cjs.map +1 -0
- package/dist/test/button.test.d.cts +2 -0
- package/dist/test/button.test.d.ts +2 -0
- package/dist/test/button.test.js +31 -0
- package/dist/test/button.test.js.map +1 -0
- package/dist/utils/convert-button-size.cjs +63 -0
- package/dist/utils/convert-button-size.cjs.map +1 -0
- package/dist/utils/convert-button-size.d.cts +9 -0
- package/dist/utils/convert-button-size.d.ts +9 -0
- package/dist/utils/convert-button-size.js +12 -0
- package/dist/utils/convert-button-size.js.map +1 -0
- package/dist/utils/index.js +3 -3
- package/package.json +8 -3
- package/src/atoms/button.tsx +4 -19
- package/src/atoms/button.type.ts +13 -0
- package/src/test/button.test.ts +27 -0
- package/src/utils/convert-button-size.ts +41 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// src/utils/convert-button-size.ts
|
|
4
|
+
var convertSizeStr = (size) => {
|
|
5
|
+
switch (size) {
|
|
6
|
+
case "small":
|
|
7
|
+
return "1";
|
|
8
|
+
case "medium":
|
|
9
|
+
return "2";
|
|
10
|
+
case "large":
|
|
11
|
+
return "3";
|
|
12
|
+
default:
|
|
13
|
+
return "2";
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var convertSizeResponse = (size) => {
|
|
17
|
+
if (typeof size === "string" || typeof size === "undefined") {
|
|
18
|
+
return convertSizeStr(size);
|
|
19
|
+
}
|
|
20
|
+
const radixSize = {};
|
|
21
|
+
let key = "initial";
|
|
22
|
+
for (key in size) {
|
|
23
|
+
radixSize[key] = convertSizeStr(size[key]);
|
|
24
|
+
}
|
|
25
|
+
return radixSize;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// src/test/button.test.ts
|
|
29
|
+
describe("convertSizeResponse", () => {
|
|
30
|
+
test("converts size to radix size", () => {
|
|
31
|
+
expect(convertSizeResponse("small")).toBe("1");
|
|
32
|
+
expect(convertSizeResponse("medium")).toBe("2");
|
|
33
|
+
expect(convertSizeResponse("large")).toBe("3");
|
|
34
|
+
});
|
|
35
|
+
test("converts size object to radix size object", () => {
|
|
36
|
+
expect(
|
|
37
|
+
convertSizeResponse({
|
|
38
|
+
initial: "small",
|
|
39
|
+
lg: "large",
|
|
40
|
+
md: "medium",
|
|
41
|
+
xl: "large",
|
|
42
|
+
xs: "small"
|
|
43
|
+
})
|
|
44
|
+
).toEqual({
|
|
45
|
+
initial: "1",
|
|
46
|
+
lg: "3",
|
|
47
|
+
md: "2",
|
|
48
|
+
xl: "3",
|
|
49
|
+
xs: "1"
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=button.test.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/convert-button-size.ts","../../src/test/button.test.ts"],"sourcesContent":["import { type ButtonProps as RadixButtonProps } from '@radix-ui/themes';\nimport type { Breakpoint } from '@radix-ui/themes/props';\nimport type { ButtonProps } from '../atoms/button.type';\n\nexport const convertSizeStr = (\n size: ButtonProps['size']\n): '1' | '2' | '3' | '4' => {\n switch (size) {\n case 'small':\n return '1';\n case 'medium':\n return '2';\n case 'large':\n return '3';\n default:\n return '2';\n }\n};\n\nexport const convertSizeResponse = (\n size: ButtonProps['size']\n): RadixButtonProps['size'] => {\n if (typeof size === 'string' || typeof size === 'undefined') {\n return convertSizeStr(size);\n }\n const radixSize: RadixButtonProps['size'] = {};\n let key: Breakpoint = 'initial';\n for (key in size) {\n radixSize[key] = convertSizeStr(size[key]);\n }\n return radixSize;\n};\n\nexport const convertSize = (\n size: ButtonProps['size']\n): RadixButtonProps['size'] => {\n if (typeof size === 'string') {\n return convertSizeStr(size);\n }\n return convertSizeResponse(size);\n};\n","import { convertSizeResponse } from '../utils/convert-button-size';\n\ndescribe('convertSizeResponse', () => {\n test('converts size to radix size', () => {\n expect(convertSizeResponse('small')).toBe('1');\n expect(convertSizeResponse('medium')).toBe('2');\n expect(convertSizeResponse('large')).toBe('3');\n });\n\n test('converts size object to radix size object', () => {\n expect(\n convertSizeResponse({\n initial: 'small',\n lg: 'large',\n md: 'medium',\n xl: 'large',\n xs: 'small',\n })\n ).toEqual({\n initial: '1',\n lg: '3',\n md: '2',\n xl: '3',\n xs: '1',\n });\n });\n});\n"],"mappings":";;;AAIO,IAAM,iBAAiB,CAC5B,SAC0B;AAC1B,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAEO,IAAM,sBAAsB,CACjC,SAC6B;AAC7B,MAAI,OAAO,SAAS,YAAY,OAAO,SAAS,aAAa;AAC3D,WAAO,eAAe,IAAI;AAAA,EAC5B;AACA,QAAM,YAAsC,CAAC;AAC7C,MAAI,MAAkB;AACtB,OAAK,OAAO,MAAM;AAChB,cAAU,GAAG,IAAI,eAAe,KAAK,GAAG,CAAC;AAAA,EAC3C;AACA,SAAO;AACT;;;AC7BA,SAAS,uBAAuB,MAAM;AACpC,OAAK,+BAA+B,MAAM;AACxC,WAAO,oBAAoB,OAAO,CAAC,EAAE,KAAK,GAAG;AAC7C,WAAO,oBAAoB,QAAQ,CAAC,EAAE,KAAK,GAAG;AAC9C,WAAO,oBAAoB,OAAO,CAAC,EAAE,KAAK,GAAG;AAAA,EAC/C,CAAC;AAED,OAAK,6CAA6C,MAAM;AACtD;AAAA,MACE,oBAAoB;AAAA,QAClB,SAAS;AAAA,QACT,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,MACN,CAAC;AAAA,IACH,EAAE,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IACN,CAAC;AAAA,EACH,CAAC;AACH,CAAC;","names":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
convertSizeResponse
|
|
3
|
+
} from "../chunk-LQY4RKWI.js";
|
|
4
|
+
import "../chunk-N552FDTV.js";
|
|
5
|
+
|
|
6
|
+
// src/test/button.test.ts
|
|
7
|
+
describe("convertSizeResponse", () => {
|
|
8
|
+
test("converts size to radix size", () => {
|
|
9
|
+
expect(convertSizeResponse("small")).toBe("1");
|
|
10
|
+
expect(convertSizeResponse("medium")).toBe("2");
|
|
11
|
+
expect(convertSizeResponse("large")).toBe("3");
|
|
12
|
+
});
|
|
13
|
+
test("converts size object to radix size object", () => {
|
|
14
|
+
expect(
|
|
15
|
+
convertSizeResponse({
|
|
16
|
+
initial: "small",
|
|
17
|
+
lg: "large",
|
|
18
|
+
md: "medium",
|
|
19
|
+
xl: "large",
|
|
20
|
+
xs: "small"
|
|
21
|
+
})
|
|
22
|
+
).toEqual({
|
|
23
|
+
initial: "1",
|
|
24
|
+
lg: "3",
|
|
25
|
+
md: "2",
|
|
26
|
+
xl: "3",
|
|
27
|
+
xs: "1"
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=button.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/test/button.test.ts"],"sourcesContent":["import { convertSizeResponse } from '../utils/convert-button-size';\n\ndescribe('convertSizeResponse', () => {\n test('converts size to radix size', () => {\n expect(convertSizeResponse('small')).toBe('1');\n expect(convertSizeResponse('medium')).toBe('2');\n expect(convertSizeResponse('large')).toBe('3');\n });\n\n test('converts size object to radix size object', () => {\n expect(\n convertSizeResponse({\n initial: 'small',\n lg: 'large',\n md: 'medium',\n xl: 'large',\n xs: 'small',\n })\n ).toEqual({\n initial: '1',\n lg: '3',\n md: '2',\n xl: '3',\n xs: '1',\n });\n });\n});\n"],"mappings":";;;;;;AAEA,SAAS,uBAAuB,MAAM;AACpC,OAAK,+BAA+B,MAAM;AACxC,WAAO,oBAAoB,OAAO,CAAC,EAAE,KAAK,GAAG;AAC7C,WAAO,oBAAoB,QAAQ,CAAC,EAAE,KAAK,GAAG;AAC9C,WAAO,oBAAoB,OAAO,CAAC,EAAE,KAAK,GAAG;AAAA,EAC/C,CAAC;AAED,OAAK,6CAA6C,MAAM;AACtD;AAAA,MACE,oBAAoB;AAAA,QAClB,SAAS;AAAA,QACT,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,MACN,CAAC;AAAA,IACH,EAAE,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IACN,CAAC;AAAA,EACH,CAAC;AACH,CAAC;","names":[]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/utils/convert-button-size.ts
|
|
21
|
+
var convert_button_size_exports = {};
|
|
22
|
+
__export(convert_button_size_exports, {
|
|
23
|
+
convertSize: () => convertSize,
|
|
24
|
+
convertSizeResponse: () => convertSizeResponse,
|
|
25
|
+
convertSizeStr: () => convertSizeStr
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(convert_button_size_exports);
|
|
28
|
+
var convertSizeStr = (size) => {
|
|
29
|
+
switch (size) {
|
|
30
|
+
case "small":
|
|
31
|
+
return "1";
|
|
32
|
+
case "medium":
|
|
33
|
+
return "2";
|
|
34
|
+
case "large":
|
|
35
|
+
return "3";
|
|
36
|
+
default:
|
|
37
|
+
return "2";
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var convertSizeResponse = (size) => {
|
|
41
|
+
if (typeof size === "string" || typeof size === "undefined") {
|
|
42
|
+
return convertSizeStr(size);
|
|
43
|
+
}
|
|
44
|
+
const radixSize = {};
|
|
45
|
+
let key = "initial";
|
|
46
|
+
for (key in size) {
|
|
47
|
+
radixSize[key] = convertSizeStr(size[key]);
|
|
48
|
+
}
|
|
49
|
+
return radixSize;
|
|
50
|
+
};
|
|
51
|
+
var convertSize = (size) => {
|
|
52
|
+
if (typeof size === "string") {
|
|
53
|
+
return convertSizeStr(size);
|
|
54
|
+
}
|
|
55
|
+
return convertSizeResponse(size);
|
|
56
|
+
};
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
convertSize,
|
|
60
|
+
convertSizeResponse,
|
|
61
|
+
convertSizeStr
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=convert-button-size.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/convert-button-size.ts"],"sourcesContent":["import { type ButtonProps as RadixButtonProps } from '@radix-ui/themes';\nimport type { Breakpoint } from '@radix-ui/themes/props';\nimport type { ButtonProps } from '../atoms/button.type';\n\nexport const convertSizeStr = (\n size: ButtonProps['size']\n): '1' | '2' | '3' | '4' => {\n switch (size) {\n case 'small':\n return '1';\n case 'medium':\n return '2';\n case 'large':\n return '3';\n default:\n return '2';\n }\n};\n\nexport const convertSizeResponse = (\n size: ButtonProps['size']\n): RadixButtonProps['size'] => {\n if (typeof size === 'string' || typeof size === 'undefined') {\n return convertSizeStr(size);\n }\n const radixSize: RadixButtonProps['size'] = {};\n let key: Breakpoint = 'initial';\n for (key in size) {\n radixSize[key] = convertSizeStr(size[key]);\n }\n return radixSize;\n};\n\nexport const convertSize = (\n size: ButtonProps['size']\n): RadixButtonProps['size'] => {\n if (typeof size === 'string') {\n return convertSizeStr(size);\n }\n return convertSizeResponse(size);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,IAAM,iBAAiB,CAC5B,SAC0B;AAC1B,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAEO,IAAM,sBAAsB,CACjC,SAC6B;AAC7B,MAAI,OAAO,SAAS,YAAY,OAAO,SAAS,aAAa;AAC3D,WAAO,eAAe,IAAI;AAAA,EAC5B;AACA,QAAM,YAAsC,CAAC;AAC7C,MAAI,MAAkB;AACtB,OAAK,OAAO,MAAM;AAChB,cAAU,GAAG,IAAI,eAAe,KAAK,GAAG,CAAC;AAAA,EAC3C;AACA,SAAO;AACT;AAEO,IAAM,cAAc,CACzB,SAC6B;AAC7B,MAAI,OAAO,SAAS,UAAU;AAC5B,WAAO,eAAe,IAAI;AAAA,EAC5B;AACA,SAAO,oBAAoB,IAAI;AACjC;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ButtonProps as ButtonProps$1 } from '@radix-ui/themes';
|
|
2
|
+
import { ButtonProps } from '../atoms/button.type.cjs';
|
|
3
|
+
import '@radix-ui/themes/props';
|
|
4
|
+
|
|
5
|
+
declare const convertSizeStr: (size: ButtonProps['size']) => '1' | '2' | '3' | '4';
|
|
6
|
+
declare const convertSizeResponse: (size: ButtonProps['size']) => ButtonProps$1['size'];
|
|
7
|
+
declare const convertSize: (size: ButtonProps['size']) => ButtonProps$1['size'];
|
|
8
|
+
|
|
9
|
+
export { convertSize, convertSizeResponse, convertSizeStr };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ButtonProps as ButtonProps$1 } from '@radix-ui/themes';
|
|
2
|
+
import { ButtonProps } from '../atoms/button.type.js';
|
|
3
|
+
import '@radix-ui/themes/props';
|
|
4
|
+
|
|
5
|
+
declare const convertSizeStr: (size: ButtonProps['size']) => '1' | '2' | '3' | '4';
|
|
6
|
+
declare const convertSizeResponse: (size: ButtonProps['size']) => ButtonProps$1['size'];
|
|
7
|
+
declare const convertSize: (size: ButtonProps['size']) => ButtonProps$1['size'];
|
|
8
|
+
|
|
9
|
+
export { convertSize, convertSizeResponse, convertSizeStr };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/utils/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import "../chunk-ZQ4XMJH7.js";
|
|
2
|
+
import {
|
|
3
|
+
scrollTo
|
|
4
|
+
} from "../chunk-ZXQZRIRS.js";
|
|
2
5
|
import {
|
|
3
6
|
getColumnMeta
|
|
4
7
|
} from "../chunk-W4GH6ZKK.js";
|
|
5
8
|
import {
|
|
6
9
|
getCellAlign
|
|
7
10
|
} from "../chunk-2BPFXK4L.js";
|
|
8
|
-
import {
|
|
9
|
-
scrollTo
|
|
10
|
-
} from "../chunk-ZXQZRIRS.js";
|
|
11
11
|
import "../chunk-N552FDTV.js";
|
|
12
12
|
export {
|
|
13
13
|
getCellAlign,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tipp/ui",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -40,11 +40,13 @@
|
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/echarts": "^4.9.22",
|
|
43
|
+
"@types/jest": "^29.5.12",
|
|
43
44
|
"@types/lodash-es": "^4.17.12",
|
|
44
45
|
"@types/react": "^18.2.61",
|
|
45
46
|
"@types/react-dom": "^18.2.19",
|
|
46
47
|
"autoprefixer": "10.4.19",
|
|
47
48
|
"eslint": "^8.57.0",
|
|
49
|
+
"jest": "^29.7.0",
|
|
48
50
|
"postcss": "8.4.33",
|
|
49
51
|
"postcss-cli": "11.0.0",
|
|
50
52
|
"postcss-combine-duplicated-selectors": "10.0.3",
|
|
@@ -52,10 +54,12 @@
|
|
|
52
54
|
"postcss-discard-empty": "6.0.1",
|
|
53
55
|
"postcss-import": "16.0.0",
|
|
54
56
|
"postcss-nesting": "12.0.2",
|
|
57
|
+
"ts-jest": "^29.2.2",
|
|
58
|
+
"ts-node": "^10.9.2",
|
|
55
59
|
"tsup": "^8.0.2",
|
|
56
60
|
"typescript": "^5.3.3",
|
|
57
|
-
"@tipp/
|
|
58
|
-
"@tipp/
|
|
61
|
+
"@tipp/typescript-config": "1.0.0",
|
|
62
|
+
"@tipp/eslint-config": "1.0.0"
|
|
59
63
|
},
|
|
60
64
|
"scripts": {
|
|
61
65
|
"build": "pnpm run build:js && pnpm run build:css",
|
|
@@ -67,6 +71,7 @@
|
|
|
67
71
|
"dev:js": "pnpm run build:js --watch",
|
|
68
72
|
"lint": "eslint . --max-warnings 0",
|
|
69
73
|
"lint-staged": "lint-staged ./src",
|
|
74
|
+
"test": "jest",
|
|
70
75
|
"type-check": "tsc --noEmit"
|
|
71
76
|
}
|
|
72
77
|
}
|
package/src/atoms/button.tsx
CHANGED
|
@@ -1,29 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Button as RadixButton,
|
|
3
|
-
type ButtonProps as RadixButtonProps,
|
|
4
|
-
} from '@radix-ui/themes';
|
|
5
1
|
import React, { forwardRef, useMemo } from 'react';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
variant?: RadixButtonProps['variant'] | 'transparent';
|
|
10
|
-
};
|
|
2
|
+
import { Button as RadixButton } from '@radix-ui/themes';
|
|
3
|
+
import { convertSize } from '../utils/convert-button-size';
|
|
4
|
+
import type { ButtonProps } from './button.type';
|
|
11
5
|
|
|
12
6
|
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
13
7
|
(props, ref): React.ReactElement => {
|
|
14
8
|
const { size, style, variant, ...restProps } = props;
|
|
15
9
|
|
|
16
10
|
const radixSize = useMemo(() => {
|
|
17
|
-
|
|
18
|
-
case 'small':
|
|
19
|
-
return '1';
|
|
20
|
-
case 'medium':
|
|
21
|
-
return '2';
|
|
22
|
-
case 'large':
|
|
23
|
-
return '3';
|
|
24
|
-
default:
|
|
25
|
-
return '2';
|
|
26
|
-
}
|
|
11
|
+
return convertSize(size);
|
|
27
12
|
}, [size]);
|
|
28
13
|
|
|
29
14
|
const mergedStyle = useMemo<ButtonProps['style']>(() => {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Button as RadixButton,
|
|
3
|
+
type ButtonProps as RadixButtonProps,
|
|
4
|
+
} from '@radix-ui/themes';
|
|
5
|
+
import type { Responsive } from '@radix-ui/themes/props';
|
|
6
|
+
|
|
7
|
+
export type ButtonProps = Omit<RadixButtonProps, 'size' | 'variant'> & {
|
|
8
|
+
size?: Responsive<'small' | 'medium' | 'large'>;
|
|
9
|
+
variant?: RadixButtonProps['variant'] | 'transparent';
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type { Responsive } from '@radix-ui/themes/props';
|
|
13
|
+
export type { RadixButton, RadixButtonProps };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { convertSizeResponse } from '../utils/convert-button-size';
|
|
2
|
+
|
|
3
|
+
describe('convertSizeResponse', () => {
|
|
4
|
+
test('converts size to radix size', () => {
|
|
5
|
+
expect(convertSizeResponse('small')).toBe('1');
|
|
6
|
+
expect(convertSizeResponse('medium')).toBe('2');
|
|
7
|
+
expect(convertSizeResponse('large')).toBe('3');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test('converts size object to radix size object', () => {
|
|
11
|
+
expect(
|
|
12
|
+
convertSizeResponse({
|
|
13
|
+
initial: 'small',
|
|
14
|
+
lg: 'large',
|
|
15
|
+
md: 'medium',
|
|
16
|
+
xl: 'large',
|
|
17
|
+
xs: 'small',
|
|
18
|
+
})
|
|
19
|
+
).toEqual({
|
|
20
|
+
initial: '1',
|
|
21
|
+
lg: '3',
|
|
22
|
+
md: '2',
|
|
23
|
+
xl: '3',
|
|
24
|
+
xs: '1',
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type ButtonProps as RadixButtonProps } from '@radix-ui/themes';
|
|
2
|
+
import type { Breakpoint } from '@radix-ui/themes/props';
|
|
3
|
+
import type { ButtonProps } from '../atoms/button.type';
|
|
4
|
+
|
|
5
|
+
export const convertSizeStr = (
|
|
6
|
+
size: ButtonProps['size']
|
|
7
|
+
): '1' | '2' | '3' | '4' => {
|
|
8
|
+
switch (size) {
|
|
9
|
+
case 'small':
|
|
10
|
+
return '1';
|
|
11
|
+
case 'medium':
|
|
12
|
+
return '2';
|
|
13
|
+
case 'large':
|
|
14
|
+
return '3';
|
|
15
|
+
default:
|
|
16
|
+
return '2';
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const convertSizeResponse = (
|
|
21
|
+
size: ButtonProps['size']
|
|
22
|
+
): RadixButtonProps['size'] => {
|
|
23
|
+
if (typeof size === 'string' || typeof size === 'undefined') {
|
|
24
|
+
return convertSizeStr(size);
|
|
25
|
+
}
|
|
26
|
+
const radixSize: RadixButtonProps['size'] = {};
|
|
27
|
+
let key: Breakpoint = 'initial';
|
|
28
|
+
for (key in size) {
|
|
29
|
+
radixSize[key] = convertSizeStr(size[key]);
|
|
30
|
+
}
|
|
31
|
+
return radixSize;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const convertSize = (
|
|
35
|
+
size: ButtonProps['size']
|
|
36
|
+
): RadixButtonProps['size'] => {
|
|
37
|
+
if (typeof size === 'string') {
|
|
38
|
+
return convertSizeStr(size);
|
|
39
|
+
}
|
|
40
|
+
return convertSizeResponse(size);
|
|
41
|
+
};
|