sonamu 0.0.14 → 0.0.16

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.
@@ -40,6 +40,7 @@ export class Template__view_list extends Template {
40
40
 
41
41
  switch (col.renderType) {
42
42
  case "string-plain":
43
+ case "string-date":
43
44
  case "number-id":
44
45
  return `<>{${colName}}</>`;
45
46
  case "number-fk_id":
@@ -49,12 +50,14 @@ export class Template__view_list extends Template {
49
50
  );
50
51
  return `<>${relPropFk.with}#{${colName}}</>`;
51
52
  case "string-image":
52
- return `<img src={${colName}} />`;
53
+ return `<>{${
54
+ col.nullable ? `${colName} && ` : ""
55
+ }<img src={${colName}} />}</>`;
53
56
  case "string-datetime":
54
57
  if (col.nullable) {
55
- return `<span className="text-tiny">{${colName} === null ? '-' : DateTime.fromSQL(${colName}).toFormat('y-MM-dd')}</span>`;
58
+ return `<span className="text-tiny">{${colName} === null ? '-' : DateTime.fromSQL(${colName}).toSQL().slice(0, 10)}</span>`;
56
59
  } else {
57
- return `<span className="text-tiny">{DateTime.fromSQL(${colName}).toFormat('y-MM-dd')}</span>`;
60
+ return `<span className="text-tiny">{DateTime.fromSQL(${colName}).toSQL().slice(0, 10)}</span>`;
58
61
  }
59
62
  case "boolean":
60
63
  return `<>{${colName} ? <Label color='green' circular>O</Label> : <Label color='grey' circular>X</Label> }</>`;
@@ -64,11 +67,11 @@ export class Template__view_list extends Template {
64
67
  targetMDNames.constant
65
68
  }.${name}[${colName}].ko}</>`;
66
69
  case "array-images":
67
- return `<>{ ${colName}.map(r => <img src={r} />) }</>`;
70
+ return `<>{ ${colName}.map(r => ${
71
+ col.nullable ? `r && ` : ""
72
+ }<img src={r} />) }</>`;
68
73
  case "number-plain":
69
- return `<>{${
70
- col.nullable ? `${colName} && ` : ""
71
- }new Intl.NumberFormat().format(${colName})}</>`;
74
+ return `<>{${col.nullable ? `${colName} && ` : ""}numF(${colName})}</>`;
72
75
  case "object":
73
76
  try {
74
77
  const relProp = getRelationPropFromColName(smdId, col.name);
@@ -333,7 +336,7 @@ export class Template__view_list extends Template {
333
336
  });
334
337
  }
335
338
 
336
- // 리스트 컬럼 프리템플릿
339
+ // 리스트 컬럼
337
340
  const columnImports = uniq(
338
341
  columnsNode
339
342
  .children!.map((col) => {
@@ -342,14 +345,6 @@ export class Template__view_list extends Template {
342
345
  .flat()
343
346
  .filter((col) => col !== null)
344
347
  ).join("\n");
345
- preTemplates.push({
346
- key: "view_list_columns",
347
- options: {
348
- smdId,
349
- columns,
350
- columnImports,
351
- } as TemplateOptions["view_list_columns"],
352
- });
353
348
 
354
349
  // SearchInput
355
350
  preTemplates!.push({
@@ -381,13 +376,7 @@ import {
381
376
  } from 'semantic-ui-react';
382
377
  import classNames from 'classnames';
383
378
  import { DateTime } from "luxon";
384
- import { DelButton } from 'src/typeframe/components/DelButton';
385
- import { EditButton } from 'src/typeframe/components/EditButton';
386
- import { AppBreadcrumbs } from 'src/typeframe/components/AppBreadcrumbs';
387
- import { AddButton } from 'src/typeframe/components/AddButton';
388
- import { useSelection, useListParams } from 'src/typeframe/helpers';
389
- import { TFColumn } from "src/typeframe/iso-types";
390
- import dc from './_columns';
379
+ import { DelButton, EditButton, AppBreadcrumbs, AddButton, useSelection, useListParams, SonamuCol, numF } from '@sonamu-kit/react-sui';
391
380
 
392
381
  import { ${names.capital}SubsetA } from "src/services/${names.fs}/${
393
382
  names.fs
@@ -463,9 +452,15 @@ export default function ${names.capital}List({}: ${names.capital}ListProps) {
463
452
  } = useSelection((rows ?? []).map((row) => row.id));
464
453
 
465
454
  // 컬럼
466
- const columns:TFColumn<${names.capital}SubsetA>[] = [
467
- ${columns.map((col) => `{ ...dc.${col.name} }`).join(",\n")}
468
- ]
455
+ const columns:SonamuCol<${names.capital}SubsetA>[] = [${columns
456
+ .map((col) => {
457
+ return [
458
+ `{ label: "${col.label}",`,
459
+ `tc: ${col.tc}, `,
460
+ `collapsing: ${["Title", "Name"].includes(col.label) === false}, }`,
461
+ ].join("\n");
462
+ })
463
+ .join(",\n")}];
469
464
 
470
465
  return (
471
466
  <div className="list ${names.fsPlural}-index">
@@ -532,6 +532,7 @@ export type RenderingNode = {
532
532
  | "string-plain"
533
533
  | "string-image"
534
534
  | "string-datetime"
535
+ | "string-date"
535
536
  | "number-plain"
536
537
  | "number-id"
537
538
  | "number-fk_id"