@tipp/ui 1.0.26 → 1.0.27

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.
@@ -1,3 +1,4 @@
1
+ import "../chunk-PSINRHYW.js";
1
2
  import {
2
3
  Chart,
3
4
  chart_theme_default
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-PSINRHYW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,104 @@
1
+ import {
2
+ Flex
3
+ } from "./chunk-25HMMI7R.js";
4
+ import {
5
+ IconButton
6
+ } from "./chunk-O3DNDMV3.js";
7
+ import {
8
+ Typo
9
+ } from "./chunk-O3XTRD7R.js";
10
+ import {
11
+ ChevronLeftIcon,
12
+ ChevronRightIcon
13
+ } from "./chunk-4UZQXJQO.js";
14
+ import {
15
+ __spreadProps,
16
+ __spreadValues
17
+ } from "./chunk-N552FDTV.js";
18
+
19
+ // src/atoms/pagination.tsx
20
+ import { useCallback, useEffect, useMemo, useState } from "react";
21
+ import { jsx, jsxs } from "react/jsx-runtime";
22
+ function Pagination(props) {
23
+ const { onChange, count = 0 } = props;
24
+ const siblingCount = 2;
25
+ const [page, setPage] = useState(() => props.page || props.defaultPage || 1);
26
+ const visibleItems = useMemo(() => {
27
+ let start = Math.max(1, page - siblingCount);
28
+ let end = Math.min(count, page + siblingCount);
29
+ if (page - siblingCount <= 0 && end < count) {
30
+ end = Math.min(count, end + Math.abs(page - siblingCount) + 1);
31
+ } else if (page + siblingCount > count && start > 1) {
32
+ start = Math.max(1, start - (page + siblingCount - count));
33
+ }
34
+ return Array.from({ length: end - start + 1 }, (_, i) => i + start);
35
+ }, [count, page]);
36
+ useEffect(() => {
37
+ onChange == null ? void 0 : onChange(page);
38
+ }, [onChange, page]);
39
+ useEffect(() => {
40
+ if (props.page) {
41
+ setPage(props.page);
42
+ }
43
+ }, [props.page]);
44
+ const onClickPrev = useCallback(() => {
45
+ setPage((prev) => Math.max(1, prev - 1));
46
+ }, []);
47
+ const onClickNext = useCallback(() => {
48
+ setPage((prev) => Math.min(count, prev + 1));
49
+ }, [count]);
50
+ const moveButtonProps = {
51
+ variant: "ghost",
52
+ size: "3",
53
+ style: { borderRadius: "50%" }
54
+ };
55
+ const iconSize = {
56
+ height: 24,
57
+ width: 24
58
+ };
59
+ const prevDisabled = useMemo(() => {
60
+ return page - siblingCount <= 1;
61
+ }, [page]);
62
+ const nextDisabled = useMemo(() => {
63
+ return page + siblingCount >= count;
64
+ }, [count, page]);
65
+ return /* @__PURE__ */ jsxs(Flex, { align: "center", className: "tipp-pagination", gap: "4", children: [
66
+ /* @__PURE__ */ jsx(
67
+ IconButton,
68
+ __spreadProps(__spreadValues({
69
+ disabled: prevDisabled,
70
+ onClick: onClickPrev
71
+ }, moveButtonProps), {
72
+ children: /* @__PURE__ */ jsx(ChevronLeftIcon, __spreadValues({}, iconSize))
73
+ })
74
+ ),
75
+ /* @__PURE__ */ jsx(Flex, { gap: "1", children: visibleItems.map((item) => {
76
+ return /* @__PURE__ */ jsx(
77
+ "button",
78
+ {
79
+ className: `page-button ${item === page ? "active" : ""}`,
80
+ onClick: () => {
81
+ setPage(item);
82
+ },
83
+ type: "button",
84
+ children: /* @__PURE__ */ jsx(Typo, { variant: "body", children: item })
85
+ },
86
+ item
87
+ );
88
+ }) }),
89
+ /* @__PURE__ */ jsx(
90
+ IconButton,
91
+ __spreadProps(__spreadValues({
92
+ disabled: nextDisabled,
93
+ onClick: onClickNext
94
+ }, moveButtonProps), {
95
+ children: /* @__PURE__ */ jsx(ChevronRightIcon, __spreadValues({}, iconSize))
96
+ })
97
+ )
98
+ ] });
99
+ }
100
+
101
+ export {
102
+ Pagination
103
+ };
104
+ //# sourceMappingURL=chunk-XG4N7OQF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/atoms/pagination.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from 'react';\nimport { ChevronLeftIcon, ChevronRightIcon } from '../icon';\nimport type { IconButtonProps } from './icon-button';\nimport { IconButton } from './icon-button';\nimport { Flex } from './flex';\nimport { Typo } from './typo';\n\nexport interface PaginationProps {\n /** 현재 선택된 페이지 */\n page?: number;\n /** 기본 선택 페이지, page보다 낮은 우선 순위를 갖는다 */\n defaultPage?: number;\n /** 선택한 페이지 변경 이벤트 cb */\n onChange?: (page: number) => void;\n /** 전체 페이지의 수 */\n count?: number;\n}\n\nexport function Pagination(props: PaginationProps): React.ReactNode {\n const { onChange, count = 0 } = props;\n const siblingCount = 2;\n\n const [page, setPage] = useState(() => props.page || props.defaultPage || 1);\n\n const visibleItems = useMemo(() => {\n let start = Math.max(1, page - siblingCount);\n let end = Math.min(count, page + siblingCount);\n if (page - siblingCount <= 0 && end < count) {\n end = Math.min(count, end + Math.abs(page - siblingCount) + 1);\n } else if (page + siblingCount > count && start > 1) {\n start = Math.max(1, start - (page + siblingCount - count));\n }\n\n return Array.from({ length: end - start + 1 }, (_, i) => i + start);\n }, [count, page]);\n\n useEffect(() => {\n onChange?.(page);\n }, [onChange, page]);\n\n useEffect(() => {\n if (props.page) {\n setPage(props.page);\n }\n }, [props.page]);\n\n const onClickPrev = useCallback(() => {\n setPage((prev) => Math.max(1, prev - 1));\n }, []);\n\n const onClickNext = useCallback(() => {\n setPage((prev) => Math.min(count, prev + 1));\n }, [count]);\n\n const moveButtonProps: IconButtonProps = {\n variant: 'ghost',\n size: '3',\n style: { borderRadius: '50%' },\n };\n\n const iconSize = {\n height: 24,\n width: 24,\n };\n\n const prevDisabled = useMemo(() => {\n return page - siblingCount <= 1;\n }, [page]);\n\n const nextDisabled = useMemo(() => {\n return page + siblingCount >= count;\n }, [count, page]);\n\n return (\n <Flex align=\"center\" className=\"tipp-pagination\" gap=\"4\">\n <IconButton\n disabled={prevDisabled}\n onClick={onClickPrev}\n {...moveButtonProps}\n >\n <ChevronLeftIcon {...iconSize} />\n </IconButton>\n <Flex gap=\"1\">\n {visibleItems.map((item) => {\n return (\n <button\n className={`page-button ${item === page ? 'active' : ''}`}\n key={item}\n onClick={() => {\n setPage(item);\n }}\n type=\"button\"\n >\n <Typo variant=\"body\">{item}</Typo>\n </button>\n );\n })}\n </Flex>\n <IconButton\n disabled={nextDisabled}\n onClick={onClickNext}\n {...moveButtonProps}\n >\n <ChevronRightIcon {...iconSize} />\n </IconButton>\n </Flex>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,SAAgB,aAAa,WAAW,SAAS,gBAAgB;AA0E7D,SAMI,KANJ;AAxDG,SAAS,WAAW,OAAyC;AAClE,QAAM,EAAE,UAAU,QAAQ,EAAE,IAAI;AAChC,QAAM,eAAe;AAErB,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,MAAM,MAAM,QAAQ,MAAM,eAAe,CAAC;AAE3E,QAAM,eAAe,QAAQ,MAAM;AACjC,QAAI,QAAQ,KAAK,IAAI,GAAG,OAAO,YAAY;AAC3C,QAAI,MAAM,KAAK,IAAI,OAAO,OAAO,YAAY;AAC7C,QAAI,OAAO,gBAAgB,KAAK,MAAM,OAAO;AAC3C,YAAM,KAAK,IAAI,OAAO,MAAM,KAAK,IAAI,OAAO,YAAY,IAAI,CAAC;AAAA,IAC/D,WAAW,OAAO,eAAe,SAAS,QAAQ,GAAG;AACnD,cAAQ,KAAK,IAAI,GAAG,SAAS,OAAO,eAAe,MAAM;AAAA,IAC3D;AAEA,WAAO,MAAM,KAAK,EAAE,QAAQ,MAAM,QAAQ,EAAE,GAAG,CAAC,GAAG,MAAM,IAAI,KAAK;AAAA,EACpE,GAAG,CAAC,OAAO,IAAI,CAAC;AAEhB,YAAU,MAAM;AACd,yCAAW;AAAA,EACb,GAAG,CAAC,UAAU,IAAI,CAAC;AAEnB,YAAU,MAAM;AACd,QAAI,MAAM,MAAM;AACd,cAAQ,MAAM,IAAI;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,MAAM,IAAI,CAAC;AAEf,QAAM,cAAc,YAA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;AAEJ;","names":[]}
package/dist/index.cjs CHANGED
@@ -71,6 +71,7 @@ __export(src_exports, {
71
71
  Button: () => Button,
72
72
  Callout: () => import_themes8.Callout,
73
73
  Card: () => import_themes9.Card,
74
+ Chart: () => Chart,
74
75
  ChatBubbleIcon: () => import_react_icons.ChatBubbleIcon,
75
76
  Checkbox: () => Checkbox,
76
77
  CheckboxCards: () => import_themes11.CheckboxCards,
@@ -104,6 +105,7 @@ __export(src_exports, {
104
105
  GearIcon: () => import_react_icons.GearIcon,
105
106
  Grid: () => import_themes20.Grid,
106
107
  Heading: () => Heading2,
108
+ HorizontalBarChart: () => HorizontalBarChart,
107
109
  HoverCard: () => import_themes23.HoverCard,
108
110
  IconButton: () => import_themes24.IconButton,
109
111
  InfoCircledIcon: () => import_react_icons.InfoCircledIcon,
@@ -144,6 +146,7 @@ __export(src_exports, {
144
146
  TrashIcon: () => import_react_icons.TrashIcon,
145
147
  Trigger: () => Trigger2,
146
148
  Typo: () => Typo,
149
+ chartTheme: () => chart_theme_default,
147
150
  createColumnHelper: () => import_react_table2.createColumnHelper,
148
151
  toast: () => import_react_toastify2.toast,
149
152
  uiProps: () => uiProps,
@@ -1099,6 +1102,200 @@ var import_themes51 = require("@radix-ui/themes");
1099
1102
 
1100
1103
  // src/ui-props/index.ts
1101
1104
  var uiProps = __toESM(require("@radix-ui/themes/dist/cjs/props/index.js"), 1);
1105
+
1106
+ // src/charts/chart.tsx
1107
+ var import_react16 = require("react");
1108
+ var import_react_resize_detector = require("react-resize-detector");
1109
+ var import_echarts_for_react = __toESM(require("echarts-for-react"), 1);
1110
+ var import_lodash_es = require("lodash-es");
1111
+
1112
+ // src/charts/chart-theme.json
1113
+ var chart_theme_default = {
1114
+ version: 1,
1115
+ themeName: "customed",
1116
+ theme: {
1117
+ seriesCnt: "5",
1118
+ backgroundColor: "rgba(0,0,0,0)",
1119
+ titleColor: "#1c2024",
1120
+ subtitleColor: "#8d8d8d",
1121
+ textColorShow: false,
1122
+ textColor: "#333",
1123
+ markTextColor: "#ffffff",
1124
+ color: [
1125
+ "#ffe629",
1126
+ "#3e63dd",
1127
+ "#ec9455",
1128
+ "#5bb98b",
1129
+ "#cb1d63",
1130
+ "#3ba272",
1131
+ "#fc8452",
1132
+ "#9a60b4",
1133
+ "#ea7ccc"
1134
+ ],
1135
+ borderColor: "#8d8d8d",
1136
+ borderWidth: 0,
1137
+ visualMapColor: ["#bf444c", "#d88273", "#f6efa6"],
1138
+ legendTextColor: "#1c2024",
1139
+ kColor: "#eb5454",
1140
+ kColor0: "#47b262",
1141
+ kBorderColor: "#eb5454",
1142
+ kBorderColor0: "#47b262",
1143
+ kBorderWidth: 1,
1144
+ lineWidth: 2,
1145
+ symbolSize: 4,
1146
+ symbol: "emptyCircle",
1147
+ symbolBorderWidth: 1,
1148
+ lineSmooth: false,
1149
+ graphLineWidth: 1,
1150
+ graphLineColor: "#aaa",
1151
+ mapLabelColor: "#000",
1152
+ mapLabelColorE: "rgb(100,0,0)",
1153
+ mapBorderColor: "#444",
1154
+ mapBorderColorE: "#444",
1155
+ mapBorderWidth: 0.5,
1156
+ mapBorderWidthE: 1,
1157
+ mapAreaColor: "#eee",
1158
+ mapAreaColorE: "rgba(255,215,0,0.8)",
1159
+ axes: [
1160
+ {
1161
+ type: "all",
1162
+ name: "\u901A\u7528\u5750\u6807\u8F74",
1163
+ axisLineShow: true,
1164
+ axisLineColor: "#6E7079",
1165
+ axisTickShow: true,
1166
+ axisTickColor: "#6E7079",
1167
+ axisLabelShow: true,
1168
+ axisLabelColor: "#6E7079",
1169
+ splitLineShow: true,
1170
+ splitLineColor: ["#E0E6F1"],
1171
+ splitAreaShow: false,
1172
+ splitAreaColor: ["rgba(250,250,250,0.2)", "rgba(210,219,238,0.2)"]
1173
+ },
1174
+ {
1175
+ type: "category",
1176
+ name: "\u7C7B\u76EE\u5750\u6807\u8F74",
1177
+ axisLineShow: true,
1178
+ axisLineColor: "#6E7079",
1179
+ axisTickShow: true,
1180
+ axisTickColor: "#6E7079",
1181
+ axisLabelShow: true,
1182
+ axisLabelColor: "#6E7079",
1183
+ splitLineShow: false,
1184
+ splitLineColor: ["#E0E6F1"],
1185
+ splitAreaShow: false,
1186
+ splitAreaColor: ["rgba(250,250,250,0.2)", "rgba(210,219,238,0.2)"]
1187
+ },
1188
+ {
1189
+ type: "value",
1190
+ name: "\u6570\u503C\u5750\u6807\u8F74",
1191
+ axisLineShow: false,
1192
+ axisLineColor: "#6E7079",
1193
+ axisTickShow: false,
1194
+ axisTickColor: "#6E7079",
1195
+ axisLabelShow: true,
1196
+ axisLabelColor: "#6E7079",
1197
+ splitLineShow: true,
1198
+ splitLineColor: ["#E0E6F1"],
1199
+ splitAreaShow: false,
1200
+ splitAreaColor: ["rgba(250,250,250,0.2)", "rgba(210,219,238,0.2)"]
1201
+ },
1202
+ {
1203
+ type: "log",
1204
+ name: "\u5BF9\u6570\u5750\u6807\u8F74",
1205
+ axisLineShow: false,
1206
+ axisLineColor: "#6E7079",
1207
+ axisTickShow: false,
1208
+ axisTickColor: "#6E7079",
1209
+ axisLabelShow: true,
1210
+ axisLabelColor: "#6E7079",
1211
+ splitLineShow: true,
1212
+ splitLineColor: ["#E0E6F1"],
1213
+ splitAreaShow: false,
1214
+ splitAreaColor: ["rgba(250,250,250,0.2)", "rgba(210,219,238,0.2)"]
1215
+ },
1216
+ {
1217
+ type: "time",
1218
+ name: "\u65F6\u95F4\u5750\u6807\u8F74",
1219
+ axisLineShow: true,
1220
+ axisLineColor: "#6E7079",
1221
+ axisTickShow: true,
1222
+ axisTickColor: "#6E7079",
1223
+ axisLabelShow: true,
1224
+ axisLabelColor: "#6E7079",
1225
+ splitLineShow: false,
1226
+ splitLineColor: ["#E0E6F1"],
1227
+ splitAreaShow: false,
1228
+ splitAreaColor: ["rgba(250,250,250,0.2)", "rgba(210,219,238,0.2)"]
1229
+ }
1230
+ ],
1231
+ axisSeperateSetting: true,
1232
+ toolboxColor: "#8d8d8d",
1233
+ toolboxEmphasisColor: "#1c2024",
1234
+ tooltipAxisColor: "#cccccc",
1235
+ tooltipAxisWidth: 1,
1236
+ timelineLineColor: "#dae1f5",
1237
+ timelineLineWidth: 2,
1238
+ timelineItemColor: "#a4b1d7",
1239
+ timelineItemColorE: "#ffffff",
1240
+ timelineCheckColor: "#316bf3",
1241
+ timelineCheckBorderColor: "#ffffff",
1242
+ timelineItemBorderWidth: 1,
1243
+ timelineControlColor: "#a4b1d7",
1244
+ timelineControlBorderColor: "#a4b1d7",
1245
+ timelineControlBorderWidth: 1,
1246
+ timelineLabelColor: "#a4b1d7"
1247
+ }
1248
+ };
1249
+
1250
+ // src/charts/chart.tsx
1251
+ var import_jsx_runtime23 = require("react/jsx-runtime");
1252
+ function Chart(props) {
1253
+ const { width, height, ref } = (0, import_react_resize_detector.useResizeDetector)({
1254
+ handleHeight: false,
1255
+ refreshMode: "debounce",
1256
+ refreshRate: 100
1257
+ });
1258
+ const option = (0, import_react16.useMemo)(() => {
1259
+ const baseOption = {
1260
+ textStyle: { fontFamily: "Noto Sans KR" },
1261
+ tooltip: { textStyle: { fontSize: 16 } }
1262
+ };
1263
+ return (0, import_lodash_es.merge)(baseOption, props.option);
1264
+ }, [props.option]);
1265
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { ref, style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
1266
+ import_echarts_for_react.default,
1267
+ __spreadProps(__spreadValues({
1268
+ opts: { renderer: "svg" },
1269
+ style: { width, height },
1270
+ theme: chart_theme_default
1271
+ }, props), {
1272
+ option
1273
+ })
1274
+ ) });
1275
+ }
1276
+
1277
+ // src/charts/horizontal-bar-chart.tsx
1278
+ var import_jsx_runtime24 = require("react/jsx-runtime");
1279
+ function HorizontalBarChart(props) {
1280
+ const { total, value, backgroundColor, barColor, height } = props;
1281
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
1282
+ "div",
1283
+ {
1284
+ className: "tipp_horizontal-bar-chart bar-wrapper",
1285
+ style: { height, backgroundColor },
1286
+ children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
1287
+ "div",
1288
+ {
1289
+ style: {
1290
+ width: `${Math.round(value / total * 100)}%`,
1291
+ height: "100%"
1292
+ },
1293
+ children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "bar", style: { backgroundColor: barColor } })
1294
+ }
1295
+ )
1296
+ }
1297
+ );
1298
+ }
1102
1299
  // Annotate the CommonJS export names for ESM import in node:
1103
1300
  0 && (module.exports = {
1104
1301
  AlertDialog,
@@ -1113,6 +1310,7 @@ var uiProps = __toESM(require("@radix-ui/themes/dist/cjs/props/index.js"), 1);
1113
1310
  Button,
1114
1311
  Callout,
1115
1312
  Card,
1313
+ Chart,
1116
1314
  ChatBubbleIcon,
1117
1315
  Checkbox,
1118
1316
  CheckboxCards,
@@ -1146,6 +1344,7 @@ var uiProps = __toESM(require("@radix-ui/themes/dist/cjs/props/index.js"), 1);
1146
1344
  GearIcon,
1147
1345
  Grid,
1148
1346
  Heading,
1347
+ HorizontalBarChart,
1149
1348
  HoverCard,
1150
1349
  IconButton,
1151
1350
  InfoCircledIcon,
@@ -1186,6 +1385,7 @@ var uiProps = __toESM(require("@radix-ui/themes/dist/cjs/props/index.js"), 1);
1186
1385
  TrashIcon,
1187
1386
  Trigger,
1188
1387
  Typo,
1388
+ chartTheme,
1189
1389
  createColumnHelper,
1190
1390
  toast,
1191
1391
  uiProps,