@teppen/react-ui 0.3.0 → 0.5.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 (57) hide show
  1. package/README.md +75 -7
  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 +2 -0
  18. package/dist/cjs/src/table/filter-form.js.map +1 -0
  19. package/dist/cjs/src/table/filter-icon.js +2 -0
  20. package/dist/cjs/src/table/filter-icon.js.map +1 -0
  21. package/dist/cjs/src/table/filter.js +2 -0
  22. package/dist/cjs/src/table/filter.js.map +1 -0
  23. package/dist/cjs/src/table/header.js +1 -1
  24. package/dist/cjs/src/table/header.js.map +1 -1
  25. package/dist/cjs/src/table/hook.js +1 -1
  26. package/dist/cjs/src/table/hook.js.map +1 -1
  27. package/dist/cjs/src/table/page.js +1 -1
  28. package/dist/cjs/src/table/page.js.map +1 -1
  29. package/dist/esm/node_modules/react-icons/lia/index.js +2 -0
  30. package/dist/esm/node_modules/react-icons/lia/index.js.map +1 -0
  31. package/dist/esm/node_modules/react-icons/lib/iconBase.js +2 -0
  32. package/dist/esm/node_modules/react-icons/lib/iconBase.js.map +1 -0
  33. package/dist/esm/node_modules/react-icons/lib/iconContext.js +2 -0
  34. package/dist/esm/node_modules/react-icons/lib/iconContext.js.map +1 -0
  35. package/dist/esm/node_modules/react-icons/md/index.js +2 -0
  36. package/dist/esm/node_modules/react-icons/md/index.js.map +1 -0
  37. package/dist/esm/src/table/base.js +1 -1
  38. package/dist/esm/src/table/cancel-icon.js +2 -0
  39. package/dist/esm/src/table/cancel-icon.js.map +1 -0
  40. package/dist/esm/src/table/cell.js +1 -1
  41. package/dist/esm/src/table/cell.js.map +1 -1
  42. package/dist/esm/src/table/edit-icon.js +2 -0
  43. package/dist/esm/src/table/edit-icon.js.map +1 -0
  44. package/dist/esm/src/table/filter-form.js +2 -0
  45. package/dist/esm/src/table/filter-form.js.map +1 -0
  46. package/dist/esm/src/table/filter-icon.js +2 -0
  47. package/dist/esm/src/table/filter-icon.js.map +1 -0
  48. package/dist/esm/src/table/filter.js +2 -0
  49. package/dist/esm/src/table/filter.js.map +1 -0
  50. package/dist/esm/src/table/header.js +1 -1
  51. package/dist/esm/src/table/header.js.map +1 -1
  52. package/dist/esm/src/table/hook.js +1 -1
  53. package/dist/esm/src/table/hook.js.map +1 -1
  54. package/dist/esm/src/table/page.js +1 -1
  55. package/dist/esm/src/table/page.js.map +1 -1
  56. package/dist/index.d.ts +25 -4
  57. package/package.json +11 -3
package/README.md CHANGED
@@ -47,7 +47,7 @@ module.exports = {
47
47
 
48
48
  To use this library, you need to import the components you want to use and render them in your React application.
49
49
 
50
- For example, to use the Button component, you can do something like this:
50
+ For example, to use the Table component, you can do something like this:
51
51
 
52
52
  ```tsx
53
53
  import React from "react";
@@ -58,14 +58,29 @@ const App = () => {
58
58
  <div>
59
59
  <Table
60
60
  rows={[
61
- { id: "1", name: "Taro" },
62
- { id: "2", name: "Yoshiko" },
63
- { id: "3", name: "Koki" },
64
- { id: "4", name: "Chisato" },
61
+ { id: "1", name: "Taro", age: 30 },
62
+ { id: "2", name: "Yoshiko", age: 60 },
63
+ { id: "3", name: "Koki", age: 13 },
64
+ { id: "4", name: "Chisato", age: 34 },
65
65
  ]}
66
66
  cols={[
67
- { key: "id", label: "ID" },
68
- { key: "name", label: "名前" },
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" },
69
84
  ]}
70
85
  />
71
86
  </div>
@@ -75,6 +90,59 @@ const App = () => {
75
90
  export default App;
76
91
  ```
77
92
 
93
+ ### Table Component
94
+
95
+ A component that displays a table based on the row and column information passed as arguments. The table component has the following features:
96
+
97
+ - Pagination function
98
+ - Filtering function (only when `label` and `type` are set in the column information)
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)
101
+
102
+ #### Arguments
103
+
104
+ The table component only accepts the arguments `rows` and `cols`. Details for each argument are described below.
105
+
106
+ ##### rows
107
+
108
+ `rows` is an array of the following associative array (`DataObject`). Only id is required and it must be unique within the array. If onClick is set, it is possible to define the behavior when a row is clicked.
109
+
110
+ ```ts
111
+ export type DataObject = {
112
+ [key: string]: any;
113
+ id: number | string;
114
+ onClick?: React.MouseEventHandler<HTMLTableRowElement>;
115
+ };
116
+ ```
117
+
118
+ ##### cols
119
+
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.
121
+
122
+ ```ts
123
+ export type TColumnType = "string" | "number";
124
+
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
+ };
144
+ ```
145
+
78
146
  ## License
79
147
 
80
148
  This library is licensed under MIT license. See LICENSE file for more information.
@@ -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