@teppen/react-ui 0.4.0 → 0.5.1

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 (47) hide show
  1. package/README.md +38 -9
  2. package/dist/cjs/node_modules/react-icons/lia/index.js +2 -0
  3. package/dist/cjs/node_modules/react-icons/lia/index.js.map +1 -0
  4. package/dist/cjs/node_modules/react-icons/lib/iconBase.js +2 -0
  5. package/dist/cjs/node_modules/react-icons/lib/iconBase.js.map +1 -0
  6. package/dist/cjs/node_modules/react-icons/lib/iconContext.js +2 -0
  7. package/dist/cjs/node_modules/react-icons/lib/iconContext.js.map +1 -0
  8. package/dist/cjs/node_modules/react-icons/md/index.js +2 -0
  9. package/dist/cjs/node_modules/react-icons/md/index.js.map +1 -0
  10. package/dist/cjs/src/table/base.js +1 -1
  11. package/dist/cjs/src/table/cancel-icon.js +2 -0
  12. package/dist/cjs/src/table/cancel-icon.js.map +1 -0
  13. package/dist/cjs/src/table/cell.js +1 -1
  14. package/dist/cjs/src/table/cell.js.map +1 -1
  15. package/dist/cjs/src/table/edit-icon.js +2 -0
  16. package/dist/cjs/src/table/edit-icon.js.map +1 -0
  17. package/dist/cjs/src/table/filter-form.js +1 -1
  18. package/dist/cjs/src/table/filter-form.js.map +1 -1
  19. package/dist/cjs/src/table/filter-icon.js +1 -1
  20. package/dist/cjs/src/table/filter-icon.js.map +1 -1
  21. package/dist/cjs/src/table/filter.js.map +1 -1
  22. package/dist/cjs/src/table/header.js +1 -1
  23. package/dist/cjs/src/table/header.js.map +1 -1
  24. package/dist/esm/node_modules/react-icons/lia/index.js +2 -0
  25. package/dist/esm/node_modules/react-icons/lia/index.js.map +1 -0
  26. package/dist/esm/node_modules/react-icons/lib/iconBase.js +2 -0
  27. package/dist/esm/node_modules/react-icons/lib/iconBase.js.map +1 -0
  28. package/dist/esm/node_modules/react-icons/lib/iconContext.js +2 -0
  29. package/dist/esm/node_modules/react-icons/lib/iconContext.js.map +1 -0
  30. package/dist/esm/node_modules/react-icons/md/index.js +2 -0
  31. package/dist/esm/node_modules/react-icons/md/index.js.map +1 -0
  32. package/dist/esm/src/table/base.js +1 -1
  33. package/dist/esm/src/table/cancel-icon.js +2 -0
  34. package/dist/esm/src/table/cancel-icon.js.map +1 -0
  35. package/dist/esm/src/table/cell.js +1 -1
  36. package/dist/esm/src/table/cell.js.map +1 -1
  37. package/dist/esm/src/table/edit-icon.js +2 -0
  38. package/dist/esm/src/table/edit-icon.js.map +1 -0
  39. package/dist/esm/src/table/filter-form.js +1 -1
  40. package/dist/esm/src/table/filter-form.js.map +1 -1
  41. package/dist/esm/src/table/filter-icon.js +1 -1
  42. package/dist/esm/src/table/filter-icon.js.map +1 -1
  43. package/dist/esm/src/table/filter.js.map +1 -1
  44. package/dist/esm/src/table/header.js +1 -1
  45. package/dist/esm/src/table/header.js.map +1 -1
  46. package/dist/index.d.ts +21 -3
  47. package/package.json +11 -3
package/README.md CHANGED
@@ -64,9 +64,23 @@ const App = () => {
64
64
  { id: "4", name: "Chisato", age: 34 },
65
65
  ]}
