@design.estate/dees-catalog 24.6.1 → 24.6.2

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.
@@ -6106,7 +6106,22 @@ __runInitializers(_init12, 1, _DeesInputCheckbox);
6106
6106
  var DeesInputCheckbox = _DeesInputCheckbox;
6107
6107
 
6108
6108
  // ts_web/elements/00group-input/dees-input-datepicker/demo.ts
6109
- var demoFunc8 = /* @__PURE__ */ __name(() => focusedInputDemo("datepicker"), "demoFunc");
6109
+ var showReport = /* @__PURE__ */ __name((event) => {
6110
+ const field = event.currentTarget;
6111
+ const value = field.value || "(empty)";
6112
+ const reason = field.checkValidity() ? "" : `${field.validationText} `;
6113
+ showDemoResult(field, `${event.type}: ${reason}value: ${value}`);
6114
+ }, "showReport");
6115
+ var demoFunc8 = /* @__PURE__ */ __name(() => focusedInputDemo("datepicker", demoSection(
6116
+ "Typed dates",
6117
+ "A typed date the field takes is its value as it is typed, reported by input, so a Save button can follow it; change follows once, on Enter or leaving the field. Text it does not take says why and leaves the value from before the typing.",
6118
+ b`
6119
+ <div class="dees-demo-grid">
6120
+ <dees-input-datepicker label="Renewal date" value="2026-12-31" minDate="2026-11-01" @input=${showReport} @change=${showReport} @validation-change=${showReport}></dees-input-datepicker>
6121
+ <dees-input-datepicker label="Maintenance window" .enableTime=${true} timeFormat="12h" @input=${showReport} @change=${showReport} @validation-change=${showReport}></dees-input-datepicker>
6122
+ </div>${demoOutput("Type a date to see what the field reports.")}
6123
+ ${demoCode('<dees-input-datepicker label="Renewal date" .value=${renewal} @input=${(event) => (draft = event.detail.value)} @validation-change=${(event) => (valid = event.detail.valid)} @change=${(event) => save(event.detail.value)}></dees-input-datepicker>')}`
6124
+ )), "demoFunc");
6110
6125
 
6111
6126
  // ts_web/elements/00group-input/dees-input-datepicker/styles.ts
