@zeyos/zx 4.3.0 → 4.3.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +111 -1
  2. package/README.md +0 -3
  3. package/dist/types/components/calendar/calendar-model.d.ts +22 -0
  4. package/dist/types/components/card-view/card-view.d.ts +1 -1
  5. package/dist/types/components/card-view/record-card.d.ts +47 -5
  6. package/dist/types/components/kanban-view/kanban-policy.d.ts +268 -0
  7. package/dist/types/components/kanban-view/kanban-view.d.ts +669 -24
  8. package/dist/types/core/component.d.ts +6 -1
  9. package/dist/types/index.d.ts +2 -1
  10. package/dist/zx-zeyos.esm.js +35 -11
  11. package/dist/zx-zeyos.esm.min.js +1 -1
  12. package/dist/zx.css +597 -78
  13. package/dist/zx.esm.js +1758 -238
  14. package/dist/zx.esm.min.js +3 -3
  15. package/dist/zx.global.js +1758 -238
  16. package/dist/zx.global.min.js +3 -3
  17. package/dist/zx.min.css +1 -1
  18. package/docs/api.json +214 -2
  19. package/docs/llms.md +30 -30
  20. package/docs/llms.txt +0 -2
  21. package/package.json +1 -2
  22. package/src/components/calendar/calendar-model.js +45 -0
  23. package/src/components/calendar/calendar.css +30 -10
  24. package/src/components/calendar/calendar.js +8 -10
  25. package/src/components/card-view/card-view.css +211 -9
  26. package/src/components/card-view/card-view.js +7 -7
  27. package/src/components/card-view/record-card.js +92 -19
  28. package/src/components/kanban-view/kanban-policy.js +412 -0
  29. package/src/components/kanban-view/kanban-view.css +480 -36
  30. package/src/components/kanban-view/kanban-view.js +1514 -235
  31. package/src/components/message/message.css +9 -10
  32. package/src/core/component.js +8 -3
  33. package/src/index.js +8 -3
  34. package/DESIGN-SYSTEM.md +0 -182
@@ -73,10 +73,15 @@ export declare class Component<TOptions extends ComponentOptions = ComponentOpti
73
73
  * Dispatches a component event and a bubbling, composed `zx-*` DOM event.
74
74
  * @param {string} type Lowercase event name.
75
75
  * @param {Record<string, unknown>} [detail={}] Single event detail object.
76
+ * @param {{honorDomCancellation?:boolean}} [options={}] Mirrored DOM-event behavior. Components
77
+ * with a cancelable mutation boundary may opt into treating `preventDefault()` on the bubbling
78
+ * `zx-*` event exactly like cancellation of the component event.
76
79
  * @returns {Event & {detail: Record<string, unknown>}}
77
80
  * @fires Component#event
78
81
  */
