@nice2dev/ui-printing 1.0.28 → 1.0.29

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 +1 @@
1
- {"version":3,"file":"NiceTemplateEditor.d.ts","sourceRoot":"","sources":["../../src/template-editor/NiceTemplateEditor.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmF,MAAM,OAAO,CAAC;AAExG,OAAO,KAAK,EAUV,uBAAuB,EAKxB,MAAM,wBAAwB,CAAC;AA6rDhC,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAgoBhE,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"NiceTemplateEditor.d.ts","sourceRoot":"","sources":["../../src/template-editor/NiceTemplateEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAON,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAUV,uBAAuB,EAKxB,MAAM,wBAAwB,CAAC;AAksDhC,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CA+nBhE,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice2dev/ui-printing",
3
- "version": "1.0.28",
3
+ "version": "1.0.29",
4
4
  "description": "React components for print management: template editor, template browser, print preview, print queue and print button",
5
5
  "keywords": [
6
6
  "printing",
@@ -54,7 +54,7 @@
54
54
  }
55
55
  },
56
56
  "devDependencies": {
57
- "@nice2dev/ui": "^1.0.20",
57
+ "@nice2dev/ui": "^1.0.30",
58
58
  "@types/react": "^18.0.0",
59
59
  "@types/react-dom": "^18.0.0",
60
60
  "@vitejs/plugin-react": "^4.2.0",
@@ -1,5 +1,13 @@
1
1
  /* eslint-disable jsx-a11y/click-events-have-key-events -- modal overlay backdrops (Esc-on-parent provides keyboard close), selection rows in .map() accompanied by visible cursor:pointer styling and sibling buttons; full keyboard migration via useAccessibleClick + extracted subcomponents tracked in TODO_1.0.10 A2.3 */
2
- import React, { useState, useCallback, useRef as _useRef, useReducer, useEffect, useMemo } from 'react';
2
+ import { NiceAppShell } from '@nice2dev/ui';
3
+ import React, {
4
+ useState,
5
+ useCallback,
6
+ useRef as _useRef,
7
+ useReducer,
8
+ useEffect,
9
+ useMemo,
10
+ } from 'react';
3
11
 
4
12
  import type {
5
13
  PrintTemplate,
@@ -153,7 +161,12 @@ function makeField(type: string, schemaField?: DataSourceField): PrintDataField
153
161
  base.style.backgroundColor = 'var(--nice-bg-secondary, #f1f5f9)';
154
162
  }
155
163
  if (type === 'line') {
156
- base.style = { ...base.style, borderWidth: 0.5, borderColor: 'var(--nice-text, #000000)', borderStyle: 'solid' };
164
+ base.style = {
165
+ ...base.style,
166
+ borderWidth: 0.5,
167
+ borderColor: 'var(--nice-text, #000000)',
168
+ borderStyle: 'solid',
169
+ };
157
170
  }
158
171
  return base;
159
172
  }
@@ -2242,38 +2255,37 @@ export const NiceTemplateEditor: React.FC<NiceTemplateEditorProps> = ({
2242
2255
  const paperHPx = paperH * zoom * MM_TO_PX;
2243
2256
 
2244
2257
  return (
2245
- <div
2258
+ <NiceAppShell
2259
+ flush
2246
2260
  className={`${styles.root} ${theme === 'dark' ? styles.dark : ''} ${className ?? ''}`}
2247
2261
  style={style}
2248
- onClick={() => setSelectedIds(new Set())}
2249
- >
2250
- <Toolbar
2251
- tpl={tpl}
2252
- zoom={zoom}
2253
- canUndo={past.length > 0}
2254
- canRedo={future.length > 0}
2255
- showGrid={showGrid}
2256
- showRulers={showRulers}
2257
- readOnly={readOnly}
2258
- selectedCount={selectedIds.size}
2259
- onPaperChange={(size, orient) => update({ paperSize: size, orientation: orient })}
2260
- onZoom={setZoom}
2261
- onUndo={() => dispatch({ type: 'UNDO' })}
2262
- onRedo={() => dispatch({ type: 'REDO' })}
2263
- onToggleGrid={() => setShowGrid((g) => !g)}
2264
- onToggleRulers={() => setShowRulers((r) => !r)}
2265
- onInsert={insertField}
2266
- onDelete={deleteSelected}
2267
- onDuplicate={duplicateSelected}
2268
- onAlignH={alignH}
2269
- onAlignV={alignV}
2270
- onBringForward={bringForward}
2271
- onSendBackward={sendBackward}
2272
- onSave={onSave ? () => onSave(tpl) : undefined}
2273
- />
2274
-
2275
- <div className={styles.editorBody}>
2276
- {/* Left panel */}
2262
+ toolbar={
2263
+ <Toolbar
2264
+ tpl={tpl}
2265
+ zoom={zoom}
2266
+ canUndo={past.length > 0}
2267
+ canRedo={future.length > 0}
2268
+ showGrid={showGrid}
2269
+ showRulers={showRulers}
2270
+ readOnly={readOnly}
2271
+ selectedCount={selectedIds.size}
2272
+ onPaperChange={(size, orient) => update({ paperSize: size, orientation: orient })}
2273
+ onZoom={setZoom}
2274
+ onUndo={() => dispatch({ type: 'UNDO' })}
2275
+ onRedo={() => dispatch({ type: 'REDO' })}
2276
+ onToggleGrid={() => setShowGrid((g) => !g)}
2277
+ onToggleRulers={() => setShowRulers((r) => !r)}
2278
+ onInsert={insertField}
2279
+ onDelete={deleteSelected}
2280
+ onDuplicate={duplicateSelected}
2281
+ onAlignH={alignH}
2282
+ onAlignV={alignV}
2283
+ onBringForward={bringForward}
2284
+ onSendBackward={sendBackward}
2285
+ onSave={onSave ? () => onSave(tpl) : undefined}
2286
+ />
2287
+ }
2288
+ sidebar={
2277
2289
  <LeftPanel
2278
2290
  activeTab={leftTab}
2279
2291
  onTabChange={setLeftTab}
@@ -2286,90 +2298,8 @@ export const NiceTemplateEditor: React.FC<NiceTemplateEditorProps> = ({
2286
2298
  onUpdateTpl={(patch) => update(patch)}
2287
2299
  onReorderField={reorderFieldInLayers}
2288
2300
  />
2289
-
2290
- {/* Canvas area */}
2291
- <div className={styles.canvasArea}>
2292
- {/* Test data bar */}
2293
- {Array.isArray(sampleData) && sampleData.length > 0 && (
2294
- <div className={styles.testDataBar}>
2295
- <span className={styles.testDataLabel}>Dane testowe:</span>
2296
- <select
2297
- className={styles.testDataSelect}
2298
- value={testDataIdx}
2299
- onChange={(e) => setTestDataIdx(+e.target.value)}
2300
- >
2301
- {sampleData.map((_, i) => (
2302
- <option key={i} value={i}>
2303
- Rekord {i + 1}
2304
- </option>
2305
- ))}
2306
- </select>
2307
- </div>
2308
- )}
2309
-
2310
- {/* Ruler corner + rulers */}
2311
- {showRulers && (
2312
- <div className={styles.rulerWrapper}>
2313
- <div className={styles.rulerCorner} />
2314
- <Ruler lengthMm={paperW} zoom={zoom} orientation="h" />
2315
- <Ruler lengthMm={paperH} zoom={zoom} orientation="v" />
2316
- </div>
2317
- )}
2318
-
2319
- {/* Scrollable paper area */}
2320
- <div className={styles.paperScroll} onClick={(e) => e.stopPropagation()}>
2321
- <div className={styles.paperShadow} style={{ width: paperWPx, minHeight: paperHPx }}>
2322
- {/* Margin guides */}
2323
- <div
2324
- className={styles.marginGuide}
2325
- style={{
2326
- top: tpl.margins.top * zoom * MM_TO_PX,
2327
- right: tpl.margins.right * zoom * MM_TO_PX,
2328
- bottom: tpl.margins.bottom * zoom * MM_TO_PX,
2329
- left: tpl.margins.left * zoom * MM_TO_PX,
2330
- }}
2331
- />
2332
-
2333
- {/* Watermarks */}
2334
- {(tpl.watermarks ?? []).map((wm) => (
2335
- <div
2336
- key={wm.id}
2337
- className={styles.watermark}
2338
- style={{
2339
- fontSize: (wm.fontSize ?? 60) * zoom,
2340
- color: wm.color ?? 'var(--nice-text-muted, #94a3b8)',
2341
- opacity: wm.opacity,
2342
- transform: `translate(-50%, -50%) rotate(${wm.angle}deg)`,
2343
- }}
2344
- >
2345
- {wm.type === 'text' ? wm.text : '??'}
2346
- </div>
2347
- ))}
2348
-
2349
- {/* Sections */}
2350
- {tpl.sections.map((section) => (
2351
- <div key={section.id}>
2352
- <SectionCanvas
2353
- section={section}
2354
- zoom={zoom}
2355
- paperWidthMm={paperW}
2356
- selectedIds={selectedIds}
2357
- sampleData={sampleDataRecord}
2358
- readOnly={readOnly}
2359
- showGrid={showGrid}
2360
- onFieldClick={handleFieldClick}
2361
- onFieldDragStart={handleFieldDragStart}
2362
- onResizeStart={handleResizeStart}
2363
- onSectionHeightChange={handleSectionHeightChange}
2364
- onDropField={handleDropField}
2365
- />
2366
- </div>
2367
- ))}
2368
- </div>
2369
- </div>
2370
- </div>
2371
-
2372
- {/* Right properties panel */}
2301
+ }
2302
+ rightSidebar={
2373
2303
  <PropertiesPanel
2374
2304
  field={firstSelected}
2375
2305
  activeTab={rightTab}
@@ -2378,8 +2308,90 @@ export const NiceTemplateEditor: React.FC<NiceTemplateEditorProps> = ({
2378
2308
  paperWidthMm={paperW}
2379
2309
  paperHeightMm={paperH}
2380
2310
  />
2311
+ }
2312
+ >
2313
+ {/* Canvas area */}
2314
+ <div className={styles.canvasArea} onClick={() => setSelectedIds(new Set())}>
2315
+ {/* Test data bar */}
2316
+ {Array.isArray(sampleData) && sampleData.length > 0 && (
2317
+ <div className={styles.testDataBar}>
2318
+ <span className={styles.testDataLabel}>Dane testowe:</span>
2319
+ <select
2320
+ className={styles.testDataSelect}
2321
+ value={testDataIdx}
2322
+ onChange={(e) => setTestDataIdx(+e.target.value)}
2323
+ >
2324
+ {sampleData.map((_, i) => (
2325
+ <option key={i} value={i}>
2326
+ Rekord {i + 1}
2327
+ </option>
2328
+ ))}
2329
+ </select>
2330
+ </div>
2331
+ )}
2332
+
2333
+ {/* Ruler corner + rulers */}
2334
+ {showRulers && (
2335
+ <div className={styles.rulerWrapper}>
2336
+ <div className={styles.rulerCorner} />
2337
+ <Ruler lengthMm={paperW} zoom={zoom} orientation="h" />
2338
+ <Ruler lengthMm={paperH} zoom={zoom} orientation="v" />
2339
+ </div>
2340
+ )}
2341
+
2342
+ {/* Scrollable paper area */}
2343
+ <div className={styles.paperScroll} onClick={(e) => e.stopPropagation()}>
2344
+ <div className={styles.paperShadow} style={{ width: paperWPx, minHeight: paperHPx }}>
2345
+ {/* Margin guides */}
2346
+ <div
2347
+ className={styles.marginGuide}
2348
+ style={{
2349
+ top: tpl.margins.top * zoom * MM_TO_PX,
2350
+ right: tpl.margins.right * zoom * MM_TO_PX,
2351
+ bottom: tpl.margins.bottom * zoom * MM_TO_PX,
2352
+ left: tpl.margins.left * zoom * MM_TO_PX,
2353
+ }}
2354
+ />
2355
+
2356
+ {/* Watermarks */}
2357
+ {(tpl.watermarks ?? []).map((wm) => (
2358
+ <div
2359
+ key={wm.id}
2360
+ className={styles.watermark}
2361
+ style={{
2362
+ fontSize: (wm.fontSize ?? 60) * zoom,
2363
+ color: wm.color ?? 'var(--nice-text-muted, #94a3b8)',
2364
+ opacity: wm.opacity,
2365
+ transform: `translate(-50%, -50%) rotate(${wm.angle}deg)`,
2366
+ }}
2367
+ >
2368
+ {wm.type === 'text' ? wm.text : '??'}
2369
+ </div>
2370
+ ))}
2371
+
2372
+ {/* Sections */}
2373
+ {tpl.sections.map((section) => (
2374
+ <div key={section.id}>
2375
+ <SectionCanvas
2376
+ section={section}
2377
+ zoom={zoom}
2378
+ paperWidthMm={paperW}
2379
+ selectedIds={selectedIds}
2380
+ sampleData={sampleDataRecord}
2381
+ readOnly={readOnly}
2382
+ showGrid={showGrid}
2383
+ onFieldClick={handleFieldClick}
2384
+ onFieldDragStart={handleFieldDragStart}
2385
+ onResizeStart={handleResizeStart}
2386
+ onSectionHeightChange={handleSectionHeightChange}
2387
+ onDropField={handleDropField}
2388
+ />
2389
+ </div>
2390
+ ))}
2391
+ </div>
2392
+ </div>
2381
2393
  </div>
2382
- </div>
2394
+ </NiceAppShell>
2383
2395
  );
2384
2396
  };
2385
2397