@oods/components-vue 0.4.0 → 0.4.1

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.js CHANGED
@@ -1,5 +1,5 @@
1
- import { defineComponent, h, useId, computed, ref, onMounted, watch, nextTick, onBeforeUnmount, isVNode, Text as Text$1, Comment, Fragment } from 'vue';
2
- import { vizPreviewLayers, svgCarriesTitle, formatPriceAmount, formatPriceCode, formatReferenceLabel, summaryValue, formatDateTime, dateTimeInputValue, formatReadOnlyValue, BILLING_MINOR_UNITS, billingSummary, formatBillingAmount, billingAmountText, billingAmountMessage, parseBillingAmount, BILLING_INTERVALS, billingIntervalMessage, billingCycle, auditSummary, initialSort, ariaSort, nextSort, recipeItemLabels, DEFAULT_COLOR_STATES, geoFieldMapping, STATUS_ICON_SVG_ATTRS, STATUS_ICON_SHAPES, getStatusPresentation, resolveStatusIcon, currencyMinorUnits, billingPaymentSummary, billingPaymentRows, traitEventRows, vizControlFields, VIZ_CONTROL_TITLES, vizFieldValue, vizSummaryRows, editVizIntent } from '@oods/component-contracts';
1
+ import { defineComponent, h, useId, computed, ref, onMounted, onBeforeUnmount, watch, nextTick, isVNode, Text as Text$1, Comment, Fragment } from 'vue';
2
+ import { vizPreviewLayers, svgCarriesTitle, formatPriceAmount, formatPriceCode, formatReferenceLabel, ownershipPhrase, summaryValue, formatDateTime, dateTimeInputValue, formatReadOnlyValue, BILLING_MINOR_UNITS, billingSummary, formatBillingAmount, billingAmountText, billingAmountMessage, parseBillingAmount, BILLING_INTERVALS, billingIntervalMessage, billingCycle, auditSummary, initialSort, ariaSort, nextSort, recipeItemLabels, DEFAULT_COLOR_STATES, geoFieldMapping, STATUS_ICON_SVG_ATTRS, STATUS_ICON_SHAPES, getStatusPresentation, resolveStatusIcon, currencyMinorUnits, billingPaymentSummary, billingPaymentRows, traitEventRows, vizControlFields, VIZ_CONTROL_TITLES, vizFieldValue, vizSummaryRows, editVizIntent } from '@oods/component-contracts';
3
3
 
4
4
  // src/primitives.ts
5
5
  function statusIcon(name) {
@@ -185,6 +185,31 @@ var Button = defineComponent({
185
185
  }
186
186
  });
187
187
  var canShowModal = () => typeof HTMLDialogElement !== "undefined" && typeof HTMLDialogElement.prototype.showModal === "function";