66
66
  cols={[
67
- { key: "id", label: "ID", type: "数値" },
68
- { key: "name", label: "名前", type: "文字列" },
69
- { key: "age", label: "年齢", type: "数値" },
67
+ { key: "id", label: "ID", type: "number" },
68
+ {
69
+ key: "name",
70
+ label: "名前",
71
+ type: "string",
72
+ editable: true,
73
+ constraints: {
74
+ maxLength: 10,
75
+ minLength: 1,
76
+ pattern: "^[a-zA-Z0-9]+$",
77
+ },
78
+ onCellBlur: (key, value, current, completeEditing) => {
79
+ console.log(key, value, current);
80
+ completeEditing();
81
+ },
82
+ },
83
+ { key: "age", label: "年齢", type: "number" },
70
84
  ]}
71
85
  />
72
86
  </div>
@@ -83,6 +97,7 @@ A component that displays a table based on the row and column information passed
83
97
  - Pagination function
84
98
  - Filtering function (only when `label` and `type` are set in the column information)
85
99
  - Sorting function (only when `label` and `type` are set in the column information)
100
+ - Editing function (only when `editable` is true and `onCellBlur` is set in the column information)
86
101
 
87
102
  #### Arguments
88
103
 
@@ -102,18 +117,32 @@ export type DataObject = {
102
117
 
103
118
  ##### cols
104
119
 
105
- In `cols`, you specify the data to be displayed in the table from left to right. The `key` here needs to match the key name in each element of rows. However, it is not necessary to always include the key `id`. `label` and `type` are optional, but they are required for some functions, so it is recommended to set them.
120
+ In `cols`, you specify the data to be displayed in the table from left to right. The `key` here needs to match the key name in each element of rows. However, it is not necessary to always include the key `id`. `label` is optional, but it is required for some functions, so it is recommended to set it.
106
121
 
107
122
  ```ts
108
123
  export type TColumnType = "string" | "number";
109
124
 
110
- export type TTableColumn = { key: string; label?: string; type?: TColumnType };
125
+ export type TTableColumn = {
126
+ key: string;
127
+ type: TColumnType;
128
+ label?: string;
129
+ editable?: boolean;
130
+ constraints?: {
131
+ maxLength?: number; // Only when "type" is "string"
132
+ minLength?: number; // Only when "type" is "string"
133
+ pattern?: string; // Only when "type" is "string"
134
+ max?: number; // Only when "type" is "number"
135
+ min?: number; // Only when "type" is "number"
136
+ };
137
+ onCellBlur?: (
138
+ key: string,
139
+ value: number | string, // Value in cell after change
140
+ current: DataObject, // Row data before change
141
+ completeEditing: () => void // Function to exit cell edit mode
142
+ ) => void;
143
+ };
111
144
  ```
112
145
 
113
146
  ## License
114
147
 
115
148
  This library is licensed under MIT license. See LICENSE file for more information.
116
-
117
- ```
118
-
119
- ```
@@ -0,0 +1,2 @@
1
+ "use strict";var L=require("../lib/iconBase.js");require("../lib/iconContext.js"),exports.LiaEdit=function(t){return L.GenIcon({tag:"svg",attr:{viewBox:"0 0 32 32"},child:[{tag:"path",attr:{d:"M 25 4.03125 C 24.234375 4.03125 23.484375 4.328125 22.90625 4.90625 L 13 14.78125 L 12.78125 15 L 12.71875 15.3125 L 12.03125 18.8125 L 11.71875 20.28125 L 13.1875 19.96875 L 16.6875 19.28125 L 17 19.21875 L 17.21875 19 L 27.09375 9.09375 C 28.246094 7.941406 28.246094 6.058594 27.09375 4.90625 C 26.515625 4.328125 25.765625 4.03125 25 4.03125 Z M 25 5.96875 C 25.234375 5.96875 25.464844 6.089844 25.6875 6.3125 C 26.132813 6.757813 26.132813 7.242188 25.6875 7.6875 L 16 17.375 L 14.28125 17.71875 L 14.625 16 L 24.3125 6.3125 C 24.535156 6.089844 24.765625 5.96875 25 5.96875 Z M 4 8 L 4 28 L 24 28 L 24 14.8125 L 22 16.8125 L 22 26 L 6 26 L 6 10 L 15.1875 10 L 17.1875 8 Z"},child:[]}]})(t)};
2
+ //# sourceMappingURL=index.js.map