xlkit 1.0.3 → 1.0.4

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 xlkit contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -134,17 +134,26 @@ header: {
134
134
  ```
135
135
 
136
136
  ### 5. 行スタイル (`rows`)
137
-
138
- 行ごとのスタイル(縞模様など)を定義できます。
139
-
140
- ```typescript
141
- rows: {
142
- style: (data, index) => {
143
- // 偶数行に背景色をつける
144
- return index % 2 === 0 ? { fill: { color: '#F0F0F0' } } : {};
145
- }
146
- }
147
- ```
137
+
138
+ 行ごとのスタイル(縞模様など)を定義できます。
139
+
140
+ ```typescript
141
+ rows: {
142
+ style: (data, index) => {
143
+ // 偶数行に背景色をつける
144
+ return index % 2 === 0 ? { fill: { color: '#F0F0F0' } } : {};
145
+ }
146
+ }
147
+ ```
148
+
149
+ また、データ行に `style` プロパティを含めることで、特定の行にスタイルを適用することも可能です。
150
+
151
+ ```typescript
152
+ const data = [
153
+ { name: 'Tom', age: 28 },
154
+ { name: 'Mary', age: 25, style: { fill: { color: '#FFFF00' } } }, // Maryの行は黄色背景
155
+ ];
156
+ ```
148
157
 
149
158
  ### 6. ブラウザ環境でのダウンロード
150
159
 
@@ -1 +1 @@
1
- {"version":3,"file":"Sheetflow.d.ts","sourceRoot":"","sources":["../src/Sheetflow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAsB,MAAM,SAAS,CAAC;AAGvD,qBAAa,KAAK;IAChB,OAAO,CAAC,QAAQ,CAAmB;;IAMnC,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,KAAK;IAsKzC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBjE,YAAY,CAAC,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC;IAajE,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAiBhF;AAED,wBAAgB,cAAc,IAAI,KAAK,CAEtC;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAE5D"}
1
+ {"version":3,"file":"Sheetflow.d.ts","sourceRoot":"","sources":["../src/Sheetflow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAsB,MAAM,SAAS,CAAC;AAGvD,qBAAa,KAAK;IAChB,OAAO,CAAC,QAAQ,CAAmB;;IAMnC,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,KAAK;IAoLzC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBjE,YAAY,CAAC,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC;IAajE,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAiBhF;AAED,wBAAgB,cAAc,IAAI,KAAK,CAEtC;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAE5D"}
package/dist/Sheetflow.js CHANGED
@@ -29,6 +29,10 @@ class XLKit {
29
29
  // 1. Setup Columns & Headers
30
30
  const columns = def.columns.map((col, colIndex) => {
31
31
  let width = col.width;
32
+ // Validate Column Key
33
+ if (col.key === 'style') {
34
+ throw new Error("Column key 'style' is reserved for row styling and cannot be used as a column key.");
35
+ }
32
36
  if (width === 'auto') {
33
37
  let maxLen = col.header.length * (def.autoWidth?.headerIncluded !== false ? 1 : 0);
34
38
  // Check data length (sample first 100 rows for performance if needed, currently all)
@@ -58,7 +62,7 @@ class XLKit {
58
62
  // 2. Add Data & Apply Row Styles
59
63
  data.forEach((row, rowIndex) => {
60
64
  const addedRow = sheet.addRow(row);
61
- // Apply row-level style
65
+ // Apply row-level style from definition
62
66
  if (def.rows?.style) {
63
67
  const rowStyle = def.rows.style(row, rowIndex);
64
68
  const mappedStyle = (0, style_1.mapStyle)(rowStyle);
@@ -66,6 +70,14 @@ class XLKit {
66
70
  cell.style = { ...cell.style, ...mappedStyle };
67
71
  });
68
72
  }
73
+ // Apply row-level style from data (if 'style' property exists)
74
+ if (row.style) {
75
+ const dataRowStyle = row.style;
76
+ const mappedStyle = (0, style_1.mapStyle)(dataRowStyle);
77
+ addedRow.eachCell((cell) => {
78
+ cell.style = { ...cell.style, ...mappedStyle };
79
+ });
80
+ }
69
81
  // Apply column-level conditional styles
70
82
  def.columns.forEach((col, colIndex) => {
71
83
  if (typeof col.style === 'function') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xlkit",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [