@wildwinter/app-shell 0.29.0 → 0.30.0

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.
package/dist/index.d.cts CHANGED
@@ -379,6 +379,36 @@ declare function isValidPropertyName(name: string): boolean;
379
379
  */
380
380
  declare function isCaseOnlyPropertyName(name: string): boolean;
381
381
 
382
+ /**
383
+ * One line saying what is wrong with this name, or undefined when nothing is.
384
+ *
385
+ * Each branch names what actually HAPPENS rather than reciting the rule, because
386
+ * the person reading it is usually somebody wondering why a condition does
387
+ * nothing. Kept to one line: it lands in a rollover on the field, and hosts
388
+ * repeat it in the Save error rather than inventing a summary of their own.
389
+ */
390
+ declare function propertyNameProblem(name: string): string | undefined;
391
+ /**
392
+ * Wire a name field: mark it live, explain the fault in its rollover, and coerce
393
+ * on Tab. `onCommit` receives what the author typed, VERBATIM, on every input.
394
+ *
395
+ * `.illegal` rather than dupGuard's `.invalid`, because both can be true of one
396
+ * field and `dupGuard.check()` owns that class: it would clear this marking every
397
+ * time it ran, including at the moment of a blocked Save.
398
+ *
399
+ * An empty field is not marked. An unfinished row is a different thing from an
400
+ * illegal one, and hosts prune blank names on save.
401
+ */
402
+ declare function bindPropertyName(input: HTMLInputElement, onCommit: (value: string) => void, opts?: {
403
+ hint?: string;
404
+ }): void;
405
+ /**
406
+ * The first field in `host` holding a name no expression could reach, for a Save
407
+ * gate. Hosts hand this back beside `dupGuard.firstDuplicate()`: two faults, two
408
+ * sets of words, one gate.
409
+ */
410
+ declare function firstIllegalPropertyName(host: ParentNode): HTMLInputElement | null;
411
+
382
412
  interface GameIdEditorOptions {
383
413
  anchor: HTMLElement;
384
414
  /** The pinned address, or "" when it is being derived. */
@@ -759,4 +789,4 @@ interface StepperBarOptions {
759
789
  /** Draw (or hide) the bar in `host`. Idempotent: call it again with new state. */
760
790
  declare function renderStepperBar(host: HTMLElement, opts: StepperBarOptions): void;
761
791
 
762
- export { type AboutOptions, type AnchoredPanel, type AnchoredPanelOptions, type Child, type Comment, type CommentMessage, type CommentsOptions, type ConfirmOptions, type DocLine, type DupGuard, type ElProps, type GameIdEditorOptions, type IconName, type IconSvgName, type Identity, type IdentityOptions, type JobProgressOptions, type JobProgressView, type Notes, type NotesEditorOptions, PALETTE, PALETTE_SIZE, PROPERTY_NAME_HINT, type PaneShell, type PaneShellOptions, type PaneShellState, type PaneSide, type PaneSideConfig, type PinButton, type PinButtonOptions, RESERVED_PROPERTY_NAMES, type SaveController, type SaveControllerOptions, type SaveIndicator, type SaveStatus, type SettingsDialog, type SettingsDialogOptions, type SettingsSection, type SettingsSectionHandle, type ShardVc, type StaleBarOptions, type StepperBarOptions, type StepperItem, type StepperTone, type TipRect, type TooltipOptions, type VcMap, askIdentity, closeAnchoredPanel, closeWithExit, colourFor, colourIndex, confirmDialog, createSaveController, dupGuard, el, expandableRow, focusNewRow, foldVc, gameIdify, hideTip, icon, iconBtn, iconSvg, initTooltips, isCaseOnlyPropertyName, isValidGameId, isValidPropertyName, labelled, lockControls, lockNotice, mountJobProgress, mountPaneShell, mountSettingsDialog, moveItem, openAnchoredPanel, openComments, openGameIdEditor, openNotesEditor, paintVcBadges, pinButton, placeAnchored, propertyNameify, renderStepperBar, saveIndicator, showAbout, staleBar, tagChips, tipAt, tipBold, vcBadgeFor };
792
+ export { type AboutOptions, type AnchoredPanel, type AnchoredPanelOptions, type Child, type Comment, type CommentMessage, type CommentsOptions, type ConfirmOptions, type DocLine, type DupGuard, type ElProps, type GameIdEditorOptions, type IconName, type IconSvgName, type Identity, type IdentityOptions, type JobProgressOptions, type JobProgressView, type Notes, type NotesEditorOptions, PALETTE, PALETTE_SIZE, PROPERTY_NAME_HINT, type PaneShell, type PaneShellOptions, type PaneShellState, type PaneSide, type PaneSideConfig, type PinButton, type PinButtonOptions, RESERVED_PROPERTY_NAMES, type SaveController, type SaveControllerOptions, type SaveIndicator, type SaveStatus, type SettingsDialog, type SettingsDialogOptions, type SettingsSection, type SettingsSectionHandle, type ShardVc, type StaleBarOptions, type StepperBarOptions, type StepperItem, type StepperTone, type TipRect, type TooltipOptions, type VcMap, askIdentity, bindPropertyName, closeAnchoredPanel, closeWithExit, colourFor, colourIndex, confirmDialog, createSaveController, dupGuard, el, expandableRow, firstIllegalPropertyName, focusNewRow, foldVc, gameIdify, hideTip, icon, iconBtn, iconSvg, initTooltips, isCaseOnlyPropertyName, isValidGameId, isValidPropertyName, labelled, lockControls, lockNotice, mountJobProgress, mountPaneShell, mountSettingsDialog, moveItem, openAnchoredPanel, openComments, openGameIdEditor, openNotesEditor, paintVcBadges, pinButton, placeAnchored, propertyNameProblem, propertyNameify, renderStepperBar, saveIndicator, showAbout, staleBar, tagChips, tipAt, tipBold, vcBadgeFor };
package/dist/index.d.ts CHANGED
@@ -379,6 +379,36 @@ declare function isValidPropertyName(name: string): boolean;
379
379
  */
380
380
  declare function isCaseOnlyPropertyName(name: string): boolean;
381
381
 
382
+ /**
383
+ * One line saying what is wrong with this name, or undefined when nothing is.
384
+ *
385
+ * Each branch names what actually HAPPENS rather than reciting the rule, because
386
+ * the person reading it is usually somebody wondering why a condition does
387
+ * nothing. Kept to one line: it lands in a rollover on the field, and hosts
388
+ * repeat it in the Save error rather than inventing a summary of their own.
389
+ */
390
+ declare function propertyNameProblem(name: string): string | undefined;
391
+ /**
392
+ * Wire a name field: mark it live, explain the fault in its rollover, and coerce
393
+ * on Tab. `onCommit` receives what the author typed, VERBATIM, on every input.
394
+ *
395
+ * `.illegal` rather than dupGuard's `.invalid`, because both can be true of one
396
+ * field and `dupGuard.check()` owns that class: it would clear this marking every
397
+ * time it ran, including at the moment of a blocked Save.
398
+ *
399
+ * An empty field is not marked. An unfinished row is a different thing from an
400
+ * illegal one, and hosts prune blank names on save.
401
+ */
402
+ declare function bindPropertyName(input: HTMLInputElement, onCommit: (value: string) => void, opts?: {
403
+ hint?: string;
404
+ }): void;
405
+ /**
406
+ * The first field in `host` holding a name no expression could reach, for a Save
407
+ * gate. Hosts hand this back beside `dupGuard.firstDuplicate()`: two faults, two
408
+ * sets of words, one gate.
409
+ */
410
+ declare function firstIllegalPropertyName(host: ParentNode): HTMLInputElement | null;
411
+
382
412
  interface GameIdEditorOptions {
383
413
  anchor: HTMLElement;
384
414
  /** The pinned address, or "" when it is being derived. */
@@ -759,4 +789,4 @@ interface StepperBarOptions {
759
789
  /** Draw (or hide) the bar in `host`. Idempotent: call it again with new state. */
760
790
  declare function renderStepperBar(host: HTMLElement, opts: StepperBarOptions): void;
761
791
 
762
- export { type AboutOptions, type AnchoredPanel, type AnchoredPanelOptions, type Child, type Comment, type CommentMessage, type CommentsOptions, type ConfirmOptions, type DocLine, type DupGuard, type ElProps, type GameIdEditorOptions, type IconName, type IconSvgName, type Identity, type IdentityOptions, type JobProgressOptions, type JobProgressView, type Notes, type NotesEditorOptions, PALETTE, PALETTE_SIZE, PROPERTY_NAME_HINT, type PaneShell, type PaneShellOptions, type PaneShellState, type PaneSide, type PaneSideConfig, type PinButton, type PinButtonOptions, RESERVED_PROPERTY_NAMES, type SaveController, type SaveControllerOptions, type SaveIndicator, type SaveStatus, type SettingsDialog, type SettingsDialogOptions, type SettingsSection, type SettingsSectionHandle, type ShardVc, type StaleBarOptions, type StepperBarOptions, type StepperItem, type StepperTone, type TipRect, type TooltipOptions, type VcMap, askIdentity, closeAnchoredPanel, closeWithExit, colourFor, colourIndex, confirmDialog, createSaveController, dupGuard, el, expandableRow, focusNewRow, foldVc, gameIdify, hideTip, icon, iconBtn, iconSvg, initTooltips, isCaseOnlyPropertyName, isValidGameId, isValidPropertyName, labelled, lockControls, lockNotice, mountJobProgress, mountPaneShell, mountSettingsDialog, moveItem, openAnchoredPanel, openComments, openGameIdEditor, openNotesEditor, paintVcBadges, pinButton, placeAnchored, propertyNameify, renderStepperBar, saveIndicator, showAbout, staleBar, tagChips, tipAt, tipBold, vcBadgeFor };
792
+ export { type AboutOptions, type AnchoredPanel, type AnchoredPanelOptions, type Child, type Comment, type CommentMessage, type CommentsOptions, type ConfirmOptions, type DocLine, type DupGuard, type ElProps, type GameIdEditorOptions, type IconName, type IconSvgName, type Identity, type IdentityOptions, type JobProgressOptions, type JobProgressView, type Notes, type NotesEditorOptions, PALETTE, PALETTE_SIZE, PROPERTY_NAME_HINT, type PaneShell, type PaneShellOptions, type PaneShellState, type PaneSide, type PaneSideConfig, type PinButton, type PinButtonOptions, RESERVED_PROPERTY_NAMES, type SaveController, type SaveControllerOptions, type SaveIndicator, type SaveStatus, type SettingsDialog, type SettingsDialogOptions, type SettingsSection, type SettingsSectionHandle, type ShardVc, type StaleBarOptions, type StepperBarOptions, type StepperItem, type StepperTone, type TipRect, type TooltipOptions, type VcMap, askIdentity, bindPropertyName, closeAnchoredPanel, closeWithExit, colourFor, colourIndex, confirmDialog, createSaveController, dupGuard, el, expandableRow, firstIllegalPropertyName, focusNewRow, foldVc, gameIdify, hideTip, icon, iconBtn, iconSvg, initTooltips, isCaseOnlyPropertyName, isValidGameId, isValidPropertyName, labelled, lockControls, lockNotice, mountJobProgress, mountPaneShell, mountSettingsDialog, moveItem, openAnchoredPanel, openComments, openGameIdEditor, openNotesEditor, paintVcBadges, pinButton, placeAnchored, propertyNameProblem, propertyNameify, renderStepperBar, saveIndicator, showAbout, staleBar, tagChips, tipAt, tipBold, vcBadgeFor };
package/dist/index.js CHANGED
@@ -879,6 +879,54 @@ function isCaseOnlyPropertyName(name) {
879
879
  return !isValidPropertyName(name) && isValidPropertyName(name.toLowerCase());
880
880
  }
881
881
 
882
+ // src/property-name-field.ts
883
+ function propertyNameProblem(name) {
884
+ if (isValidPropertyName(name)) return void 0;
885
+ const suggestion = propertyNameify(name);
886
+ const tail = suggestion ? ` Try "${suggestion}", or press Tab.` : "";
887
+ if (RESERVED_PROPERTY_NAMES.includes(name.toLowerCase())) {
888
+ return `Cannot be used: "${name.toLowerCase()}" is a keyword in expressions.${tail}`;
889
+ }
890
+ if (name.includes("-")) return `Cannot be used: a hyphen reads as subtraction in an expression.${tail}`;
891
+ if (/^[0-9]/.test(name)) return `Cannot be used: a name cannot start with a digit.${tail}`;
892
+ if (name !== name.toLowerCase()) {
893
+ return `Cannot be used: expressions fold names, so this would look for "${name.toLowerCase()}".${tail}`;
894
+ }
895
+ return `Cannot be used: only lower case letters, digits and underscores.${tail}`;
896
+ }
897
+ function bindPropertyName(input, onCommit, opts = {}) {
898
+ const hint = opts.hint;
899
+ const sync = () => {
900
+ const v = input.value.trim();
901
+ const problem = v === "" ? void 0 : propertyNameProblem(v);
902
+ input.classList.toggle("illegal", !!problem);
903
+ if (problem) input.title = problem;
904
+ else if (input.title.startsWith("Cannot be used")) {
905
+ if (hint) input.title = hint;
906
+ else input.removeAttribute("title");
907
+ }
908
+ };
909
+ input.addEventListener("input", () => {
910
+ onCommit(input.value);
911
+ sync();
912
+ });
913
+ input.addEventListener("keydown", (e) => {
914
+ if (e.key !== "Tab" || e.shiftKey) return;
915
+ const typed = input.value.trim();
916
+ if (typed === "" || isValidPropertyName(typed)) return;
917
+ const coerced = propertyNameify(typed);
918
+ if (!coerced || coerced === input.value) return;
919
+ e.preventDefault();
920
+ input.value = coerced;
921
+ onCommit(coerced);
922
+ sync();
923
+ });
924
+ sync();
925
+ }
926
+ function firstIllegalPropertyName(host) {
927
+ return host.querySelector("input.illegal");
928
+ }
929
+
882
930
  // src/id-editor.ts
883
931
  function openGameIdEditor(opts) {
884
932
  const slugify = opts.slugify ?? gameIdify;
@@ -1539,6 +1587,6 @@ function renderStepperBar(host, opts) {
1539
1587
  );
1540
1588
  }
1541
1589
 
1542
- export { PALETTE, PALETTE_SIZE, PROPERTY_NAME_HINT, RESERVED_PROPERTY_NAMES, askIdentity, closeAnchoredPanel, closeWithExit, colourFor, colourIndex, confirmDialog, createSaveController, dupGuard, el, expandableRow, focusNewRow, foldVc, gameIdify, hideTip, icon, iconBtn, iconSvg, initTooltips, isCaseOnlyPropertyName, isValidGameId, isValidPropertyName, labelled, lockControls, lockNotice, mountJobProgress, mountPaneShell, mountSettingsDialog, moveItem, openAnchoredPanel, openComments, openGameIdEditor, openNotesEditor, paintVcBadges, pinButton, placeAnchored, propertyNameify, renderStepperBar, saveIndicator, showAbout, staleBar, tagChips, tipAt, tipBold, vcBadgeFor };
1590
+ export { PALETTE, PALETTE_SIZE, PROPERTY_NAME_HINT, RESERVED_PROPERTY_NAMES, askIdentity, bindPropertyName, closeAnchoredPanel, closeWithExit, colourFor, colourIndex, confirmDialog, createSaveController, dupGuard, el, expandableRow, firstIllegalPropertyName, focusNewRow, foldVc, gameIdify, hideTip, icon, iconBtn, iconSvg, initTooltips, isCaseOnlyPropertyName, isValidGameId, isValidPropertyName, labelled, lockControls, lockNotice, mountJobProgress, mountPaneShell, mountSettingsDialog, moveItem, openAnchoredPanel, openComments, openGameIdEditor, openNotesEditor, paintVcBadges, pinButton, placeAnchored, propertyNameProblem, propertyNameify, renderStepperBar, saveIndicator, showAbout, staleBar, tagChips, tipAt, tipBold, vcBadgeFor };
1543
1591
  //# sourceMappingURL=index.js.map
1544
1592
  //# sourceMappingURL=index.js.map