6112
6127
  var datepickerStyles = [
@@ -6221,6 +6236,11 @@ var datepickerStyles = [
6221
6236
  ];
6222
6237
 
6223
6238
  // ts_web/elements/00group-input/dees-input-datepicker/template.ts
6239
+ var placeholderOf = /* @__PURE__ */ __name((component) => {
6240
+ if (component.placeholder) return component.placeholder;
6241
+ if (!component.enableTime) return "YYYY-MM-DD";
6242
+ return `YYYY-MM-DD ${component.timeFormat === "12h" ? "h:mm AM/PM" : "HH:mm"}`;
6243
+ }, "placeholderOf");
6224
6244
  var renderDatepicker = /* @__PURE__ */ __name((component) => {
6225
6245
  return b`
6226
6246
  <div class="input-wrapper">
@@ -6235,12 +6255,13 @@ var renderDatepicker = /* @__PURE__ */ __name((component) => {
6235
6255
  aria-describedby="date-description date-validation"
6236
6256
  class="date-input field-control ${component.isOpened ? "open" : ""}"
6237
6257
  .value=${component.draftText ?? component.formatDate(component.value)}
6238
- .placeholder=${component.placeholder}
6258
+ .placeholder=${placeholderOf(component)}
6239
6259
  ?disabled=${component.disabled}
6240
6260
  ?required=${component.required}
6241
6261
  @click=${component.toggleCalendar}
6242
6262
  @keydown=${component.handleKeydown}
6243
6263
  @input=${component.handleManualInput}
6264
+ @compositionend=${component.handleCompositionEnd}
6244
6265
  @blur=${component.handleInputBlur}
6245
6266
  style="padding-right: ${component.value || component.draftText ? "calc(var(--dees-input-action-size) + 40px)" : "40px"}"
6246
6267
  />
@@ -7235,7 +7256,7 @@ var _DeesInputDatepicker = class _DeesInputDatepicker extends (_a12 = DeesInputB
7235
7256
  __privateAdd(this, _maxDate2, __runInitializers(_init14, 32, this, "")), __runInitializers(_init14, 35, this);
7236
7257
  __privateAdd(this, _disabledDates2, __runInitializers(_init14, 36, this, [])), __runInitializers(_init14, 39, this);
7237
7258
  __privateAdd(this, _weekStartsOn2, __runInitializers(_init14, 40, this)), __runInitializers(_init14, 43, this);
7238
- __privateAdd(this, _placeholder2, __runInitializers(_init14, 44, this, "YYYY-MM-DD")), __runInitializers(_init14, 47, this);
7259
+ __privateAdd(this, _placeholder2, __runInitializers(_init14, 44, this, "")), __runInitializers(_init14, 47, this);
7239
7260
  __privateAdd(this, _enableTimezone2, __runInitializers(_init14, 48, this, false)), __runInitializers(_init14, 51, this);
7240
7261
  __privateAdd(this, _timezone2, __runInitializers(_init14, 52, this, "")), __runInitializers(_init14, 55, this);
7241
7262
  __privateAdd(this, _events2, __runInitializers(_init14, 56, this, [])), __runInitializers(_init14, 59, this);
@@ -7247,12 +7268,18 @@ var _DeesInputDatepicker = class _DeesInputDatepicker extends (_a12 = DeesInputB
7247
7268
  __privateAdd(this, _draftText, __runInitializers(_init14, 80, this, null)), __runInitializers(_init14, 83, this);
7248
7269
  __privateAdd(this, _validationText, __runInitializers(_init14, 84, this, "")), __runInitializers(_init14, 87, this);
7249
7270
  __publicField(this, "lastCommittedValue");
7271
+ /**
7272
+ * The value the field held when the reader began typing: Enter or leaving the field reports a
7273
+ * typed value with `change` only when it differs from it, and text the field does not take
7274
+ * returns the value to it.
7275
+ */
7276
+ __publicField(this, "draftBase", "");
7250
7277
  /** The zone the field's readings were taken in, to read them again when it changes. */
7251
7278
  __publicField(this, "readingTimeZone");
7252
7279
  __publicField(this, "popupInstance", null);
7253
7280
  __publicField(this, "handleDateSelected", /* @__PURE__ */ __name((event) => {
7254
7281
  if (this.disabled) return;
7255
- this.commitDate(event.detail, true);
7282
+ this.commitDate(event.detail);
7256
7283
  }, "handleDateSelected"));
7257
7284
  __publicField(this, "handleDateCleared", /* @__PURE__ */ __name(() => {
7258
7285
  if (!this.disabled) this.commitClear();
@@ -7272,7 +7299,7 @@ var _DeesInputDatepicker = class _DeesInputDatepicker extends (_a12 = DeesInputB
7272
7299
  return;
7273
7300
  }
7274
7301
  this.timezone = timeZone;
7275
- if (reading) this.commitDate(reading, true);
7302
+ if (reading) this.commitDate(reading);
7276
7303
  }, "handleTimezoneSelected"));
7277
7304
  __publicField(this, "handleCloseRequest", /* @__PURE__ */ __name(() => {
7278
7305
  this.closePopup();
@@ -7295,6 +7322,10 @@ var _DeesInputDatepicker = class _DeesInputDatepicker extends (_a12 = DeesInputB
7295
7322
  get validationState() {
7296
7323
  return this.validationText ? "invalid" : "valid";
7297
7324
  }
7325
+ /** The value the reader last committed: while they type, the one from before the typing. */
7326
+ get committedValue() {
7327
+ return this.draftText === null ? this.value : this.draftBase;
7328
+ }
7298
7329
  /**
7299
7330
  * The time zone of the field's clock: `timezone`, else the I18n's, else the runtime's. A zone the
7300
7331
  * runtime does not know is passed over, with a warning.
@@ -7308,14 +7339,15 @@ var _DeesInputDatepicker = class _DeesInputDatepicker extends (_a12 = DeesInputB
7308
7339
  willUpdate(changed3) {
7309
7340
  super.willUpdate(changed3);
7310
7341
  if (changed3.has("value") && this.value !== this.lastCommittedValue || this.clockTimeZone !== this.readingTimeZone) {
7311
- this.syncValue(this.value);
7342
+ this.takeValue(this.value);
7312
7343
  }
7313
7344
  }
7314
7345
  updated(changed3) {
7315
7346
  super.updated(changed3);
7316
7347
  if (changed3.has("disabled") && this.disabled) this.closePopup();
7317
7348
  if (["value", "minDate", "maxDate", "disabledDates", "required", "disabled", "timezone"].some((key) => changed3.has(key))) {
7318
- this.updateValidation(this.currentValidationMessage());
7349
+ if (this.draftText !== null && !this.disabled) this.takeEdit();
7350
+ else this.updateValidation(this.currentValidationMessage());
7319
7351
  }
7320
7352
  if (this.popupInstance) {
7321
7353
  this.popupInstance.minDate = this.minDate;
@@ -7337,15 +7369,21 @@ var _DeesInputDatepicker = class _DeesInputDatepicker extends (_a12 = DeesInputB
7337
7369
  if (input.value !== display) input.value = display;
7338
7370
  }
7339
7371
  }
7340
- syncValue(value) {
7341
- this.value = value ?? "";
7342
- this.lastCommittedValue = this.value;
7343
- this.draftText = null;
7372
+ /**
7373
+ * Takes `value` as the field's value, and its day and time as the calendar's selection. The text
7374
+ * then shows the value as the field writes it and the calendar turns to its month; while the reader
7375
+ * types (`keepText`), their text stays as typed and the calendar keeps the month it shows.
7376
+ */
7377
+ takeValue(value, keepText = false) {
7378
+ this.value = value;
7379
+ this.lastCommittedValue = value;
7344
7380
  this.readingTimeZone = this.clockTimeZone;
7345
- this.selectedDate = parseDateValue(this.value, this.readingTimeZone);
7346
- this.viewDate = new Date(this.selectedDate ?? readClock(/* @__PURE__ */ new Date(), this.readingTimeZone));
7381
+ this.selectedDate = parseDateValue(value, this.readingTimeZone);
7347
7382
  this.selectedHour = this.selectedDate?.getUTCHours() ?? 0;
7348
7383
  this.selectedMinute = this.selectedDate?.getUTCMinutes() ?? 0;
7384
+ if (keepText) return;
7385
+ this.draftText = null;
7386
+ this.viewDate = new Date(this.selectedDate ?? readClock(/* @__PURE__ */ new Date(), this.readingTimeZone));
7349
7387
  }
7350
7388
  /** A value as the field writes it, on its clock or, with `timeZone`, on the clock of that zone. */
7351
7389
  formatDate(isoString, timeZone = this.clockTimeZone) {
@@ -7455,8 +7493,8 @@ var _DeesInputDatepicker = class _DeesInputDatepicker extends (_a12 = DeesInputB
7455
7493
  }
7456
7494
  /**
7457
7495
  * Which of the two moments a reading in an hour the clock reads twice names, as the clock's offset
7458
- * then: one the bounds take, and of those the one the field's value is in when the value sits in
7459
- * that same hour, so a time edited there stays in its pass; else the earlier. Undefined for a
7496
+ * then: one the bounds take, and of those the one the field's committed value is in when that value
7497
+ * sits in the same hour, so a time edited there stays in its pass; else the earlier. Undefined for a
7460
7498
  * reading the clock shows once.
7461
7499
  */
7462
7500
  passOf(reading, timeZone = this.clockTimeZone) {
@@ -7469,59 +7507,89 @@ var _DeesInputDatepicker = class _DeesInputDatepicker extends (_a12 = DeesInputB
7469
7507
  return kept && kept.day === calendarDayKey(reading) && choices.includes(kept.offset) ? kept.offset : choices[0];
7470
7508
  }
7471
7509
  /**
7472
- * The pass of an hour the clock reads twice the field's value is in: its day and the clock's
7510
+ * The pass of an hour the clock reads twice the field's committed value is in (while the reader
7511
+ * types, the value from before the typing, as Enter has always read it): its day and the clock's
7473
7512
  * offset. Undefined for a value the clock shows once, whose offset says nothing of another reading.
7474
7513
  */
7475
7514
  valuePass(timeZone) {
7476
7515
  const offset = this.valueOffset(timeZone);
7477
7516
  if (offset === void 0) return void 0;
7478
- const reading = readClock(new Date(this.value), timeZone);
7517
+ const reading = readClock(new Date(this.committedValue), timeZone);
7479
7518
  return clockInstants(reading, timeZone).length === 2 ? { day: calendarDayKey(reading), offset } : void 0;
7480
7519
  }
7481
- /** The clock's offset at the field's value, when the value says its instant. */
7520
+ /** The clock's offset at the field's committed value, when the value says its instant. */
7482
7521
  valueOffset(timeZone = this.clockTimeZone) {
7483
- if (!namesInstant(this.value)) return void 0;
7484
- const instant = new Date(this.value);
7522
+ const value = this.committedValue;
7523
+ if (!namesInstant(value)) return void 0;
7524
+ const instant = new Date(value);
7485
7525
  return Number.isNaN(instant.getTime()) ? void 0 : clockOffset(instant, timeZone);
7486
7526
  }
7487
- commitDate(date2, normalizeDraft) {
7527
+ /** Commits a moment picked in the calendar, set in its time boxes or by Today, or kept in a zone chosen. */
7528
+ commitDate(date2) {
7488
7529
  const offset = this.passOf(date2);
7489
7530
  const message = dateValidationMessage(date2, this.constraintsIn(this.clockTimeZone, offset), this.t);
7490
7531
  if (message) {
7491
7532
  this.updateValidation(message);
7492
- return false;
7493
- }
7494
- const value = this.formatValueWithTimezone(date2, offset);
7495
- const changed3 = value !== this.value;
7496
- this.lastCommittedValue = value;
7497
- this.value = value;
7498
- this.readingTimeZone = this.clockTimeZone;
7499
- this.selectedDate = new Date(date2);
7500
- this.selectedHour = date2.getUTCHours();
7501
- this.selectedMinute = date2.getUTCMinutes();
7502
- this.viewDate = new Date(date2);
7503
- if (normalizeDraft) this.draftText = null;
7504
- this.updateValidation("");
7505
- if (changed3) {
7506
- this.changeSubject.next(this);
7507
- this.reportValueCommit();
7533
+ return;
7508
7534
  }
7509
- return true;
7535
+ this.commitValue(this.formatValueWithTimezone(date2, offset), { pick: true });
7510
7536
  }
7537
+ /** Clears the value, from the field's button or the calendar's. */
7511
7538
  commitClear() {
7512
- const changed3 = Boolean(this.value);
7513
- this.syncValue("");
7539
+ this.commitValue("", { pick: true });
7540
+ }
7541
+ /**
7542
+ * Commits a value: a pick, Clear, Enter or leaving the field. `changeSubject` and `change` report it
7543
+ * once, when it differs from the value before the typing. `input` comes first for a pick that
7544
+ * changes it, as every pick reports `input` then `change`, and for a commit that changes the value
7545
+ * `input` last reported. Text the field does not take stays as typed (`keepText`).
7546
+ */
7547
+ commitValue(value, { pick = false, keepText = false } = {}) {
7548
+ const before = this.committedValue;
7549
+ const reported = this.value;
7550
+ this.takeValue(value, keepText);
7514
7551
  this.updateValidation(this.currentValidationMessage());
7515
- if (changed3) {
7516
- this.changeSubject.next(this);
7517
- this.reportValueCommit();
7552
+ const changed3 = value !== before;
7553
+ if (changed3) this.changeSubject.next(this);
7554
+ if (value !== reported || pick && changed3) this.dispatchValueEvent("input");
7555
+ if (changed3) this.dispatchValueEvent("change");
7556
+ }
7557
+ /**
7558
+ * What the typed text leaves the field holding, as Enter takes it: the moment it names, nothing for
7559
+ * no text, and for text the field does not take (`refused`) the value from before the typing.
7560
+ */
7561
+ readDraft() {
7562
+ const text = this.draftText?.trim() ?? "";
7563
+ if (!text) return { value: "", reading: null, refused: false };
7564
+ const reading = this.manualMessage(text) ? null : this.parseManualDate(text);
7565
+ if (!reading) return { value: this.draftBase, reading: null, refused: true };
7566
+ return { value: this.formatValueWithTimezone(reading, this.passOf(reading)), reading, refused: false };
7567
+ }
7568
+ /**
7569
+ * Takes an edit of the text: the value becomes the one Enter would leave and `input` reports it,
7570
+ * the text stays as typed, and the calendar turns to a moment it names. `change` waits for Enter or
7571
+ * leaving the field.
7572
+ */
7573
+ takeEdit() {
7574
+ const { value, reading } = this.readDraft();
7575
+ const edited = value !== this.value;
7576
+ if (edited) {
7577
+ this.takeValue(value, true);
7578
+ if (reading) this.viewDate = new Date(reading);
7518
7579
  }
7580
+ this.updateValidation(this.currentValidationMessage());
7581
+ if (edited) this.dispatchValueEvent("input");
7582
+ }
7583
+ /** Enter or leaving the field: commits the typed text and writes it as the field does; text it does not take stays. */
7584
+ commitDraft() {
7585
+ const { value, refused } = this.readDraft();
7586
+ this.commitValue(value, { keepText: refused });
7519
7587
  }
7520
7588
  handleKeydown(e2) {
7521
7589
  if (this.disabled || e2.isComposing) return;
7522
7590
  if (e2.key === "Enter") {
7523
7591
  e2.preventDefault();
7524
- if (this.draftText !== null) this.commitManualInput(true);
7592
+ if (this.draftText !== null) this.commitDraft();
7525
7593
  else void this.toggleCalendar();
7526
7594
  } else if (e2.key === "ArrowDown" && e2.altKey) {
7527
7595
  e2.preventDefault();
@@ -7545,26 +7613,26 @@ var _DeesInputDatepicker = class _DeesInputDatepicker extends (_a12 = DeesInputB
7545
7613
  e2.stopPropagation();
7546
7614
  if (!this.disabled) this.commitClear();
7547
7615
  }
7616
+ /**
7617
+ * Each edit sets the value Enter would leave and reports it with `input`, without rewriting the
7618
+ * text under the caret: a moment the field takes, nothing for emptied text, and the value from
7619
+ * before the typing for text it does not take, which says why. An edit inside an IME composition
7620
+ * waits for the composition to end.
7621
+ */
7548
7622
  handleManualInput(e2) {
7549
7623
  if (this.disabled) return;
7624
+ if (this.draftText === null) this.draftBase = this.value;
7550
7625
  this.draftText = e2.target.value;
7551
- if (!e2.isComposing) this.updateValidation(this.currentValidationMessage());
7626
+ if (!e2.isComposing) this.takeEdit();
7552
7627
  }
7553
- handleInputBlur(_event) {
7554
- if (!this.disabled && this.draftText !== null) this.commitManualInput(true);
7628
+ /** The text an IME composition leaves is an edit; an engine may send no `input` after the composition ends. */
7629
+ handleCompositionEnd(e2) {
7630
+ if (this.disabled || this.draftText === null) return;
7631
+ this.draftText = e2.target.value;
7632
+ this.takeEdit();
7555
7633
  }
7556
- commitManualInput(normalizeDraft) {
7557
- const text = this.draftText?.trim() ?? "";
7558
- if (!text) {
7559
- this.commitClear();
7560
- return;
7561
- }
7562
- const message = this.manualMessage(text);
7563
- if (message) {
7564
- this.updateValidation(message);
7565
- return;
7566
- }
7567
- this.commitDate(this.parseManualDate(text), normalizeDraft);
7634
+ handleInputBlur(_event) {
7635
+ if (!this.disabled && this.draftText !== null) this.commitDraft();
7568
7636
  }
7569
7637
  /** The fields of typed text: the day, and the hour and minute when it names a time. */
7570
7638
  manualFields(input) {
@@ -7643,7 +7711,7 @@ var _DeesInputDatepicker = class _DeesInputDatepicker extends (_a12 = DeesInputB
7643
7711
  return this.value;
7644
7712
  }
7645
7713
  setValue(value) {
7646
- this.syncValue(value);
7714
+ this.takeValue(value ?? "");
7647
7715
  this.updateValidation(this.currentValidationMessage());
7648
7716
  }
7649
7717
  async disconnectedCallback() {
@@ -136980,7 +137048,7 @@ var bright = {
136980
137048
  // ts_web/00_commitinfo_data.ts
136981
137049
  var commitinfo = {
136982
137050
  name: "@design.estate/dees-catalog",
136983
- version: "24.6.1",
137051
+ version: "24.6.2",
136984
137052
  description: "A comprehensive library that provides dynamic web components for building sophisticated and modern web applications using JavaScript and TypeScript."
136985
137053
  };
136986
137054
  export {