@croquiscom/pds 7.5.0 → 8.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/components/column-view-controller/ColumnViewController.d.ts +2 -2
  3. package/dist/components/table/DataTable.d.ts +102 -0
  4. package/dist/components/table/DataTable.stories.d.ts +32 -0
  5. package/dist/components/table/DataTableHeader.d.ts +9 -0
  6. package/dist/components/table/DataTableRows.d.ts +11 -0
  7. package/dist/components/table/Table.d.ts +6 -86
  8. package/dist/components/table/Table.stories.d.ts +1 -28
  9. package/dist/components/table/TableCell.d.ts +15 -0
  10. package/dist/components/table/TableCol.d.ts +13 -14
  11. package/dist/components/table/TableColGroup.d.ts +9 -0
  12. package/dist/components/table/TableContainer.d.ts +9 -0
  13. package/dist/components/table/TableRow.d.ts +12 -0
  14. package/dist/components/table/TableSortIndicator.d.ts +1 -2
  15. package/dist/components/table/constants.d.ts +2 -0
  16. package/dist/components/table/index.d.ts +7 -1
  17. package/dist/components/table/reducer.d.ts +2 -2
  18. package/dist/components/table/storybook-helper/custom.argTypes.d.ts +4 -4
  19. package/dist/components/table/storybook-helper/sampleData.d.ts +17 -17
  20. package/dist/components/table/styles.d.ts +14 -0
  21. package/dist/components/table/types.d.ts +16 -16
  22. package/dist/components/table/utils.d.ts +6 -6
  23. package/dist/foundation/colors.d.ts +11 -0
  24. package/dist/foundation/semantic_colors.d.ts +26 -0
  25. package/dist/index.es.js +6 -6
  26. package/dist/index.es.js.map +1 -1
  27. package/dist/index.js +6 -6
  28. package/dist/index.js.map +1 -1
  29. package/package.json +1 -1
  30. package/scripts/jscodeshift-utils.ts +31 -0
  31. package/scripts/table/migrate-table.ts +107 -0
  32. package/dist/components/table/TableHeader.d.ts +0 -9
  33. package/dist/components/table/TableRows.d.ts +0 -11
  34. package/scripts/icons/migrate-icons.ts +0 -54
  35. package/scripts/icons/migration-icon-list.ts +0 -162
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@croquiscom/pds",
3
- "version": "7.5.0",
3
+ "version": "8.1.0",
4
4
  "description": "Design system for Zigzag's Partner Center",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.es.js",