79
- emit(type: string, detail?: Record<string, unknown>): Event & {
82
+ emit(type: string, detail?: Record<string, unknown>, options?: {
83
+ honorDomCancellation?: boolean;
84
+ }): Event & {
80
85
  detail: Record<string, unknown>;
81
86
  };
82
87
  /**
@@ -78,12 +78,13 @@ export { DateRangePicker, clampRange, defaultDateRangePresets, normalizeRange, r
78
78
  export { DateRangeBox, formatRangeText, parseRangeText } from './components/datebox/date-range-box.js';
79
79
  export { Timebox, splitTime, joinTime } from './components/timebox/timebox.js';
80
80
  export { Calendar } from './components/calendar/calendar.js';
81
- export { CALENDAR_VIEWS, addCalendarDays, calendarDayDifference, calendarDayKey, calendarEventIntersects, calendarEventSpansDays, calendarRange, cloneCalendarEvent, layoutCalendarSpans, layoutTimedCalendarEvents, normalizeCalendarEvents, shiftCalendarEvent, startOfCalendarDay, startOfCalendarWeek } from './components/calendar/calendar-model.js';
81
+ export { CALENDAR_VIEWS, addCalendarDays, addCalendarMonths, calendarDayDifference, calendarDayKey, calendarEventIntersects, calendarEventSpansDays, calendarPageDate, calendarRange, cloneCalendarEvent, layoutCalendarSpans, layoutTimedCalendarEvents, normalizeCalendarEvents, shiftCalendarEvent, startOfCalendarDay, startOfCalendarWeek } from './components/calendar/calendar-model.js';
82
82
  export { RecordView, normalizeViewFields, reconcileFieldOrder, moveViewField, readViewField, renderViewField, sortViewRecords, normalizeViewState, viewRecordId } from './components/view/record-view.js';
83
83
  export { Table, reorderTableRows } from './components/table/table.js';
84
84
  export { TableView } from './components/table-view/table-view.js';
85
85
  export { CardView } from './components/card-view/card-view.js';
86
86
  export { KanbanView } from './components/kanban-view/kanban-view.js';
87
+ export { absoluteKanbanIndex, allowsKanbanTransition, createKanbanHistory, evaluateKanbanMove, kanbanSearchTerms, locateKanbanRecord, matchesKanbanSearch, normalizeKanbanRules, reorderKanbanRecords, resolveKanbanRules } from './components/kanban-view/kanban-policy.js';
87
88
  export { Grid, billingColumns, isBillingLine } from './components/grid/grid.js';
88
89
  export { Chart, ChartJsAdapter, chartSummaryTable, cloneChartValue, isEmptyChartData } from './components/chart/chart.js';
89
90
  export { TreeView } from './components/tree/tree.js';
@@ -870,21 +870,26 @@ var Component = class extends EventTarget {
870
870
  * Dispatches a component event and a bubbling, composed `zx-*` DOM event.
871
871
  * @param {string} type Lowercase event name.
872
872
  * @param {Record<string, unknown>} [detail={}] Single event detail object.
873
+ * @param {{honorDomCancellation?:boolean}} [options={}] Mirrored DOM-event behavior. Components
874
+ * with a cancelable mutation boundary may opt into treating `preventDefault()` on the bubbling
875
+ * `zx-*` event exactly like cancellation of the component event.
873
876
  * @returns {Event & {detail: Record<string, unknown>}}
874
877
  * @fires Component#event
875
878
  */
876
- emit(type, detail = {}) {
879
+ emit(type, detail = {}, options = {}) {
877
880
  if (detail === null || typeof detail !== "object" || Array.isArray(detail)) {
878
881
  throw new TypeError("Event detail must be an object");
879
882
  }
880
883
  const componentEvent = createCustomEvent(type, detail, { cancelable: true });
881
884
  this.dispatchEvent(componentEvent);
882
885
  if (this.el) {
883
- this.el.dispatchEvent(createCustomEvent(`zx-${type}`, detail, {
886
+ const domEvent = createCustomEvent(`zx-${type}`, detail, {
884
887
  bubbles: true,
885
888
  composed: true,
886
889
  cancelable: true
887
- }));
890
+ });
891
+ this.el.dispatchEvent(domEvent);
892
+ if (options.honorDomCancellation && domEvent.defaultPrevented) componentEvent.preventDefault();
888
893
  }
889
894
  return componentEvent;
890
895
  }
@@ -13132,6 +13137,29 @@ function calendarRange(view, anchor, options = {}) {
13132
13137
  }
13133
13138
  return { start, end };
13134
13139
  }
13140
+ function calendarPageDate(view, anchor, direction, options = {}) {
13141
+ const date = validDate5(anchor, "Calendar date");
13142
+ const step = integer(direction, "direction");
13143
+ if (view === "day") date.setDate(date.getDate() + step);
13144
+ else if (view === "agenda") {
13145
+ date.setDate(date.getDate() + step * positiveInteger(options.agendaDays ?? 14, "agendaDays"));
13146
+ } else if (view === "week") date.setDate(date.getDate() + step * 7);
13147
+ else if (view === "month") return addCalendarMonths(date, step);
13148
+ else if (view === "year") return addCalendarMonths(date, step * 12);
13149
+ else throw new RangeError(`Unknown calendar view: ${view}`);
13150
+ return date;
13151
+ }
13152
+ function addCalendarMonths(value, months) {
13153
+ const date = validDate5(value, "Calendar date");
13154
+ const day = date.getDate();
13155
+ date.setDate(1);
13156
+ date.setMonth(date.getMonth() + integer(months, "month amount"));
13157
+ date.setDate(Math.min(day, daysInCalendarMonth(date.getFullYear(), date.getMonth())));
13158
+ return date;
13159
+ }
13160
+ function daysInCalendarMonth(year, month) {
13161
+ return new Date(year, month + 1, 0).getDate();
13162
+ }
13135
13163
  function normalizeCalendarEvents(records, options = {}) {
13136
13164
  if (!Array.isArray(records)) throw new TypeError("Calendar events must be an array");
13137
13165
  const readers = {
@@ -13575,7 +13603,7 @@ var Calendar = class extends Component {
13575
13603
  durationEditable: Object.prototype.hasOwnProperty.call(changes, "durationEditable") ? changes.durationEditable : current.durationEditable,
13576
13604
  data: changes.data ?? current.data
13577
13605
  };
13578
- const [next] = normalizeCalendarEvents([source]);
13606
+ const [next] = normalizeCalendarEvents([source], { dateUnit: this.options.dateUnit });
13579
13607
  next.data = source.data;
13580
13608
  this._events = this._events.map((event, eventIndex) => eventIndex === index ? next : event);
13581
13609
  this._mutationVersions.delete(String(id));
@@ -14601,13 +14629,9 @@ var Calendar = class extends Component {
14601
14629
  }
14602
14630
  /** @param {number} direction @returns {this} */
14603
14631
  _page(direction) {
14604
- const date = new Date(this._date.getTime());
14605
- if (this._view === "day") date.setDate(date.getDate() + direction);
14606
- else if (this._view === "agenda") date.setDate(date.getDate() + direction * this.options.agendaDays);
14607
- else if (this._view === "week") date.setDate(date.getDate() + direction * 7);
14608
- else if (this._view === "month") date.setMonth(date.getMonth() + direction);
14609
- else date.setFullYear(date.getFullYear() + direction);
14610
- return this.setDate(date);
14632
+ return this.setDate(calendarPageDate(this._view, this._date, direction, {
14633
+ agendaDays: this.options.agendaDays
14634
+ }));
14611
14635
  }
14612
14636
  /** @param {{start: Date, end: Date}} range @returns {string} */
14613
14637
  _rangeTitle(range) {