188
+ var pageLocks = 0;
189
+ var pageStyle;
190
+ function lockPageScroll() {
191
+ const page = document.documentElement;
192
+ if (pageLocks++ === 0) {
193
+ const scrollbar = window.innerWidth - page.clientWidth;
194
+ pageStyle = { overflow: page.style.overflow, paddingRight: page.style.paddingRight };
195
+ if (scrollbar > 0) page.style.paddingRight = `${parseFloat(getComputedStyle(page).paddingRight) + scrollbar}px`;
196
+ page.style.overflow = "hidden";
197
+ }
198
+ let held = true;
199
+ return () => {
200
+ if (!held) return;
201
+ held = false;
202
+ if (--pageLocks === 0 && pageStyle) {
203
+ page.style.overflow = pageStyle.overflow;
204
+ page.style.paddingRight = pageStyle.paddingRight;
205
+ pageStyle = void 0;
206
+ }
207
+ };
208
+ }
209
+ var outsideBox = (event, dialog) => {
210
+ const box = dialog.getBoundingClientRect();
211
+ return event.clientX < box.left || event.clientX > box.right || event.clientY < box.top || event.clientY > box.bottom;
212
+ };
188
213
  var Dialog = defineComponent({
189
214
  name: "OodsDialog",
190
215
  props: {
@@ -206,15 +231,24 @@ var Dialog = defineComponent({
206
231
  const element = ref(null);
207
232
  const mounted = ref(false);
208
233
  const managed = computed(() => props.modal && mounted.value && canShowModal());
234
+ let unlockScroll;
235
+ let pressedBackdrop = false;
236
+ const releaseScroll = () => {
237
+ unlockScroll?.();
238
+ unlockScroll = void 0;
239
+ };
209
240
  const sync = () => {
210
241
  const dialog = element.value;
211
242
  if (!dialog || !managed.value) return;
212
- if (props.open && !dialog.open) dialog.showModal();
213
- else if (!props.open && dialog.open) dialog.close();
243
+ if (props.open && !dialog.open) {
244
+ dialog.showModal();
245
+ unlockScroll ??= lockPageScroll();
246
+ } else if (!props.open && dialog.open) dialog.close();
214
247
  };
215
248
  onMounted(() => {
216
249
  mounted.value = true;
217
250
  });
251
+ onBeforeUnmount(releaseScroll);
218
252
  watch([() => props.open, managed], sync, { flush: "post" });
219
253
  const requestClose = (event) => {
220
254
  event.preventDefault();
@@ -237,10 +271,23 @@ var Dialog = defineComponent({
237
271
  if (event.key === "Escape" && !event.defaultPrevented) requestClose(event);
238
272
  },
239
273
  onCancel: requestClose,
240
- // The browser closed it (a close request it would not let be cancelled) while open is still true. A close event
241
- // from moving a mounted dialog into the top layer finds it open again, and is not reported.
274
+ // A close event from moving a mounted dialog into the top layer finds it open again, and is not reported. Any other
275
+ // close releases the page; when the browser closed it (a close request it would not let be cancelled) while open is
276
+ // still true, it is reported.
242
277
  onClose: () => {
243
- if (props.open && !element.value?.open) emit("close");
278
+ if (element.value?.open) return;
279
+ releaseScroll();
280
+ if (props.open) emit("close");
281
+ },
282
+ onMousedown: (event) => {
283
+ pressedBackdrop = managed.value && event.target === event.currentTarget && outsideBox(event, event.currentTarget);
284
+ },
285
+ // s223-m02 (#2527 ruling 13b): a click on the backdrop emits close, as the close control does. A press that began
286
+ // inside the dialog (text selected and dragged out) is not a backdrop click.
287
+ onClick: (event) => {
288
+ const backdrop = pressedBackdrop && event.target === event.currentTarget && outsideBox(event, event.currentTarget);
289
+ pressedBackdrop = false;
290
+ if (backdrop) emit("close");
244
291
  }
245
292
  }, [
246
293
  h("div", { class: "oods-dialog__header" }, [
@@ -803,12 +850,15 @@ function createBadgeFamily(options) {
803
850
  };
804
851
  for (const key of options.extraProps) props[key] = String;
805
852
  for (const key of options.booleanProps ?? []) props[key] = { type: [String, Boolean], default: void 0 };
853
+ if (options.booleanProps) props.hideWhenFalse = { type: [Boolean, String], default: void 0 };
806
854
  return defineComponent({
807
855
  name: `Oods${options.component}`,
808
856
  props,
809
857
  setup(componentProps, { slots }) {
810
858
  return () => {
811
859
  const record = componentProps;
860
+ const flag = options.booleanProps?.map((key) => record[key]).find((value) => typeof value === "boolean");
861
+ if (record.hideWhenFalse === true && flag === false) return null;
812
862
  const content = authoredContent(slots.default?.());
813
863
  const scalar = scalarContent(content);
814
864
  const read = (key) => typeof record[key] === "boolean" && options.booleanProps?.includes(key) ? String(record[key]) : record[key];
@@ -1435,12 +1485,13 @@ var TagSummary = defineComponent({
1435
1485
  });
1436
1486
  var OwnershipMeta = defineComponent({
1437
1487
  name: "OodsOwnershipMeta",
1438
- props: { title: String, label: String, heading: String, name: String, ownerType: String, owner_type: String, role: String, ownershipRole: String },
1488
+ props: { title: String, label: String, heading: String, name: String, ownerType: String, owner_type: String, role: String, ownershipRole: String, ownerLabel: String },
1439
1489
  setup(props, { slots }) {
1440
1490
  return () => {
1441
1491
  const content = authoredContent(slots.default?.());
1442
1492
  const terms = [["Owner Type", firstScalar(props.ownerType, props.owner_type)], ["Role", firstScalar(props.role, props.ownershipRole)]].filter((entry) => entry[1] !== void 0);
1443
- return h("div", { class: "oods-ownership-meta", "data-oods-component": "OwnershipMeta", "data-meta-type": "ownership" }, content.length ? content : [
1493
+ const phrase = props.ownerLabel !== void 0 ? ownershipPhrase(props.ownerLabel, firstScalar(props.ownerType, props.owner_type), firstScalar(props.role, props.ownershipRole)) : void 0;
1494
+ return h("div", { class: "oods-ownership-meta", "data-oods-component": "OwnershipMeta", "data-meta-type": "ownership" }, content.length ? content : phrase ? [h("span", { "data-meta-item": "true" }, phrase)] : [
1444
1495
  h("span", { "data-meta-title": "true" }, firstText(props.title, props.label, props.heading, props.name) ?? "Ownership"),
1445
1496
  ...terms.map(([term, value]) => h("span", { key: term, "data-meta-item": "true" }, [h("strong", `${term}:`), ` ${value}`]))
1446
1497
  ]);
@@ -2166,6 +2217,63 @@ var Tabs = defineComponent({
2166
2217
  ]);
2167
2218
  }
2168
2219
  });
2220
+ var SegmentedControl = defineComponent({
2221
+ name: "OodsSegmentedControl",
2222
+ props: {
2223
+ id: String,
2224
+ label: String,
2225
+ modelValue: String,
2226
+ value: String,
2227
+ defaultValue: { type: String, default: "" },
2228
+ name: String,
2229
+ size: { type: String, default: "md" },
2230
+ disabled: Boolean,
2231
+ options: { type: Array, default: () => [] }
2232
+ },
2233
+ emits: {
2234
+ "update:modelValue": (_value) => true,
2235
+ change: (_value) => true
2236
+ },
2237
+ setup(props, { emit, slots }) {
2238
+ const generatedId = useId();
2239
+ const internalValue = ref(props.defaultValue);
2240
+ const currentValue = computed(() => props.modelValue ?? props.value ?? internalValue.value);
2241
+ const select = (event) => {
2242
+ const next = event.target.value;
2243
+ if (props.modelValue === void 0 && props.value === void 0) internalValue.value = next;
2244
+ emit("update:modelValue", next);
2245
+ emit("change", next);
2246
+ };
2247
+ return () => {
2248
+ const id = props.id || `oods-segmentedcontrol-${generatedId}`;
2249
+ const label = slots.label?.() ?? props.label;
2250
+ return h("div", {
2251
+ class: "oods-field oods-segmented-control",
2252
+ "data-oods-component": "SegmentedControl",
2253
+ "data-size": props.size
2254
+ }, [
2255
+ h("span", { id: `${id}-label`, class: "oods-field-label" }, [label]),
2256
+ h("div", {
2257
+ id,
2258
+ role: "radiogroup",
2259
+ "aria-labelledby": `${id}-label`,
2260
+ class: "oods-segmented-control__track"
2261
+ }, props.options.map((option) => h("label", { key: option.value, class: "oods-segmented-control__option" }, [
2262
+ h("input", {
2263
+ type: "radio",
2264
+ class: "oods-segmented-control__input",
2265
+ name: props.name || id,
2266
+ value: option.value,
2267
+ checked: option.value === currentValue.value,
2268
+ disabled: props.disabled || option.disabled,
2269
+ onChange: select
2270
+ }),
2271
+ h("span", { class: "oods-segmented-control__label" }, option.label)
2272
+ ])))
2273
+ ]);
2274
+ };
2275
+ }
2276
+ });
2169
2277
  function isRecord2(value) {
2170
2278
  return typeof value === "object" && value !== null && !Array.isArray(value);
2171
2279
  }
@@ -2983,7 +3091,8 @@ var array = Array;
2983
3091
  function eventRecipe(id, kind, title) {
2984
3092
  return defineComponent({ name: id, props: { id: String, title: { type: String, default: title }, archivedAt: String, restoredAt: String, archivedBy: String, reason: String, timestamp: String, code: String, history: array, status: String, showActor: { type: Boolean, default: true }, showReason: { type: Boolean, default: true } }, setup: (props) => () => {
2985
3093
  const rows = traitEventRows(kind, props);
2986
- return h("article", { id: props.id, class: "oods-trait-recipe", "data-oods-component": id, "aria-label": props.title }, [h("h2", props.title), rows.length ? h("ol", rows.map((row, index) => h("li", { key: index }, [h("strong", row.title), h("p", row.at ? h("time", { datetime: row.at }, row.time) : row.time), row.actor && h("p", `Actor: ${row.actor}`), row.reason && h("p", `Reason: ${row.reason}`), row.code && h("p", `Code: ${row.code}`)]))) : h("p", "No events recorded.")]);
3094
+ if (!rows.length) return null;
3095
+ return h("article", { id: props.id, class: "oods-trait-recipe", "data-oods-component": id, "aria-label": props.title }, [h("h2", props.title), h("ol", rows.map((row, index) => h("li", { key: index }, [h("strong", row.title), h("p", row.at ? h("time", { datetime: row.at }, row.time) : row.time), row.actor && h("p", `Actor: ${row.actor}`), row.reason && h("p", `Reason: ${row.reason}`), row.code && h("p", `Code: ${row.code}`)])))]);
2987
3096
  } });
2988
3097
  }
2989
3098
  var ArchiveEvent = eventRecipe("ArchiveEvent", "archive", "Archive events");
@@ -3084,5 +3193,210 @@ var VizLinePreview = preview("VizLinePreview", "line");
3084
3193
  var VizMarkPreview = preview("VizMarkPreview", "bar");
3085
3194
  var VizPointPreview = preview("VizPointPreview", "scatter");
3086
3195
  var VizScatterPreview = preview("VizScatterPreview", "scatter");
3196
+ var Combobox = defineComponent({
3197
+ name: "OodsCombobox",
3198
+ props: {
3199
+ id: String,
3200
+ label: String,
3201
+ options: { type: Array, default: () => [] },
3202
+ modelValue: String,
3203
+ value: String,
3204
+ defaultValue: { type: String, default: "" },
3205
+ placeholder: String,
3206
+ name: String,
3207
+ required: Boolean,
3208
+ disabled: Boolean,
3209
+ help: String,
3210
+ validation: Object,
3211
+ /** The control height, as Button, Input and Select: xs 24, sm 28, md 32 (default) or lg 40. */
3212
+ size: { type: String, default: "md" }
3213
+ },
3214
+ emits: {
3215
+ "update:modelValue": (_value) => true,
3216
+ change: (_value) => true
3217
+ },
3218
+ setup(props, { emit, slots }) {
3219
+ const generatedId = useId();
3220
+ const controlId = computed(() => props.id || `oods-combobox-${generatedId}`);
3221
+ const internalValue = ref(props.defaultValue);
3222
+ const query = ref(null);
3223
+ const open = ref(false);
3224
+ const active = ref(-1);
3225
+ const root = ref(null);
3226
+ const listbox = ref(null);
3227
+ const chosenValue = computed(() => props.modelValue ?? props.value ?? internalValue.value);
3228
+ const chosen = computed(() => props.options.find((option) => option.value === chosenValue.value));
3229
+ const text = computed(() => query.value ?? chosen.value?.label ?? "");
3230
+ const matches = computed(() => {
3231
+ const needle = (query.value ?? "").trim().toLowerCase();
3232
+ return props.options.map((option) => needle === "" || option.label.toLowerCase().includes(needle));
3233
+ });
3234
+ const reachable = computed(() => props.options.flatMap((option, index) => matches.value[index] && !option.disabled ? [index] : []));
3235
+ const optionId = (index) => `${controlId.value}-option-${index}`;
3236
+ const close = () => {
3237
+ open.value = false;
3238
+ active.value = -1;
3239
+ };
3240
+ const commit = (next) => {
3241
+ if (props.modelValue === void 0 && props.value === void 0) internalValue.value = next;
3242
+ emit("update:modelValue", next);
3243
+ emit("change", next);
3244
+ };
3245
+ const pick = (index) => {
3246
+ const option = props.options[index];
3247
+ if (!option || option.disabled) return;
3248
+ query.value = null;
3249
+ close();
3250
+ if (option.value !== chosenValue.value) commit(option.value);
3251
+ };
3252
+ const outside = (event) => {
3253
+ if (!root.value?.contains(event.target)) close();
3254
+ };
3255
+ watch(open, (isOpen) => {
3256
+ if (isOpen) document.addEventListener("pointerdown", outside);
3257
+ else document.removeEventListener("pointerdown", outside);
3258
+ });
3259
+ onBeforeUnmount(() => {
3260
+ if (typeof document !== "undefined") document.removeEventListener("pointerdown", outside);
3261
+ });
3262
+ watch([open, active], async () => {
3263
+ if (!open.value || active.value < 0) return;
3264
+ await nextTick();
3265
+ const element = listbox.value?.children[active.value];
3266
+ element?.scrollIntoView?.({ block: "nearest" });
3267
+ });
3268
+ const keydown = (event) => {
3269
+ if (event.defaultPrevented || props.disabled || event.isComposing) return;
3270
+ const order = reachable.value;
3271
+ const first = order[0] ?? -1;
3272
+ const last = order[order.length - 1] ?? -1;
3273
+ const at = order.indexOf(active.value);
3274
+ switch (event.key) {
3275
+ case "ArrowDown":
3276
+ event.preventDefault();
3277
+ active.value = !open.value || at === -1 ? first : order[(at + 1) % order.length];
3278
+ open.value = true;
3279
+ return;
3280
+ case "ArrowUp":
3281
+ event.preventDefault();
3282
+ active.value = !open.value || at <= 0 ? last : order[at - 1];
3283
+ open.value = true;
3284
+ return;
3285
+ case "Home":
3286
+ case "End":
3287
+ if (!open.value) return;
3288
+ event.preventDefault();
3289
+ active.value = event.key === "Home" ? first : last;
3290
+ return;
3291
+ case "Enter":
3292
+ if (!open.value) return;
3293
+ event.preventDefault();
3294
+ if (active.value >= 0) pick(active.value);
3295
+ return;
3296
+ case "Escape":
3297
+ if (open.value) {
3298
+ event.preventDefault();
3299
+ close();
3300
+ return;
3301
+ }
3302
+ if (text.value === "" && chosenValue.value === "") return;
3303
+ event.preventDefault();
3304
+ query.value = null;
3305
+ if (chosenValue.value !== "") commit("");
3306
+ return;
3307
+ case "Tab":
3308
+ if (open.value) close();
3309
+ return;
3310
+ }
3311
+ };
3312
+ return () => {
3313
+ const id = controlId.value;
3314
+ const label = slots.label?.() ?? props.label;
3315
+ const help = slots.help?.() ?? props.help;
3316
+ const validation = slots.validation?.() ?? props.validation?.message;
3317
+ const tone = props.validation ? props.validation.state === "error" ? "critical" : props.validation.state : void 0;
3318
+ const describedBy = [help ? `${id}-help` : void 0, validation ? `${id}-validation` : void 0].filter(Boolean).join(" ") || void 0;
3319
+ const noMatches = open.value && !matches.value.some(Boolean);
3320
+ return h("div", {
3321
+ ref: root,
3322
+ class: "oods-field oods-combobox",
3323
+ ...tone ? { style: { "--cmp-input-message-border": `var(--sys-status-${tone}-border)`, "--cmp-input-message-text": `var(--sys-status-${tone}-text)` } } : {},
3324
+ "data-oods-component": "Combobox",
3325
+ "data-size": props.size,
3326
+ "data-validation-state": props.validation?.state
3327
+ }, [
3328
+ h("label", { id: `${id}-label`, class: "oods-field-label", for: id }, [
3329
+ label,
3330
+ props.required ? h("span", { class: "oods-field-required", "aria-hidden": "true" }, "*") : null
3331
+ ]),
3332
+ h("div", { class: "oods-combobox__control" }, [
3333
+ h("input", {
3334
+ id,
3335
+ type: "text",
3336
+ role: "combobox",
3337
+ class: "oods-field-control oods-combobox__input",
3338
+ value: text.value,
3339
+ placeholder: props.placeholder,
3340
+ autocomplete: "off",
3341
+ "aria-autocomplete": "list",
3342
+ "aria-expanded": open.value ? "true" : "false",
3343
+ "aria-controls": `${id}-listbox`,
3344
+ "aria-activedescendant": open.value && active.value >= 0 ? optionId(active.value) : void 0,
3345
+ "aria-describedby": describedBy,
3346
+ "aria-invalid": props.validation?.state === "error" ? "true" : void 0,
3347
+ required: props.required,
3348
+ disabled: props.disabled,
3349
+ onInput: (event) => {
3350
+ query.value = event.target.value;
3351
+ open.value = true;
3352
+ active.value = -1;
3353
+ },
3354
+ onKeydown: keydown,
3355
+ onClick: () => {
3356
+ if (!props.disabled) open.value = true;
3357
+ },
3358
+ onBlur: () => {
3359
+ query.value = null;
3360
+ close();
3361
+ }
3362
+ }),
3363
+ h("span", { class: "oods-combobox__chevron", "aria-hidden": "true" }, [statusIcon("chevron-down")]),
3364
+ h("div", {
3365
+ class: "oods-combobox__popup",
3366
+ hidden: !open.value,
3367
+ onMousedown: (event) => event.preventDefault()
3368
+ }, [
3369
+ h(
3370
+ "ul",
3371
+ { ref: listbox, id: `${id}-listbox`, class: "oods-combobox__listbox", role: "listbox", "aria-labelledby": `${id}-label` },
3372
+ props.options.map((option, index) => h("li", {
3373
+ key: option.value,
3374
+ id: optionId(index),
3375
+ class: "oods-combobox__option",
3376
+ role: "option",
3377
+ "aria-selected": option.value === chosenValue.value ? "true" : "false",
3378
+ "aria-disabled": option.disabled ? "true" : void 0,
3379
+ "data-value": option.value,
3380
+ "data-active": index === active.value ? "true" : void 0,
3381
+ hidden: !matches.value[index],
3382
+ onClick: () => pick(index),
3383
+ onPointermove: () => {
3384
+ if (!option.disabled && index !== active.value) active.value = index;
3385
+ }
3386
+ }, [
3387
+ h("span", { class: "oods-combobox__option-label" }, option.label),
3388
+ h("span", { class: "oods-combobox__check", "aria-hidden": "true" }, [statusIcon("check")])
3389
+ ]))
3390
+ ),
3391
+ h("p", { class: "oods-combobox__empty", role: "status" }, noMatches ? "No matches" : "")
3392
+ ])
3393
+ ]),
3394
+ props.name ? h("input", { type: "hidden", name: props.name, value: chosenValue.value }) : null,
3395
+ help ? h("p", { id: `${id}-help`, class: "oods-field-help" }, help) : null,
3396
+ validation ? h("p", { id: `${id}-validation`, class: "oods-field-error", role: props.validation?.state === "error" ? "alert" : void 0 }, validation) : null
3397
+ ]);
3398
+ };
3399
+ }
3400
+ });
3087
3401
 
3088
- export { AddressCollectionPanel, AddressEditor, AddressSummaryBadge, AddressValidationTimeline, ArchiveEvent, ArchivePill, ArchiveSummary, ArchivedRowOverlay, AuditEvent, AuditSummaryCard, AuditTimeline, Badge, Banner, BillingAmountInput, BillingCardMeta, BillingIntervalSelector, BillingSummaryBadge, Button, CancellationBadge, CancellationEvent, CancellationForm, CancellationSummary, Card, CardHeader, Checkbox, ClassificationBadge, ClassificationEditor, ClassificationPanel, ColorStatePicker, ColorSwatch, ColorizedBadge, CommunicationDetailPanel, CycleProgressCard, DatePicker, DetailHeader, Dialog, FilterPanel, FormLabelGroup, GeoFieldMappingForm, GeoResolutionBadge, GeocodablePreview, Grid, InlineLabel, Input, LabelCell, MembershipAuditTimeline, MembershipPanel, MessageEventTimeline, MessageStatusBadge, OwnerBadge, OwnershipMeta, OwnershipSummary, PaginationBar, PaymentEventTimeline, PaymentTimeline, PreferenceEditor, PreferencePanel, PreferenceSummaryBadge, PreferenceTimeline, PriceBadge, PriceCardMeta, PriceSummary, RelativeTimestamp, RoleAssignmentForm, RoleBadgeList, SearchInput, Select, SortIndicator, Stack, StateTransitionEvent, StatusBadge, StatusColorLegend, StatusSelector, StatusTimeline, Switch, Table, TableBody, TableCaption, TableCell, TableHead, TableHeaderCell, TableRow, Tabs, TagInput, TagManager, TagPills, TagSummary, TemplatePicker, Text, Textarea, TimelineEntryLabel, VizAreaControls, VizAreaPreview, VizAxisControls, VizAxisSummary, VizColorControls, VizColorLegendConfig, VizEncodingBadge, VizGraphPreview, VizHeatmapControls, VizHeatmapPreview, VizLineControls, VizLinePreview, VizMarkControls, VizMarkPreview, VizOpacityControls, VizOpacitySummary, VizPointControls, VizPointPreview, VizRoleBadge, VizScaleControls, VizScaleSummary, VizScatterControls, VizScatterPreview, VizShapeControls, VizShapeLegend, VizSizeControls, VizSizeSummary };
3402
+ export { AddressCollectionPanel, AddressEditor, AddressSummaryBadge, AddressValidationTimeline, ArchiveEvent, ArchivePill, ArchiveSummary, ArchivedRowOverlay, AuditEvent, AuditSummaryCard, AuditTimeline, Badge, Banner, BillingAmountInput, BillingCardMeta, BillingIntervalSelector, BillingSummaryBadge, Button, CancellationBadge, CancellationEvent, CancellationForm, CancellationSummary, Card, CardHeader, Checkbox, ClassificationBadge, ClassificationEditor, ClassificationPanel, ColorStatePicker, ColorSwatch, ColorizedBadge, Combobox, CommunicationDetailPanel, CycleProgressCard, DatePicker, DetailHeader, Dialog, FilterPanel, FormLabelGroup, GeoFieldMappingForm, GeoResolutionBadge, GeocodablePreview, Grid, InlineLabel, Input, LabelCell, MembershipAuditTimeline, MembershipPanel, MessageEventTimeline, MessageStatusBadge, OwnerBadge, OwnershipMeta, OwnershipSummary, PaginationBar, PaymentEventTimeline, PaymentTimeline, PreferenceEditor, PreferencePanel, PreferenceSummaryBadge, PreferenceTimeline, PriceBadge, PriceCardMeta, PriceSummary, RelativeTimestamp, RoleAssignmentForm, RoleBadgeList, SearchInput, SegmentedControl, Select, SortIndicator, Stack, StateTransitionEvent, StatusBadge, StatusColorLegend, StatusSelector, StatusTimeline, Switch, Table, TableBody, TableCaption, TableCell, TableHead, TableHeaderCell, TableRow, Tabs, TagInput, TagManager, TagPills, TagSummary, TemplatePicker, Text, Textarea, TimelineEntryLabel, VizAreaControls, VizAreaPreview, VizAxisControls, VizAxisSummary, VizColorControls, VizColorLegendConfig, VizEncodingBadge, VizGraphPreview, VizHeatmapControls, VizHeatmapPreview, VizLineControls, VizLinePreview, VizMarkControls, VizMarkPreview, VizOpacityControls, VizOpacitySummary, VizPointControls, VizPointPreview, VizRoleBadge, VizScaleControls, VizScaleSummary, VizScatterControls, VizScatterPreview, VizShapeControls, VizShapeLegend, VizSizeControls, VizSizeSummary };
package/dist/ported.cjs CHANGED
@@ -187,6 +187,31 @@ vue.defineComponent({
187
187
  }
188
188
  });
189
189
  var canShowModal = () => typeof HTMLDialogElement !== "undefined" && typeof HTMLDialogElement.prototype.showModal === "function";
190
+ var pageLocks = 0;
191
+ var pageStyle;
192
+ function lockPageScroll() {
193
+ const page = document.documentElement;
194
+ if (pageLocks++ === 0) {
195
+ const scrollbar = window.innerWidth - page.clientWidth;
196
+ pageStyle = { overflow: page.style.overflow, paddingRight: page.style.paddingRight };
197
+ if (scrollbar > 0) page.style.paddingRight = `${parseFloat(getComputedStyle(page).paddingRight) + scrollbar}px`;
198
+ page.style.overflow = "hidden";
199
+ }
200
+ let held = true;
201
+ return () => {
202
+ if (!held) return;
203
+ held = false;
204
+ if (--pageLocks === 0 && pageStyle) {
205
+ page.style.overflow = pageStyle.overflow;
206
+ page.style.paddingRight = pageStyle.paddingRight;
207
+ pageStyle = void 0;
208
+ }
209
+ };
210
+ }
211
+ var outsideBox = (event, dialog) => {
212
+ const box = dialog.getBoundingClientRect();
213
+ return event.clientX < box.left || event.clientX > box.right || event.clientY < box.top || event.clientY > box.bottom;
214
+ };
190
215
  vue.defineComponent({
191
216
  name: "OodsDialog",
192
217
  props: {
@@ -208,15 +233,24 @@ vue.defineComponent({
208
233
  const element = vue.ref(null);
209
234
  const mounted = vue.ref(false);
210
235
  const managed = vue.computed(() => props.modal && mounted.value && canShowModal());
236
+ let unlockScroll;
237
+ let pressedBackdrop = false;
238
+ const releaseScroll = () => {
239
+ unlockScroll?.();
240
+ unlockScroll = void 0;
241
+ };
211
242
  const sync = () => {
212
243
  const dialog = element.value;
213
244
  if (!dialog || !managed.value) return;
214
- if (props.open && !dialog.open) dialog.showModal();
215
- else if (!props.open && dialog.open) dialog.close();
245
+ if (props.open && !dialog.open) {
246
+ dialog.showModal();
247
+ unlockScroll ??= lockPageScroll();
248
+ } else if (!props.open && dialog.open) dialog.close();
216
249
  };
217
250
  vue.onMounted(() => {
218
251
  mounted.value = true;
219
252
  });
253
+ vue.onBeforeUnmount(releaseScroll);
220
254
  vue.watch([() => props.open, managed], sync, { flush: "post" });
221
255
  const requestClose = (event) => {
222
256
  event.preventDefault();
@@ -239,10 +273,23 @@ vue.defineComponent({
239
273
  if (event.key === "Escape" && !event.defaultPrevented) requestClose(event);
240
274
  },
241
275
  onCancel: requestClose,
242
- // The browser closed it (a close request it would not let be cancelled) while open is still true. A close event
243
- // from moving a mounted dialog into the top layer finds it open again, and is not reported.
276
+ // A close event from moving a mounted dialog into the top layer finds it open again, and is not reported. Any other
277
+ // close releases the page; when the browser closed it (a close request it would not let be cancelled) while open is
278
+ // still true, it is reported.
244
279
  onClose: () => {
245
- if (props.open && !element.value?.open) emit("close");
280
+ if (element.value?.open) return;
281
+ releaseScroll();
282
+ if (props.open) emit("close");
283
+ },
284
+ onMousedown: (event) => {
285
+ pressedBackdrop = managed.value && event.target === event.currentTarget && outsideBox(event, event.currentTarget);
286
+ },
287
+ // s223-m02 (#2527 ruling 13b): a click on the backdrop emits close, as the close control does. A press that began
288
+ // inside the dialog (text selected and dragged out) is not a backdrop click.
289
+ onClick: (event) => {
290
+ const backdrop = pressedBackdrop && event.target === event.currentTarget && outsideBox(event, event.currentTarget);
291
+ pressedBackdrop = false;
292
+ if (backdrop) emit("close");
246
293
  }
247
294
  }, [
248
295
  vue.h("div", { class: "oods-dialog__header" }, [
package/dist/ported.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { dateTimeInputValue, formatDateTime, formatReadOnlyValue, STATUS_ICON_SVG_ATTRS, STATUS_ICON_SHAPES, getStatusPresentation, resolveStatusIcon, currencyMinorUnits } from '@oods/component-contracts';
2
- import { defineComponent, h, useId, computed, ref, onMounted, watch, onBeforeUnmount } from 'vue';
2
+ import { defineComponent, h, useId, computed, ref, onMounted, onBeforeUnmount, watch } from 'vue';
3
3
 
4
4
  // src/ported.ts
5
5
  function statusIcon(name) {
@@ -185,6 +185,31 @@ defineComponent({
185
185
  }
186
186
  });
187
187
  var canShowModal = () => typeof HTMLDialogElement !== "undefined" && typeof HTMLDialogElement.prototype.showModal === "function";
188
+ var pageLocks = 0;
189
+ var pageStyle;
190
+ function lockPageScroll() {
191
+ const page = document.documentElement;
192
+ if (pageLocks++ === 0) {
193
+ const scrollbar = window.innerWidth - page.clientWidth;
194
+ pageStyle = { overflow: page.style.overflow, paddingRight: page.style.paddingRight };
195
+ if (scrollbar > 0) page.style.paddingRight = `${parseFloat(getComputedStyle(page).paddingRight) + scrollbar}px`;
196
+ page.style.overflow = "hidden";
197
+ }
198
+ let held = true;
199
+ return () => {
200
+ if (!held) return;
201
+ held = false;
202
+ if (--pageLocks === 0 && pageStyle) {
203
+ page.style.overflow = pageStyle.overflow;
204
+ page.style.paddingRight = pageStyle.paddingRight;
205
+ pageStyle = void 0;
206
+ }
207
+ };
208
+ }
209
+ var outsideBox = (event, dialog) => {
210
+ const box = dialog.getBoundingClientRect();
211
+ return event.clientX < box.left || event.clientX > box.right || event.clientY < box.top || event.clientY > box.bottom;
212
+ };
188
213
  defineComponent({
189
214
  name: "OodsDialog",
190
215
  props: {
@@ -206,15 +231,24 @@ defineComponent({
206
231
  const element = ref(null);
207
232
  const mounted = ref(false);
208
233
  const managed = computed(() => props.modal && mounted.value && canShowModal());
234
+ let unlockScroll;
235
+ let pressedBackdrop = false;
236
+ const releaseScroll = () => {
237
+ unlockScroll?.();
238
+ unlockScroll = void 0;
239
+ };
209
240
  const sync = () => {
210
241
  const dialog = element.value;
211
242
  if (!dialog || !managed.value) return;
212
- if (props.open && !dialog.open) dialog.showModal();
213
- else if (!props.open && dialog.open) dialog.close();
243
+ if (props.open && !dialog.open) {
244
+ dialog.showModal();
245
+ unlockScroll ??= lockPageScroll();
246
+ } else if (!props.open && dialog.open) dialog.close();
214
247
  };
215
248
  onMounted(() => {
216
249
  mounted.value = true;
217
250
  });
251
+ onBeforeUnmount(releaseScroll);
218
252
  watch([() => props.open, managed], sync, { flush: "post" });
219
253
  const requestClose = (event) => {
220
254
  event.preventDefault();
@@ -237,10 +271,23 @@ defineComponent({
237
271
  if (event.key === "Escape" && !event.defaultPrevented) requestClose(event);
238
272
  },
239
273
  onCancel: requestClose,
240
- // The browser closed it (a close request it would not let be cancelled) while open is still true. A close event
241
- // from moving a mounted dialog into the top layer finds it open again, and is not reported.
274
+ // A close event from moving a mounted dialog into the top layer finds it open again, and is not reported. Any other
275
+ // close releases the page; when the browser closed it (a close request it would not let be cancelled) while open is
276
+ // still true, it is reported.
242
277
  onClose: () => {
243
- if (props.open && !element.value?.open) emit("close");
278
+ if (element.value?.open) return;
279
+ releaseScroll();
280
+ if (props.open) emit("close");
281
+ },
282
+ onMousedown: (event) => {
283
+ pressedBackdrop = managed.value && event.target === event.currentTarget && outsideBox(event, event.currentTarget);
284
+ },
285
+ // s223-m02 (#2527 ruling 13b): a click on the backdrop emits close, as the close control does. A press that began
286
+ // inside the dialog (text selected and dragged out) is not a backdrop click.
287
+ onClick: (event) => {
288
+ const backdrop = pressedBackdrop && event.target === event.currentTarget && outsideBox(event, event.currentTarget);
289
+ pressedBackdrop = false;
290
+ if (backdrop) emit("close");
244
291
  }
245
292
  }, [
246
293
  h("div", { class: "oods-dialog__header" }, [