@@ -0,0 +1,31 @@
1
+ import core, { Collection } from 'jscodeshift';
2
+
3
+ export function getImportDeclaration(j: core.JSCodeshift, source: Collection<any>, sourcePath: string) {
4
+ return source.find(j.ImportDeclaration).filter((path) => path.node.source.value === sourcePath);
5
+ }
6
+
7
+ export function hasImportDeclaration(j: core.JSCodeshift, source: Collection<any>, sourcePath: string) {
8
+ return !!source.find(j.ImportDeclaration).filter((path) => path.node.source.value === sourcePath).length;
9
+ }
10
+
11
+ export function getImportSpecifier(
12
+ j: core.JSCodeshift,
13
+ source: Collection<any>,
14
+ specifier: string,
15
+ sourcePath: string,
16
+ ) {
17
+ return source
18
+ .find(j.ImportDeclaration)
19
+ .filter((path) => path.node.source.value === sourcePath)
20
+ .find(j.ImportSpecifier)
21
+ .filter((path) => path.value.imported.name === specifier);
22
+ }
23
+
24
+ export function hasImportSpecifier(
25
+ j: core.JSCodeshift,
26
+ source: Collection<any>,
27
+ specifier: string,
28
+ sourcePath: string,
29
+ ) {
30
+ return !!getImportSpecifier(j, source, specifier, sourcePath)?.length;
31
+ }
@@ -0,0 +1,107 @@
1
+ /**
2
+ * 사용처 사용법
3
+ * step 1
4
+ * npx jscodeshift -t ./node_modules/@croquiscom/pds/scripts/table/migrate-table.ts --extensions=ts,tsx --parser=tsx --ignore-pattern="./node_modules/**" './' --verbose=3
5
+ *
6
+ * step 2
7
+ * step 1 완료 후 prettier를 한 번 실행 해주셔야 합니다.
8
+ * npm run prettier
9
+ * or
10
+ * prettier --write .
11
+ */
12
+ import { getImportDeclaration, hasImportDeclaration, hasImportSpecifier } from '../jscodeshift-utils';
13
+ import { API, FileInfo } from 'jscodeshift';
14
+
15
+ const migrations = {
16
+ Table: 'DataTable',
17
+ TableProps: 'DataTableProps',
18
+ TableColumnBase: 'DataTableColumnBase',
19
+ TableColumnType: 'DataTableColumnType',
20
+ TableColumnsType: 'DataTableColumnsType',
21
+ TableColumnGroupType: 'DataTableColumnGroupType',
22
+ TableRowType: 'DataTableRowType',
23
+ TableRowsType: 'DataTableRowsType',
24
+ TableState: 'DataTableState',
25
+ TableAction: 'DataTableAction',
26
+ };
27
+
28
+ const original_name_list = Object.keys(migrations);
29
+ const migration_entries = Object.entries(migrations);
30
+
31
+ export default function transformer(file: FileInfo, api: API) {
32
+ const j = api.jscodeshift;
33
+ const source = j(file.source);
34
+
35
+ let is_used_comp = false;
36
+ let is_used_props = false;
37
+
38
+ if (!hasImportDeclaration(j, source, '@croquiscom/pds')) {
39
+ return;
40
+ }
41
+
42
+ getImportDeclaration(j, source, '@croquiscom/pds')
43
+ .find(j.ImportSpecifier)
44
+ .filter((path) => original_name_list.includes(path.node.imported.name))
45
+ .forEach((path) => {
46
+ const new_name = migrations[path.node.imported.name];
47
+ if (!new_name) return;
48
+
49
+ if (new_name === 'DataTable') {
50
+ if (source.find(j.Identifier, { name: 'DataTable' }).length) {
51
+ j(path).replaceWith(j.importSpecifier(j.identifier(new_name), j.identifier('PdsDataTable')));
52
+ is_used_comp = true;
53
+ return;
54
+ }
55
+ }
56
+ if (new_name === 'DataTableProps') {
57
+ if (source.find(j.Identifier, { name: 'DataTableProps' }).length) {
58
+ j(path).replaceWith(j.importSpecifier(j.identifier(new_name), j.identifier('PdsDataTableProps')));
59
+ is_used_props = true;
60
+ return;
61
+ }
62
+ }
63
+
64
+ j(path).replaceWith(j.importSpecifier(j.identifier(new_name)));
65
+ });
66
+
67
+ migration_entries
68
+ .filter(([_origin, new_name]) => hasImportSpecifier(j, source, new_name, '@croquiscom/pds'))
69
+ .forEach(([original_name, new_name]) => {
70
+ if (new_name === 'DataTable') {
71
+ source.find(j.JSXIdentifier, { name: original_name }).forEach((path) => {
72
+ j(path).replaceWith(j.jsxIdentifier(is_used_comp ? 'PdsDataTable' : new_name));
73
+ });
74
+ return;
75
+ }
76
+
77
+ source.find(j.Identifier, { name: original_name }).forEach((path) => {
78
+ if (new_name === 'DataTableProps' && is_used_props) {
79
+ j(path).replaceWith('PdsDataTableProps');
80
+ } else {
81
+ j(path).replaceWith(new_name);
82
+ }
83
+ });
84
+
85
+ source
86
+ .find(j.CallExpression, { typeParameters: { type: 'TSTypeParameterInstantiation' } } as any)
87
+ .forEach((path) => {
88
+ const index = (path.node as any).typeParameters.params.findIndex((param) => {
89
+ return j(param).find(j.Identifier, { name: original_name }).length;
90
+ });
91
+
92
+ if (index === -1) return;
93
+
94
+ j((path.node as any).typeParameters.params[index])
95
+ .find(j.Identifier, { name: original_name })
96
+ .forEach((path) => {
97
+ if (new_name === 'DataTableProps' && is_used_props) {
98
+ j(path).replaceWith('PdsDataTableProps');
99
+ } else {
100
+ j(path).replaceWith(j.identifier(new_name));
101
+ }
102
+ });
103
+ });
104
+ });
105
+
106
+ return source.toSource({ quote: 'single' });
107
+ }
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- import { SelectRowsAction, TableRowsType } from './types';
3
- import { TableProps } from './Table';
4
- export interface TableHeaderProps<DataType> extends Pick<TableProps<DataType>, 'columns' | 'rows' | 'stickyHeader' | 'sortBy' | 'sortDirection' | 'onSortBy' | 'selectableRows' | 'hideSelectAll' | 'resize'> {
5
- allSelected?: boolean;
6
- selectedRows?: TableRowsType<DataType>;
7
- onSelectedRows?: (action: SelectRowsAction<DataType>) => void;
8
- }
9
- export declare const TableHeader: <DataType extends object = any>({ columns, rows, stickyHeader, sortBy, sortDirection, allSelected, selectedRows, selectableRows, hideSelectAll, resize, onSelectedRows, onSortBy, }: TableHeaderProps<DataType>) => JSX.Element;
@@ -1,11 +0,0 @@
1
- /// <reference types="react" />
2
- import { TableProps } from './Table';
3
- import { TableRowsType, SelectRowAction } from './types';
4
- interface TableRowsProps<DataType> extends Pick<TableProps<DataType>, 'columns' | 'rows' | 'noDataText' | 'loading' | 'selectableRows' | 'clickableRows' | 'cellHoverStyle' | 'resize'> {
5
- tableContainerAttribute: number;
6
- allSelected?: boolean;
7
- selectedRows?: TableRowsType<DataType>;
8
- onSelectedRow?: (action: SelectRowAction<DataType>) => void;
9
- }
10
- export declare const TableRows: <DataType extends object = any>({ columns, rows, loading, selectableRows, clickableRows, selectedRows, noDataText, cellHoverStyle, tableContainerAttribute, resize, onSelectedRow, }: TableRowsProps<DataType>) => JSX.Element;
11
- export {};
@@ -1,54 +0,0 @@
1
- import { API, FileInfo } from 'jscodeshift';
2
- import { icon_list } from './migration-icon-list';
3
-
4
- const icon_map = new Map();
5
-
6
- icon_list.forEach((icon) => {
7
- icon_map.set(
8
- icon[0].map((name) => `Icon${name}`),
9
- icon[1],
10
- );
11
- });
12
-
13
- const icon_keys = [...icon_map.keys()];
14
-
15
- export default function transformer(file: FileInfo, api: API) {
16
- const j = api.jscodeshift;
17
- const source = j(file.source);
18
-
19
- icon_keys.forEach((keys) => {
20
- keys.forEach((key) => {
21
- source.find(j.Identifier).forEach((path) => {
22
- const target_key = icon_keys.find((keys) => keys.includes(path.node.name));
23
- if (!icon_map.has(target_key)) {
24
- return;
25
- }
26
-
27
- const new_icon = icon_map.get(target_key);
28
-
29
- if (!j(path).isOfType(j.JSXIdentifier)) {
30
- j(path).replaceWith(j.identifier(`Icon${new_icon}`));
31
- return;
32
- }
33
-
34
- if (j.JSXOpeningElement.check(path.parent.node) && path.parent.node.name.name === key) {
35
- const parentPath = j(path.parent);
36
- const has_size_prop = parentPath.find(j.JSXAttribute, { name: { name: 'size' } }).length;
37
- const size = key.match(/(\d+)(?!.*\d)/)[0];
38
- const size_no = Number(size);
39
- const size_prop = j.jsxAttribute(
40
- j.jsxIdentifier('size'),
41
- j.jsxExpressionContainer(j.numericLiteral(size_no)),
42
- );
43
-
44
- path.parent.value.name = j.jsxIdentifier(`Icon${new_icon}`);
45
- if (!has_size_prop && size_no !== 16) {
46
- path.parent.value.attributes.push(size_prop);
47
- }
48
- }
49
- });
50
- });
51
- });
52
-
53
- return source.toSource({ quote: 'single' });
54
- }
@@ -1,162 +0,0 @@
1
- export const icon_list = [
2
- [['ArrowTop16', 'ArrowTop18'], 'ArrowChevronUp'],
3
- [['ArrowBottom16', 'ArrowBottom18'], 'ArrowChevronDown'],
4
- [['ArrowLeft16', 'ArrowLeft18'], 'ArrowChevronLeft'],
5
- [['ArrowRight16', 'ArrowRight18'], 'ArrowChevronRight'],
6
- [['ArrowTriangleUp16'], 'ArrowTriangleUp'],
7
- [['ArrowTriangleDown16'], 'ArrowTriangleDown'],
8
- [['ArrowLineUp20'], 'ArrowDirectionUp'],
9
- [['ArrowLineDown20'], 'ArrowDirectionDown'],
10
- [['ArrowLineLeft20'], 'ArrowDirectionLeft'],
11
- [['ArrowLineRight20'], 'ArrowDirectionRight'],
12
- [['ArrowIncrease10'], 'ArrowIncrease'],
13
- [['ArrowDecrease10'], 'ArrowDecrease'],
14
- [['StatusNo16', 'CloseSmall16', 'CloseMedium24'], 'X'],
15
- [['Check14', 'Check24'], 'Check'],
16
- [['CircleCheckLine16', 'Done20'], 'CircleCheck'],
17
- [['CircleCheckFill16'], 'CircleCheckFill'],
18
- [['Alert16', 'Alert20', 'Warning24', 'EmptyNoti50', 'Alert50'], 'CircleWarning'],
19
- [['AlertFill20'], 'CircleWarningFill'],
20
- [['Info14', 'Info16', 'Info24'], 'CircleInfo'],
21
- [['InfoFill20'], 'CircleInfoFill'],
22
- [['Help14', 'Help16'], 'CircleQuestion'],
23
- [['Order24'], 'Checklist'],
24
- [['Refund24'], 'BoxX'],
25
- [['Exchange24'], 'BoxReturn'],
26
- [['Question24'], 'Message'],
27
- [['Alert24'], 'TriangleWarning'],
28
- [['Plus16', 'Plus20'], 'Plus'],
29
- [['Minus20'], 'Minus'],
30
- [['CirclePlus14', 'Charge20'], 'CirclePlus'],
31
- [['CircleMinus14'], 'CircleMinus'],
32
- [['AutoCharge20'], 'CircleAutoCharge'],
33
- [['Won16', 'CircleWon18', 'CircleWon24', 'Account24'], 'CircleWon'],
34
- [['OutlinkTwo14'], 'LinkExternal'],
35
- [['Thumbup14'], 'ThumbsUp'],
36
- [['IndentArrow14'], 'ArrowIndent'],
37
- [['Copy14'], 'Copy'],
38
- [['StatusYes16'], 'Circle'],
39
- [['Refresh14'], 'Refresh'],
40
- [['Search14'], 'Search'],
41
- [['Doc14'], 'Document'],
42
- [['Below10'], 'Below'],
43
- [['Status10'], 'CircleFill'],
44
- [['Move10'], 'Move'],
45
- [['New10'], 'New'],
46
- [['Star10'], 'Star'],
47
- [['IdeaLine24'], 'Bulb'],
48
- [['IdeaFill24'], 'BulbFill'],
49
- [['CircleCard24'], 'CircleCreditCard'],
50
- [['Subscription24'], 'Subscription'],
51
- [['Picture24', 'Promotion24'], 'Picture'],
52
- [['Megaphone14', 'Notice24'], 'Megaphone'],
53
- [['Lock18'], 'Unlock'],
54
- [['Locked16'], 'Lock'],
55
- [['Email18'], 'Email'],
56
- [['Vvip18'], 'Vvip'],
57
- [['Link16'], 'Link'],
58
- [['LinkCircle16'], 'CircleLinkFill'],
59
- [['Edit16'], 'Edit'],
60
- [['EyeOn16'], 'EyeOn'],
61
- [['EyeOff16'], 'EyeOff'],
62
- [['Error16'], 'Warning'],
63
- [['Video16'], 'CirclePlayFill'],
64
- [['Play20'], 'PlayFill'],
65
- [['Pause20'], 'PauseFill'],
66
- [['DeleteCircleFill20'], 'CircleXFill'],
67
- [['LoadingDonuts30'], 'LoadingDonuts'],
68
- [['LoadingDots30'], 'LoadingDots'],
69
- [['Graph24'], 'BarChart'],
70
- [['Powerup24'], 'Rocket'],
71
- [['Cs24'], 'Counselor'],
72
- [['Cart24'], 'Cart'],
73
- [['Product24'], 'Hanger'],
74
- [['Exhibition24'], 'Layout'],
75
- [['Delivery24'], 'ZDelivery'],
76
- [['ChargeCoupon20', 'Coupon24'], 'Coupon'],
77
- [['Dashboard24'], 'HomeDashboard'],
78
- [['Store24'], 'Store'],
79
- [['Contract24'], 'Contract'],
80
- [['MemoDefault20', 'Message24'], 'Comment'],
81
- [['MemoAttention20'], 'CommentAlert'],
82
- [['Video24'], 'Video'],
83
- [['PartnerSupport24'], 'Handshake'],
84
- [['Upload50'], 'Upload'],
85
- [['DocConfirm50'], 'DocumentCheck'],
86
- [['Spoid20'], 'Spoid'],
87
- [['Camera20'], 'Camera'],
88
- [['PenaltyGood20'], 'FaceSmileFill'],
89
- [['PenaltyNotsobad20'], 'FaceNeutralFill'],
90
- [['PenaltyBad20'], 'FaceBadFill'],
91
- [['Ordering16'], 'Sort'],
92
- [['TableMove16'], 'ThreeBars'],
93
- [['Pin16'], 'Pin'],
94
- [['Clock16'], 'Clock'],
95
- [['Calendar16'], 'Calendar'],
96
- [['Crop16'], 'Crop'],
97
- [['DiscountTag16'], 'DiscountTagFill'],
98
- [['Zoomin16'], 'ZoomIn'],
99
- [['Best16'], 'BoxBestFill'],
100
- [['Interest16'], 'BoxFingerOffFill'],
101
- [['NotExposed16'], 'BoxEyeOffFill'],
102
- [['SluggishSales16'], 'BoxGraphDownFill'],
103
- [['SteadySeller16'], 'BoxCartFill'],
104
- [['ZigzagWeb16'], 'ZigzagWeb'],
105
- [['Excel16'], 'Excel'],
106
- [['Instagram16'], 'CircleInstagram'],
107
- [['YouTube16'], 'CircleYouTube'],
108
- [['TikTok16'], 'CircleTikTok'],
109
- [['Blog16'], 'CircleBlog'],
110
- [['Zigzag16'], 'BoxZigzag'],
111
- [['Fbk16'], 'BoxFbk'],
112
- [['Posty16'], 'BoxPosty'],
113
- [['Mystore16'], 'BoxMystore'],
114
- [['ZigzagKor16'], 'BoxKorea'],
115
- [['ZigzagJpn16'], 'BoxJapan'],
116
- [['ZigzagEng16'], 'BoxUSA'],
117
- [['ZigzagCan16'], 'BoxCanada'],
118
- [['ZigzagGlobal16'], 'BoxGlobal'],
119
- [['Home16'], 'BoxHome'],
120
- [['NumOne18'], 'NumOneFill'],
121
- [['NumTwo18'], 'NumTwoFill'],
122
- [['NumThree18'], 'NumThreeFill'],
123
- [['NumFour18'], 'NumFourFill'],
124
- [['NumFive18'], 'NumFiveFill'],
125
- [['NumSix18'], 'NumSixFill'],
126
- [['NumSeven18'], 'NumSevenFill'],
127
- [['NumEight18'], 'NumEightFill'],
128
- [['NumNine18'], 'NumNineFill'],
129
- [['NumTen18'], 'NumTenFill'],
130
- [['Pin24'], 'PinColor'],
131
- [['Brand72'], 'CategoryBrand'],
132
- [['Shop72'], 'CategoryShop'],
133
- [['Beauty72'], 'CategoryBeauty'],
134
- [['Life72'], 'CategoryLife'],
135
- [['Kids72'], 'CategoryKids'],
136
- [['Delivery72'], 'CategoryZDelivery'],
137
- [['GlobalDelivery72'], 'CategoryDeliveryGlobal'],
138
- [['OrderAmount18'], 'ColoredMoneyBag'],
139
- [['Orders18'], 'ColoredDocument'],
140
- [['Cvr18'], 'ColoredMoneyFly'],
141
- [['Heart18'], 'ColoredHeart'],
142
- [['Bookmark18'], 'ColoredStar'],
143
- [['Coupon18'], 'ColoredCoupon'],
144
- [['Grade18'], 'ColoredMedal'],
145
- [['Ranking18'], 'ColoredRanking'],
146
- [['Trend18'], 'ColoredPulse'],
147
- [['TrendIncreasing18'], 'ColoredGraphUp'],
148
- [['TrendDecreasing18'], 'ColoredGraphDown'],
149
- [['BarChart18'], 'ColoredBarChart'],
150
- [['Click18'], 'ColoredEyes'],
151
- [['Cart18'], 'ColoredShoppingBag'],
152
- [['User18'], 'ColoredPerson'],
153
- [['One18'], 'ColoredOneFinger'],
154
- [['Two18'], 'ColoredTwoFingers'],
155
- [['Tip18'], 'ColoredTip'],
156
- [['AlertTriangle18'], 'ColoredWarning'],
157
- [['Write18'], 'ColoredWrite'],
158
- [['Excel18'], 'ColoredExcel'],
159
- [['Confetti18'], 'ColoredConfetti'],
160
- [['Check18'], 'ColoredCheck'],
161
- [['Return18'], 'ColoredReturn'],
162
- ] as const;