Skip to content

Add data-table render templates; expand zn-style and query-builder#84

Open
felippe-ch wants to merge 2 commits into
masterfrom
data-table-render-templates
Open

Add data-table render templates; expand zn-style and query-builder#84
felippe-ch wants to merge 2 commits into
masterfrom
data-table-render-templates

Conversation

@felippe-ch

Copy link
Copy Markdown
Contributor

Data-table

  • Add per-column render templates inspired by DataTables.net columns.render:
    • displayTemplates: Record<string, DisplayTemplate> on the component
    • header.renderTemplate: name lookup into displayTemplates
    • header.render: inline DisplayTemplate function (JS-property only)
    • <script type="zn-templates"> child compiled at connect for fully-declarative use
  • Add column-level cell defaults: header.cellTemplate (data wins) and header.ifEmpty (fallback when cell has no text or icon)
  • Accept a single Row on the data property in addition to Row[]
  • Plumb row + header through renderCellBody to renderCell so templates have full context

zn-style

  • border accepts a side string (t/b/l/r combinations, plus 'a' / 'tblr' for all sides); bare still renders all four for backward compatibility
  • size prop with xs/s/m/l/xl mapped to the existing zn-font-size tokens
  • muted helper class

Query-builder / datepicker

  • QueryBuilderDateSubmitFormat = 'iso' | 'timestamp' | 'legacy' on filter items, controls how date / dateTime values are serialized at submit time
  • datepicker container property for shadow-DOM-friendly overlay placement
  • Pull air-datepicker theme rules into scss/air-datapicker.scss so the in-shadow global container picks up zinc tokens

Utilities

  • deepQuery: cross-shadow-DOM querySelector helper

Docs

  • New sections for render templates, column cell defaults, border sides, size, muted, and date submit format
  • code-previews.cjs only IIFE-wraps scripts the browser would execute as JS so data-block types like <script type="zn-templates"> survive the preview build

Tests

  • zn-style: border side mapping, size scale, muted
  • data-table: single-Row data, displayTemplates surface
  • query: deepQuery across light DOM, single shadow, nested shadows

Data-table
- Add per-column render templates inspired by DataTables.net columns.render:
  * displayTemplates: Record<string, DisplayTemplate> on the component
  * header.renderTemplate: name lookup into displayTemplates
  * header.render: inline DisplayTemplate function (JS-property only)
  * <script type="zn-templates"> child compiled at connect for fully-declarative use
- Add column-level cell defaults: header.cellTemplate (data wins) and
  header.ifEmpty (fallback when cell has no text or icon)
- Accept a single Row on the data property in addition to Row[]
- Plumb row + header through renderCellBody to renderCell so templates have full context

zn-style
- border accepts a side string (t/b/l/r combinations, plus 'a' / 'tblr' for all sides);
  bare <zn-style border> still renders all four for backward compatibility
- size prop with xs/s/m/l/xl mapped to the existing zn-font-size tokens
- muted helper class

Query-builder / datepicker
- QueryBuilderDateSubmitFormat = 'iso' | 'timestamp' | 'legacy' on filter items,
  controls how date / dateTime values are serialized at submit time
- datepicker container property for shadow-DOM-friendly overlay placement
- Pull air-datepicker theme rules into scss/air-datapicker.scss so the in-shadow
  global container picks up zinc tokens

Utilities
- deepQuery: cross-shadow-DOM querySelector helper

Docs
- New sections for render templates, column cell defaults, border sides, size,
  muted, and date submit format
- code-previews.cjs only IIFE-wraps scripts the browser would execute as JS so
  data-block types like <script type="zn-templates"> survive the preview build

Tests
- zn-style: border side mapping, size scale, muted
- data-table: single-Row data, displayTemplates surface
- query: deepQuery across light DOM, single shadow, nested shadows
hideColumn?: boolean;
secondary?: boolean;
type?: string;
renderTemplate?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed need to remove the render template functionality and add specific DateTime formatting as an option within data tables

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread scss/_root.scss Outdated
}

.zn-muted {
opacity: 0.5;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
opacity: 0.5;
color: var(--zn-color-muted-text);

* - yyyy: Full year (2024)
*/
@property() format: string = 'MM/dd/yyyy';
@property() format: string = 'dd/MM/yyyy';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't be changing the default format, we specifically chose the American format.

Suggested change
@property() format: string = 'dd/MM/yyyy';
@property() format: string = 'MM/dd/yyyy';

…e render templates

- Change datepicker default format from dd/MM/yyyy to MM/dd/yyyy
- Refactor data-table rendering: remove header.render and header.renderTemplate properties
- Introduce header.type property for template lookup
- Add defaultTemplates with built-in dateTime formatter
- Rename _slotTemplates to _formatTemplates and initialize with defaultTemplates
- Update zn-muted class to use CSS variable instead of opacity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants