@oods/components-vue 0.17.0 → 0.19.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/README.md +2 -2
- package/dist/index.cjs +31 -22
- package/dist/index.d.cts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +32 -23
- package/dist/ported.cjs +24 -19
- package/dist/ported.d.cts +12 -0
- package/dist/ported.d.ts +12 -0
- package/dist/ported.js +26 -21
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -30,8 +30,8 @@ Generated sample screens identify their sample data. A workflow's local store is
|
|
|
30
30
|
|
|
31
31
|
## Limits
|
|
32
32
|
|
|
33
|
-
Generated apps
|
|
33
|
+
Generated apps use the OODS release that generated them. To upgrade, regenerate the app or update every OODS library listed in your app’s package.json to the same release, then reinstall. These packages are separate from the local MCP server, `@oods/foundry`.
|
|
34
34
|
|
|
35
35
|
## License
|
|
36
36
|
|
|
37
|
-
Apache License 2.0. See [LICENSE](https://cdn.jsdelivr.net/npm/@oods/components-vue@0.
|
|
37
|
+
Apache License 2.0. See [LICENSE](https://cdn.jsdelivr.net/npm/@oods/components-vue@0.19.0/LICENSE) and [NOTICE](https://cdn.jsdelivr.net/npm/@oods/components-vue@0.19.0/NOTICE). Generated output belongs to its user; installed package dependencies retain their own licenses.
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var vue = require('vue');
|
|
4
3
|
var componentContracts = require('@oods/component-contracts');
|
|
4
|
+
var vue = require('vue');
|
|
5
5
|
|
|
6
6
|
// src/primitives.ts
|
|
7
7
|
function statusIcon(name) {
|
|
@@ -63,9 +63,6 @@ function tokenTone(tone) {
|
|
|
63
63
|
if (tone === "danger") return "critical";
|
|
64
64
|
return tone;
|
|
65
65
|
}
|
|
66
|
-
function statusLabel(status) {
|
|
67
|
-
return normalizeStatus(status).split("_").filter(Boolean).map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join(" ");
|
|
68
|
-
}
|
|
69
66
|
function slotOrValue(slot, value) {
|
|
70
67
|
return slot ? slot() : value;
|
|
71
68
|
}
|
|
@@ -97,7 +94,7 @@ var Badge = vue.defineComponent({
|
|
|
97
94
|
}
|
|
98
95
|
}, [
|
|
99
96
|
props.icon || slots.icon ? vue.h("span", { class: "oods-badge__icon", "aria-hidden": "true" }, [slotOrValue(slots.icon, props.icon)]) : null,
|
|
100
|
-
vue.h("span", { class: "oods-badge__label" }, [slotOrValue(slots.default, props.content ??
|
|
97
|
+
vue.h("span", { class: "oods-badge__label" }, [slotOrValue(slots.default, props.content ?? componentContracts.enumOptionLabel(props.status ?? ""))])
|
|
101
98
|
]);
|
|
102
99
|
};
|
|
103
100
|
}
|
|
@@ -138,7 +135,7 @@ var Banner = vue.defineComponent({
|
|
|
138
135
|
}, [
|
|
139
136
|
vue.h("div", { class: "oods-banner__content" }, [
|
|
140
137
|
props.title || props.status || slots.title ? vue.h("strong", { class: "oods-banner__title" }, [
|
|
141
|
-
slotOrValue(slots.title, props.title ||
|
|
138
|
+
slotOrValue(slots.title, props.title || componentContracts.enumOptionLabel(props.status ?? ""))
|
|
142
139
|
]) : null,
|
|
143
140
|
props.detail ? vue.h("p", { class: "oods-banner__detail" }, props.detail) : null,
|
|
144
141
|
slots.default || props.content ? vue.h(slots.default ? "div" : "p", { class: "oods-banner__body" }, [slotOrValue(slots.default, props.content)]) : null,
|
|
@@ -1371,7 +1368,7 @@ var InlineLabel = vue.defineComponent({
|
|
|
1371
1368
|
});
|
|
1372
1369
|
var LabelCell = vue.defineComponent({
|
|
1373
1370
|
name: "OodsLabelCell",
|
|
1374
|
-
props: { label: String, text: String, value: String, description: String, subtitle: String, sublabel: String, supporting: String, truncate: Boolean, maxLength: [Number, String] },
|
|
1371
|
+
props: { caption: String, label: String, text: String, value: String, description: String, subtitle: String, sublabel: String, supporting: String, truncate: Boolean, maxLength: [Number, String] },
|
|
1375
1372
|
setup(props, { slots }) {
|
|
1376
1373
|
return () => {
|
|
1377
1374
|
const content = authoredContent(slots.default?.());
|
|
@@ -1381,6 +1378,7 @@ var LabelCell = vue.defineComponent({
|
|
|
1381
1378
|
"span",
|
|
1382
1379
|
{ class: "oods-label-cell", "data-oods-component": "LabelCell" },
|
|
1383
1380
|
content.length ? content : [
|
|
1381
|
+
props.caption ? vue.h("span", { "data-oods-label-cell-caption": "true" }, props.caption + " ") : null,
|
|
1384
1382
|
vue.h("span", { "data-oods-label-cell-primary": "true" }, truncateLabel(firstText(props.label, props.text, props.value) ?? "", limit)),
|
|
1385
1383
|
description ? vue.h("span", { "data-oods-label-cell-description": "true" }, truncateLabel(description, limit)) : null
|
|
1386
1384
|
]
|
|
@@ -1580,7 +1578,10 @@ var CancellationForm = vue.defineComponent({
|
|
|
1580
1578
|
return vue.h(props.embedded ? "fieldset" : "form", { class: "oods-cancellation-form", "data-oods-component": "CancellationForm", "data-form-type": "cancellation", onSubmit: props.embedded ? void 0 : (event) => event.preventDefault() }, [
|
|
1581
1579
|
formHeader(firstText(props.title, props.label, props.heading, props.name) ?? "Cancellation Form", firstText(props.description, props.subtitle, props.hint)),
|
|
1582
1580
|
vue.h("div", { "data-form-content": "true" }, content.length ? content : [
|
|
1583
|
-
vue.h("label", { "data-form-control": "select" }, [vue.h("span", "Reason Code"), props.allowedReasons?.length === 0 ? vue.h("input", { name: "reasonCode", value: props.reasonCode ?? "" }) : vue.h("select", { name: "reasonCode", value: props.reasonCode },
|
|
1581
|
+
vue.h("label", { "data-form-control": "select" }, [vue.h("span", "Reason Code"), props.allowedReasons?.length === 0 ? vue.h("input", { name: "reasonCode", value: props.reasonCode ?? "" }) : vue.h("select", { name: "reasonCode", value: props.reasonCode ?? "" }, [
|
|
1582
|
+
!props.reasonCode ? vue.h("option", { value: "", disabled: true, selected: true }, "Choose a reason") : null,
|
|
1583
|
+
...selectOptionNodes(choices.filter((choice) => choice.value !== ""), props.reasonCode)
|
|
1584
|
+
])]),
|
|
1584
1585
|
props.codeHelp ? vue.h("p", { class: "oods-field-help" }, props.codeHelp) : null,
|
|
1585
1586
|
vue.h("label", { "data-form-control": "textarea" }, [vue.h("span", "Reason"), vue.h("textarea", { name: "reason", rows: 4, value: firstText(props.reason, props.cancellationReason) ?? "" })]),
|
|
1586
1587
|
props.reasonHelp ? vue.h("p", { class: "oods-field-help" }, props.reasonHelp) : null
|
|
@@ -2295,13 +2296,10 @@ function firstText2(record, keys) {
|
|
|
2295
2296
|
}
|
|
2296
2297
|
return void 0;
|
|
2297
2298
|
}
|
|
2298
|
-
function statusLabel2(status) {
|
|
2299
|
-
return status.split(/[_-]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1)).join(" ");
|
|
2300
|
-
}
|
|
2301
2299
|
function getPortedStatusPresentation(domain, status) {
|
|
2302
2300
|
const presentation = componentContracts.getStatusPresentation(domain.toLowerCase(), status);
|
|
2303
2301
|
return {
|
|
2304
|
-
label:
|
|
2302
|
+
label: presentation.label,
|
|
2305
2303
|
description: presentation.description,
|
|
2306
2304
|
tone: presentation.tone,
|
|
2307
2305
|
icon: componentContracts.resolveStatusIcon(presentation.iconName)
|
|
@@ -2313,7 +2311,8 @@ function formatPrice(amountCents, amount, currency) {
|
|
|
2313
2311
|
const formatted = Number.isInteger(normalizedAmount) ? String(normalizedAmount) : normalizedAmount.toFixed(2);
|
|
2314
2312
|
return currency ? `${currency.toUpperCase()} ${formatted}` : formatted;
|
|
2315
2313
|
}
|
|
2316
|
-
function normalizeTimelineEvents(raw) {
|
|
2314
|
+
function normalizeTimelineEvents(raw, labels) {
|
|
2315
|
+
const statusLabel = (state) => componentContracts.enumOptionLabel(state, labels);
|
|
2317
2316
|
if (!Array.isArray(raw)) return [];
|
|
2318
2317
|
const events = [];
|
|
2319
2318
|
for (const entry of raw) {
|
|
@@ -2322,13 +2321,15 @@ function normalizeTimelineEvents(raw) {
|
|
|
2322
2321
|
events.push({ label: String(entry) });
|
|
2323
2322
|
continue;
|
|
2324
2323
|
}
|
|
2324
|
+
const event = firstText2(entry, ["event"]);
|
|
2325
|
+
const state = firstText2(entry, ["status", "state"]);
|
|
2325
2326
|
const from = firstText2(entry, ["from"]);
|
|
2326
2327
|
const to = firstText2(entry, ["to"]);
|
|
2327
2328
|
const attribution = componentContracts.historyAttribution(entry);
|
|
2328
2329
|
events.push({
|
|
2329
|
-
label: firstText2(entry, ["label", "title"]) ?? (
|
|
2330
|
+
label: firstText2(entry, ["label", "title"]) ?? (event ? componentContracts.formatReadOnlyValue(event, "string", true) : void 0) ?? (state ? statusLabel(state) : void 0) ?? firstText2(entry, ["text", "name"]) ?? (to ? from ? `${statusLabel(from)} \u2192 ${statusLabel(to)}` : statusLabel(to) : void 0) ?? "Event",
|
|
2330
2331
|
timestamp: firstText2(entry, ["timestamp", "datetime", "time", "at", "createdAt", "updatedAt"]),
|
|
2331
|
-
detail: firstText2(entry, ["detail", "description", "message"]) ?? (to ? from ? `${
|
|
2332
|
+
detail: firstText2(entry, ["detail", "description", "message"]) ?? (to ? from ? `${statusLabel(from)} \u2192 ${statusLabel(to)}` : statusLabel(to) : void 0),
|
|
2332
2333
|
actorId: attribution?.namesActor ? void 0 : firstText2(entry, ["actorId", "actor_id", "actor"]),
|
|
2333
2334
|
...attribution ? { attribution: attribution.text } : {},
|
|
2334
2335
|
reason: firstText2(entry, ["reason"])
|
|
@@ -2442,7 +2443,10 @@ var StatusBadge = vue.defineComponent({
|
|
|
2442
2443
|
const status = props.status ?? props.value ?? "unknown";
|
|
2443
2444
|
const presentation = getPortedStatusPresentation(props.domain, status);
|
|
2444
2445
|
const tone = props.tone === "lifecycle" ? presentation.tone : props.tone ?? presentation.tone;
|
|
2445
|
-
const
|
|
2446
|
+
const children = slots.default?.();
|
|
2447
|
+
const slotLabel = children?.length && children.every((node) => node.type === vue.Text) ? children.map((node) => node.children).join("") : void 0;
|
|
2448
|
+
const badgeSlots = children ? { ...slots, default: () => children } : slots;
|
|
2449
|
+
const ariaLabel = stringValue(attrs["aria-label"]) ?? props.label ?? `Status: ${slotLabel ?? props.content ?? presentation.label}`;
|
|
2446
2450
|
return vue.h(Badge, {
|
|
2447
2451
|
...attrs,
|
|
2448
2452
|
class: mergedClass("oods-status-badge", attrs.class),
|
|
@@ -2454,7 +2458,7 @@ var StatusBadge = vue.defineComponent({
|
|
|
2454
2458
|
title: stringValue(attrs.title) ?? presentation.description,
|
|
2455
2459
|
"aria-label": ariaLabel,
|
|
2456
2460
|
"data-oods-component": "StatusBadge"
|
|
2457
|
-
}, props.showIcon && presentation.icon && !slots.icon ? { ...
|
|
2461
|
+
}, props.showIcon && presentation.icon && !slots.icon ? { ...badgeSlots, icon: () => statusIcon(presentation.icon) } : badgeSlots);
|
|
2458
2462
|
};
|
|
2459
2463
|
}
|
|
2460
2464
|
});
|
|
@@ -2511,6 +2515,7 @@ var PriceBadge = vue.defineComponent({
|
|
|
2511
2515
|
};
|
|
2512
2516
|
}
|
|
2513
2517
|
});
|
|
2518
|
+
var statusLabelProps = { enumLabels: Object };
|
|
2514
2519
|
var timelineProps = {
|
|
2515
2520
|
title: String,
|
|
2516
2521
|
source: Array,
|
|
@@ -2551,11 +2556,14 @@ function timelineComponent(configuration) {
|
|
|
2551
2556
|
return vue.defineComponent({
|
|
2552
2557
|
name: `Oods${configuration.componentId}`,
|
|
2553
2558
|
inheritAttrs: false,
|
|
2554
|
-
props:
|
|
2559
|
+
props: {
|
|
2560
|
+
...timelineProps,
|
|
2561
|
+
...configuration.componentId === "StatusTimeline" ? statusLabelProps : {}
|
|
2562
|
+
},
|
|
2555
2563
|
setup(props, { attrs, slots }) {
|
|
2556
2564
|
return () => {
|
|
2557
2565
|
const rawEvents = configuration.componentId === "StatusTimeline" ? firstArray(props.source, props.events, props.history, props.entries, props.stateHistory) : firstArray(props.source, props.events, props.history, props.entries, props.auditLog);
|
|
2558
|
-
const normalized = normalizeTimelineEvents(rawEvents);
|
|
2566
|
+
const normalized = normalizeTimelineEvents(rawEvents, props.enumLabels);
|
|
2559
2567
|
const events = props.maxVisible === void 0 ? normalized : normalized.slice(0, Math.max(0, Math.floor(props.maxVisible)));
|
|
2560
2568
|
const title = props.title ?? configuration.defaultTitle;
|
|
2561
2569
|
const slottedEvents = slots.default?.();
|
|
@@ -2568,8 +2576,8 @@ function timelineComponent(configuration) {
|
|
|
2568
2576
|
"data-timeline-type": configuration.timelineType
|
|
2569
2577
|
}, [
|
|
2570
2578
|
vue.h("h2", { class: "oods-timeline__title", "data-timeline-title": "true" }, title),
|
|
2571
|
-
props.status ? vue.h("p", { class: "oods-timeline__current", "data-timeline-current": "true" }, `Current status: ${
|
|
2572
|
-
props.allowedTransitions?.length ? vue.h("p", { "data-timeline-transitions": "true" }, `Allowed transitions: ${props.allowedTransitions.join(", ")}`) : null,
|
|
2579
|
+
props.status ? vue.h("p", { class: "oods-timeline__current", "data-timeline-current": "true" }, `Current status: ${componentContracts.enumOptionLabel(props.status, props.enumLabels)}`) : null,
|
|
2580
|
+
props.allowedTransitions?.length ? vue.h("p", { "data-timeline-transitions": "true" }, `Allowed transitions: ${props.allowedTransitions.map((value) => componentContracts.enumOptionLabel(value, props.enumLabels)).join(", ")}`) : null,
|
|
2573
2581
|
vue.h("ol", { class: "oods-timeline__events", "data-timeline-events": "true" }, slottedEvents?.length ? slottedEvents : events.length ? events.map((event, index) => renderTimelineEvent(
|
|
2574
2582
|
event,
|
|
2575
2583
|
index,
|
|
@@ -2902,6 +2910,7 @@ var RelativeTimestamp = vue.defineComponent({
|
|
|
2902
2910
|
label: String,
|
|
2903
2911
|
text: String,
|
|
2904
2912
|
timezone: String,
|
|
2913
|
+
caption: String,
|
|
2905
2914
|
hideWhenEmpty: Boolean,
|
|
2906
2915
|
now: [String, Number, Date],
|
|
2907
2916
|
field: String,
|
|
@@ -2931,7 +2940,7 @@ var RelativeTimestamp = vue.defineComponent({
|
|
|
2931
2940
|
datetime: datetime || void 0,
|
|
2932
2941
|
title: stringValue(attrs.title) ?? absolute,
|
|
2933
2942
|
"data-oods-component": "RelativeTimestamp"
|
|
2934
|
-
}, content);
|
|
2943
|
+
}, props.caption ? `${props.caption}: ${content}` : content);
|
|
2935
2944
|
};
|
|
2936
2945
|
}
|
|
2937
2946
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -299,6 +299,7 @@ type InlineLabelProps = {
|
|
|
299
299
|
maxLength?: number | string;
|
|
300
300
|
};
|
|
301
301
|
type LabelCellProps = InlineLabelProps & {
|
|
302
|
+
caption?: string;
|
|
302
303
|
description?: string;
|
|
303
304
|
subtitle?: string;
|
|
304
305
|
sublabel?: string;
|
|
@@ -1477,6 +1478,7 @@ declare const InlineLabel: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
1477
1478
|
maxLength: (StringConstructor | NumberConstructor)[];
|
|
1478
1479
|
}>> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
1479
1480
|
declare const LabelCell: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
1481
|
+
caption: StringConstructor;
|
|
1480
1482
|
label: StringConstructor;
|
|
1481
1483
|
text: StringConstructor;
|
|
1482
1484
|
value: StringConstructor;
|
|
@@ -1489,6 +1491,7 @@ declare const LabelCell: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
1489
1491
|
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
1490
1492
|
[key: string]: any;
|
|
1491
1493
|
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
1494
|
+
caption: StringConstructor;
|
|
1492
1495
|
label: StringConstructor;
|
|
1493
1496
|
text: StringConstructor;
|
|
1494
1497
|
value: StringConstructor;
|
|
@@ -2401,6 +2404,7 @@ type TimelineProps = {
|
|
|
2401
2404
|
stateHistory?: readonly unknown[];
|
|
2402
2405
|
auditLog?: readonly unknown[];
|
|
2403
2406
|
status?: string;
|
|
2407
|
+
enumLabels?: Record<string, string>;
|
|
2404
2408
|
allowedTransitions?: readonly string[];
|
|
2405
2409
|
showActorId?: boolean;
|
|
2406
2410
|
showReason?: boolean;
|
|
@@ -2475,6 +2479,7 @@ type RelativeTimestampProps = {
|
|
|
2475
2479
|
label?: string;
|
|
2476
2480
|
text?: string;
|
|
2477
2481
|
timezone?: string;
|
|
2482
|
+
caption?: string;
|
|
2478
2483
|
hideWhenEmpty?: boolean;
|
|
2479
2484
|
now?: string | number | Date;
|
|
2480
2485
|
field?: string;
|
|
@@ -2617,6 +2622,8 @@ declare const StatusTimeline: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
2617
2622
|
readonly eventTimestampField: StringConstructor;
|
|
2618
2623
|
readonly eventOptionsParameter: StringConstructor;
|
|
2619
2624
|
readonly showFromState: BooleanConstructor;
|
|
2625
|
+
} & {
|
|
2626
|
+
enumLabels: PropType<Record<string, string>>;
|
|
2620
2627
|
}>, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
2621
2628
|
[key: string]: any;
|
|
2622
2629
|
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
@@ -2648,6 +2655,8 @@ declare const StatusTimeline: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
2648
2655
|
readonly eventTimestampField: StringConstructor;
|
|
2649
2656
|
readonly eventOptionsParameter: StringConstructor;
|
|
2650
2657
|
readonly showFromState: BooleanConstructor;
|
|
2658
|
+
} & {
|
|
2659
|
+
enumLabels: PropType<Record<string, string>>;
|
|
2651
2660
|
}>> & Readonly<{}>, {
|
|
2652
2661
|
readonly showActorId: boolean;
|
|
2653
2662
|
readonly showReason: boolean;
|
|
@@ -2682,6 +2691,8 @@ declare const AuditTimeline: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
2682
2691
|
readonly eventTimestampField: StringConstructor;
|
|
2683
2692
|
readonly eventOptionsParameter: StringConstructor;
|
|
2684
2693
|
readonly showFromState: BooleanConstructor;
|
|
2694
|
+
} & {
|
|
2695
|
+
enumLabels: PropType<Record<string, string>>;
|
|
2685
2696
|
}>, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
2686
2697
|
[key: string]: any;
|
|
2687
2698
|
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
@@ -2713,6 +2724,8 @@ declare const AuditTimeline: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
2713
2724
|
readonly eventTimestampField: StringConstructor;
|
|
2714
2725
|
readonly eventOptionsParameter: StringConstructor;
|
|
2715
2726
|
readonly showFromState: BooleanConstructor;
|
|
2727
|
+
} & {
|
|
2728
|
+
enumLabels: PropType<Record<string, string>>;
|
|
2716
2729
|
}>> & Readonly<{}>, {
|
|
2717
2730
|
readonly showActorId: boolean;
|
|
2718
2731
|
readonly showReason: boolean;
|
|
@@ -2947,6 +2960,7 @@ declare const RelativeTimestamp: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
2947
2960
|
label: StringConstructor;
|
|
2948
2961
|
text: StringConstructor;
|
|
2949
2962
|
timezone: StringConstructor;
|
|
2963
|
+
caption: StringConstructor;
|
|
2950
2964
|
hideWhenEmpty: BooleanConstructor;
|
|
2951
2965
|
now: PropType<string | number | Date>;
|
|
2952
2966
|
field: StringConstructor;
|
|
@@ -2964,6 +2978,7 @@ declare const RelativeTimestamp: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
2964
2978
|
label: StringConstructor;
|
|
2965
2979
|
text: StringConstructor;
|
|
2966
2980
|
timezone: StringConstructor;
|
|
2981
|
+
caption: StringConstructor;
|
|
2967
2982
|
hideWhenEmpty: BooleanConstructor;
|
|
2968
2983
|
now: PropType<string | number | Date>;
|
|
2969
2984
|
field: StringConstructor;
|
package/dist/index.d.ts
CHANGED
|
@@ -299,6 +299,7 @@ type InlineLabelProps = {
|
|
|
299
299
|
maxLength?: number | string;
|
|
300
300
|
};
|
|
301
301
|
type LabelCellProps = InlineLabelProps & {
|
|
302
|
+
caption?: string;
|
|
302
303
|
description?: string;
|
|
303
304
|
subtitle?: string;
|
|
304
305
|
sublabel?: string;
|
|
@@ -1477,6 +1478,7 @@ declare const InlineLabel: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
1477
1478
|
maxLength: (StringConstructor | NumberConstructor)[];
|
|
1478
1479
|
}>> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
1479
1480
|
declare const LabelCell: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
1481
|
+
caption: StringConstructor;
|
|
1480
1482
|
label: StringConstructor;
|
|
1481
1483
|
text: StringConstructor;
|
|
1482
1484
|
value: StringConstructor;
|
|
@@ -1489,6 +1491,7 @@ declare const LabelCell: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
1489
1491
|
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
1490
1492
|
[key: string]: any;
|
|
1491
1493
|
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
1494
|
+
caption: StringConstructor;
|
|
1492
1495
|
label: StringConstructor;
|
|
1493
1496
|
text: StringConstructor;
|
|
1494
1497
|
value: StringConstructor;
|
|
@@ -2401,6 +2404,7 @@ type TimelineProps = {
|
|
|
2401
2404
|
stateHistory?: readonly unknown[];
|
|
2402
2405
|
auditLog?: readonly unknown[];
|
|
2403
2406
|
status?: string;
|
|
2407
|
+
enumLabels?: Record<string, string>;
|
|
2404
2408
|
allowedTransitions?: readonly string[];
|
|
2405
2409
|
showActorId?: boolean;
|
|
2406
2410
|
showReason?: boolean;
|
|
@@ -2475,6 +2479,7 @@ type RelativeTimestampProps = {
|
|
|
2475
2479
|
label?: string;
|
|
2476
2480
|
text?: string;
|
|
2477
2481
|
timezone?: string;
|
|
2482
|
+
caption?: string;
|
|
2478
2483
|
hideWhenEmpty?: boolean;
|
|
2479
2484
|
now?: string | number | Date;
|
|
2480
2485
|
field?: string;
|
|
@@ -2617,6 +2622,8 @@ declare const StatusTimeline: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
2617
2622
|
readonly eventTimestampField: StringConstructor;
|
|
2618
2623
|
readonly eventOptionsParameter: StringConstructor;
|
|
2619
2624
|
readonly showFromState: BooleanConstructor;
|
|
2625
|
+
} & {
|
|
2626
|
+
enumLabels: PropType<Record<string, string>>;
|
|
2620
2627
|
}>, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
2621
2628
|
[key: string]: any;
|
|
2622
2629
|
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
@@ -2648,6 +2655,8 @@ declare const StatusTimeline: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
2648
2655
|
readonly eventTimestampField: StringConstructor;
|
|
2649
2656
|
readonly eventOptionsParameter: StringConstructor;
|
|
2650
2657
|
readonly showFromState: BooleanConstructor;
|
|
2658
|
+
} & {
|
|
2659
|
+
enumLabels: PropType<Record<string, string>>;
|
|
2651
2660
|
}>> & Readonly<{}>, {
|
|
2652
2661
|
readonly showActorId: boolean;
|
|
2653
2662
|
readonly showReason: boolean;
|
|
@@ -2682,6 +2691,8 @@ declare const AuditTimeline: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
2682
2691
|
readonly eventTimestampField: StringConstructor;
|
|
2683
2692
|
readonly eventOptionsParameter: StringConstructor;
|
|
2684
2693
|
readonly showFromState: BooleanConstructor;
|
|
2694
|
+
} & {
|
|
2695
|
+
enumLabels: PropType<Record<string, string>>;
|
|
2685
2696
|
}>, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
2686
2697
|
[key: string]: any;
|
|
2687
2698
|
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
@@ -2713,6 +2724,8 @@ declare const AuditTimeline: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
2713
2724
|
readonly eventTimestampField: StringConstructor;
|
|
2714
2725
|
readonly eventOptionsParameter: StringConstructor;
|
|
2715
2726
|
readonly showFromState: BooleanConstructor;
|
|
2727
|
+
} & {
|
|
2728
|
+
enumLabels: PropType<Record<string, string>>;
|
|
2716
2729
|
}>> & Readonly<{}>, {
|
|
2717
2730
|
readonly showActorId: boolean;
|
|
2718
2731
|
readonly showReason: boolean;
|
|
@@ -2947,6 +2960,7 @@ declare const RelativeTimestamp: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
2947
2960
|
label: StringConstructor;
|
|
2948
2961
|
text: StringConstructor;
|
|
2949
2962
|
timezone: StringConstructor;
|
|
2963
|
+
caption: StringConstructor;
|
|
2950
2964
|
hideWhenEmpty: BooleanConstructor;
|
|
2951
2965
|
now: PropType<string | number | Date>;
|
|
2952
2966
|
field: StringConstructor;
|
|
@@ -2964,6 +2978,7 @@ declare const RelativeTimestamp: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
2964
2978
|
label: StringConstructor;
|
|
2965
2979
|
text: StringConstructor;
|
|
2966
2980
|
timezone: StringConstructor;
|
|
2981
|
+
caption: StringConstructor;
|
|
2967
2982
|
hideWhenEmpty: BooleanConstructor;
|
|
2968
2983
|
now: PropType<string | number | Date>;
|
|
2969
2984
|
field: StringConstructor;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { enumOptionLabel, svgCarriesTitle, vizPreviewLayers, formatPriceAmount, formatPriceCode, formatReferenceLabel, ownerKindLabel, 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, VIZ_CONTROL_TITLES, vizControlFields, vizFieldValue, vizSummaryRows, historyAttribution, editVizIntent } from '@oods/component-contracts';
|
|
2
|
+
import { defineComponent, h, useId, computed, ref, onMounted, onBeforeUnmount, watch, nextTick, Text as Text$1, isVNode, Comment, Fragment } from 'vue';
|
|
3
3
|
|
|
4
4
|
// src/primitives.ts
|
|
5
5
|
function statusIcon(name) {
|
|
@@ -61,9 +61,6 @@ function tokenTone(tone) {
|
|
|
61
61
|
if (tone === "danger") return "critical";
|
|
62
62
|
return tone;
|
|
63
63
|
}
|
|
64
|
-
function statusLabel(status) {
|
|
65
|
-
return normalizeStatus(status).split("_").filter(Boolean).map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join(" ");
|
|
66
|
-
}
|
|
67
64
|
function slotOrValue(slot, value) {
|
|
68
65
|
return slot ? slot() : value;
|
|
69
66
|
}
|
|
@@ -95,7 +92,7 @@ var Badge = defineComponent({
|
|
|
95
92
|
}
|
|
96
93
|
}, [
|
|
97
94
|
props.icon || slots.icon ? h("span", { class: "oods-badge__icon", "aria-hidden": "true" }, [slotOrValue(slots.icon, props.icon)]) : null,
|
|
98
|
-
h("span", { class: "oods-badge__label" }, [slotOrValue(slots.default, props.content ??
|
|
95
|
+
h("span", { class: "oods-badge__label" }, [slotOrValue(slots.default, props.content ?? enumOptionLabel(props.status ?? ""))])
|
|
99
96
|
]);
|
|
100
97
|
};
|
|
101
98
|
}
|
|
@@ -136,7 +133,7 @@ var Banner = defineComponent({
|
|
|
136
133
|
}, [
|
|
137
134
|
h("div", { class: "oods-banner__content" }, [
|
|
138
135
|
props.title || props.status || slots.title ? h("strong", { class: "oods-banner__title" }, [
|
|
139
|
-
slotOrValue(slots.title, props.title ||
|
|
136
|
+
slotOrValue(slots.title, props.title || enumOptionLabel(props.status ?? ""))
|
|
140
137
|
]) : null,
|
|
141
138
|
props.detail ? h("p", { class: "oods-banner__detail" }, props.detail) : null,
|
|
142
139
|
slots.default || props.content ? h(slots.default ? "div" : "p", { class: "oods-banner__body" }, [slotOrValue(slots.default, props.content)]) : null,
|
|
@@ -1369,7 +1366,7 @@ var InlineLabel = defineComponent({
|
|
|
1369
1366
|
});
|
|
1370
1367
|
var LabelCell = defineComponent({
|
|
1371
1368
|
name: "OodsLabelCell",
|
|
1372
|
-
props: { label: String, text: String, value: String, description: String, subtitle: String, sublabel: String, supporting: String, truncate: Boolean, maxLength: [Number, String] },
|
|
1369
|
+
props: { caption: String, label: String, text: String, value: String, description: String, subtitle: String, sublabel: String, supporting: String, truncate: Boolean, maxLength: [Number, String] },
|
|
1373
1370
|
setup(props, { slots }) {
|
|
1374
1371
|
return () => {
|
|
1375
1372
|
const content = authoredContent(slots.default?.());
|
|
@@ -1379,6 +1376,7 @@ var LabelCell = defineComponent({
|
|
|
1379
1376
|
"span",
|
|
1380
1377
|
{ class: "oods-label-cell", "data-oods-component": "LabelCell" },
|
|
1381
1378
|
content.length ? content : [
|
|
1379
|
+
props.caption ? h("span", { "data-oods-label-cell-caption": "true" }, props.caption + " ") : null,
|
|
1382
1380
|
h("span", { "data-oods-label-cell-primary": "true" }, truncateLabel(firstText(props.label, props.text, props.value) ?? "", limit)),
|
|
1383
1381
|
description ? h("span", { "data-oods-label-cell-description": "true" }, truncateLabel(description, limit)) : null
|
|
1384
1382
|
]
|
|
@@ -1578,7 +1576,10 @@ var CancellationForm = defineComponent({
|
|
|
1578
1576
|
return h(props.embedded ? "fieldset" : "form", { class: "oods-cancellation-form", "data-oods-component": "CancellationForm", "data-form-type": "cancellation", onSubmit: props.embedded ? void 0 : (event) => event.preventDefault() }, [
|
|
1579
1577
|
formHeader(firstText(props.title, props.label, props.heading, props.name) ?? "Cancellation Form", firstText(props.description, props.subtitle, props.hint)),
|
|
1580
1578
|
h("div", { "data-form-content": "true" }, content.length ? content : [
|
|
1581
|
-
h("label", { "data-form-control": "select" }, [h("span", "Reason Code"), props.allowedReasons?.length === 0 ? h("input", { name: "reasonCode", value: props.reasonCode ?? "" }) : h("select", { name: "reasonCode", value: props.reasonCode },
|
|
1579
|
+
h("label", { "data-form-control": "select" }, [h("span", "Reason Code"), props.allowedReasons?.length === 0 ? h("input", { name: "reasonCode", value: props.reasonCode ?? "" }) : h("select", { name: "reasonCode", value: props.reasonCode ?? "" }, [
|
|
1580
|
+
!props.reasonCode ? h("option", { value: "", disabled: true, selected: true }, "Choose a reason") : null,
|
|
1581
|
+
...selectOptionNodes(choices.filter((choice) => choice.value !== ""), props.reasonCode)
|
|
1582
|
+
])]),
|
|
1582
1583
|
props.codeHelp ? h("p", { class: "oods-field-help" }, props.codeHelp) : null,
|
|
1583
1584
|
h("label", { "data-form-control": "textarea" }, [h("span", "Reason"), h("textarea", { name: "reason", rows: 4, value: firstText(props.reason, props.cancellationReason) ?? "" })]),
|
|
1584
1585
|
props.reasonHelp ? h("p", { class: "oods-field-help" }, props.reasonHelp) : null
|
|
@@ -2293,13 +2294,10 @@ function firstText2(record, keys) {
|
|
|
2293
2294
|
}
|
|
2294
2295
|
return void 0;
|
|
2295
2296
|
}
|
|
2296
|
-
function statusLabel2(status) {
|
|
2297
|
-
return status.split(/[_-]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1)).join(" ");
|
|
2298
|
-
}
|
|
2299
2297
|
function getPortedStatusPresentation(domain, status) {
|
|
2300
2298
|
const presentation = getStatusPresentation(domain.toLowerCase(), status);
|
|
2301
2299
|
return {
|
|
2302
|
-
label:
|
|
2300
|
+
label: presentation.label,
|
|
2303
2301
|
description: presentation.description,
|
|
2304
2302
|
tone: presentation.tone,
|
|
2305
2303
|
icon: resolveStatusIcon(presentation.iconName)
|
|
@@ -2311,7 +2309,8 @@ function formatPrice(amountCents, amount, currency) {
|
|
|
2311
2309
|
const formatted = Number.isInteger(normalizedAmount) ? String(normalizedAmount) : normalizedAmount.toFixed(2);
|
|
2312
2310
|
return currency ? `${currency.toUpperCase()} ${formatted}` : formatted;
|
|
2313
2311
|
}
|
|
2314
|
-
function normalizeTimelineEvents(raw) {
|
|
2312
|
+
function normalizeTimelineEvents(raw, labels) {
|
|
2313
|
+
const statusLabel = (state) => enumOptionLabel(state, labels);
|
|
2315
2314
|
if (!Array.isArray(raw)) return [];
|
|
2316
2315
|
const events = [];
|
|
2317
2316
|
for (const entry of raw) {
|
|
@@ -2320,13 +2319,15 @@ function normalizeTimelineEvents(raw) {
|
|
|
2320
2319
|
events.push({ label: String(entry) });
|
|
2321
2320
|
continue;
|
|
2322
2321
|
}
|
|
2322
|
+
const event = firstText2(entry, ["event"]);
|
|
2323
|
+
const state = firstText2(entry, ["status", "state"]);
|
|
2323
2324
|
const from = firstText2(entry, ["from"]);
|
|
2324
2325
|
const to = firstText2(entry, ["to"]);
|
|
2325
2326
|
const attribution = historyAttribution(entry);
|
|
2326
2327
|
events.push({
|
|
2327
|
-
label: firstText2(entry, ["label", "title"]) ?? (
|
|
2328
|
+
label: firstText2(entry, ["label", "title"]) ?? (event ? formatReadOnlyValue(event, "string", true) : void 0) ?? (state ? statusLabel(state) : void 0) ?? firstText2(entry, ["text", "name"]) ?? (to ? from ? `${statusLabel(from)} \u2192 ${statusLabel(to)}` : statusLabel(to) : void 0) ?? "Event",
|
|
2328
2329
|
timestamp: firstText2(entry, ["timestamp", "datetime", "time", "at", "createdAt", "updatedAt"]),
|
|
2329
|
-
detail: firstText2(entry, ["detail", "description", "message"]) ?? (to ? from ? `${
|
|
2330
|
+
detail: firstText2(entry, ["detail", "description", "message"]) ?? (to ? from ? `${statusLabel(from)} \u2192 ${statusLabel(to)}` : statusLabel(to) : void 0),
|
|
2330
2331
|
actorId: attribution?.namesActor ? void 0 : firstText2(entry, ["actorId", "actor_id", "actor"]),
|
|
2331
2332
|
...attribution ? { attribution: attribution.text } : {},
|
|
2332
2333
|
reason: firstText2(entry, ["reason"])
|
|
@@ -2440,7 +2441,10 @@ var StatusBadge = defineComponent({
|
|
|
2440
2441
|
const status = props.status ?? props.value ?? "unknown";
|
|
2441
2442
|
const presentation = getPortedStatusPresentation(props.domain, status);
|
|
2442
2443
|
const tone = props.tone === "lifecycle" ? presentation.tone : props.tone ?? presentation.tone;
|
|
2443
|
-
const
|
|
2444
|
+
const children = slots.default?.();
|
|
2445
|
+
const slotLabel = children?.length && children.every((node) => node.type === Text$1) ? children.map((node) => node.children).join("") : void 0;
|
|
2446
|
+
const badgeSlots = children ? { ...slots, default: () => children } : slots;
|
|
2447
|
+
const ariaLabel = stringValue(attrs["aria-label"]) ?? props.label ?? `Status: ${slotLabel ?? props.content ?? presentation.label}`;
|
|
2444
2448
|
return h(Badge, {
|
|
2445
2449
|
...attrs,
|
|
2446
2450
|
class: mergedClass("oods-status-badge", attrs.class),
|
|
@@ -2452,7 +2456,7 @@ var StatusBadge = defineComponent({
|
|
|
2452
2456
|
title: stringValue(attrs.title) ?? presentation.description,
|
|
2453
2457
|
"aria-label": ariaLabel,
|
|
2454
2458
|
"data-oods-component": "StatusBadge"
|
|
2455
|
-
}, props.showIcon && presentation.icon && !slots.icon ? { ...
|
|
2459
|
+
}, props.showIcon && presentation.icon && !slots.icon ? { ...badgeSlots, icon: () => statusIcon(presentation.icon) } : badgeSlots);
|
|
2456
2460
|
};
|
|
2457
2461
|
}
|
|
2458
2462
|
});
|
|
@@ -2509,6 +2513,7 @@ var PriceBadge = defineComponent({
|
|
|
2509
2513
|
};
|
|
2510
2514
|
}
|
|
2511
2515
|
});
|
|
2516
|
+
var statusLabelProps = { enumLabels: Object };
|
|
2512
2517
|
var timelineProps = {
|
|
2513
2518
|
title: String,
|
|
2514
2519
|
source: Array,
|
|
@@ -2549,11 +2554,14 @@ function timelineComponent(configuration) {
|
|
|
2549
2554
|
return defineComponent({
|
|
2550
2555
|
name: `Oods${configuration.componentId}`,
|
|
2551
2556
|
inheritAttrs: false,
|
|
2552
|
-
props:
|
|
2557
|
+
props: {
|
|
2558
|
+
...timelineProps,
|
|
2559
|
+
...configuration.componentId === "StatusTimeline" ? statusLabelProps : {}
|
|
2560
|
+
},
|
|
2553
2561
|
setup(props, { attrs, slots }) {
|
|
2554
2562
|
return () => {
|
|
2555
2563
|
const rawEvents = configuration.componentId === "StatusTimeline" ? firstArray(props.source, props.events, props.history, props.entries, props.stateHistory) : firstArray(props.source, props.events, props.history, props.entries, props.auditLog);
|
|
2556
|
-
const normalized = normalizeTimelineEvents(rawEvents);
|
|
2564
|
+
const normalized = normalizeTimelineEvents(rawEvents, props.enumLabels);
|
|
2557
2565
|
const events = props.maxVisible === void 0 ? normalized : normalized.slice(0, Math.max(0, Math.floor(props.maxVisible)));
|
|
2558
2566
|
const title = props.title ?? configuration.defaultTitle;
|
|
2559
2567
|
const slottedEvents = slots.default?.();
|
|
@@ -2566,8 +2574,8 @@ function timelineComponent(configuration) {
|
|
|
2566
2574
|
"data-timeline-type": configuration.timelineType
|
|
2567
2575
|
}, [
|
|
2568
2576
|
h("h2", { class: "oods-timeline__title", "data-timeline-title": "true" }, title),
|
|
2569
|
-
props.status ? h("p", { class: "oods-timeline__current", "data-timeline-current": "true" }, `Current status: ${
|
|
2570
|
-
props.allowedTransitions?.length ? h("p", { "data-timeline-transitions": "true" }, `Allowed transitions: ${props.allowedTransitions.join(", ")}`) : null,
|
|
2577
|
+
props.status ? h("p", { class: "oods-timeline__current", "data-timeline-current": "true" }, `Current status: ${enumOptionLabel(props.status, props.enumLabels)}`) : null,
|
|
2578
|
+
props.allowedTransitions?.length ? h("p", { "data-timeline-transitions": "true" }, `Allowed transitions: ${props.allowedTransitions.map((value) => enumOptionLabel(value, props.enumLabels)).join(", ")}`) : null,
|
|
2571
2579
|
h("ol", { class: "oods-timeline__events", "data-timeline-events": "true" }, slottedEvents?.length ? slottedEvents : events.length ? events.map((event, index) => renderTimelineEvent(
|
|
2572
2580
|
event,
|
|
2573
2581
|
index,
|
|
@@ -2900,6 +2908,7 @@ var RelativeTimestamp = defineComponent({
|
|
|
2900
2908
|
label: String,
|
|
2901
2909
|
text: String,
|
|
2902
2910
|
timezone: String,
|
|
2911
|
+
caption: String,
|
|
2903
2912
|
hideWhenEmpty: Boolean,
|
|
2904
2913
|
now: [String, Number, Date],
|
|
2905
2914
|
field: String,
|
|
@@ -2929,7 +2938,7 @@ var RelativeTimestamp = defineComponent({
|
|
|
2929
2938
|
datetime: datetime || void 0,
|
|
2930
2939
|
title: stringValue(attrs.title) ?? absolute,
|
|
2931
2940
|
"data-oods-component": "RelativeTimestamp"
|
|
2932
|
-
}, content);
|
|
2941
|
+
}, props.caption ? `${props.caption}: ${content}` : content);
|
|
2933
2942
|
};
|
|
2934
2943
|
}
|
|
2935
2944
|
});
|
package/dist/ported.cjs
CHANGED
|
@@ -63,9 +63,6 @@ function tokenTone(tone) {
|
|
|
63
63
|
if (tone === "danger") return "critical";
|
|
64
64
|
return tone;
|
|
65
65
|
}
|
|
66
|
-
function statusLabel(status) {
|
|
67
|
-
return normalizeStatus(status).split("_").filter(Boolean).map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join(" ");
|
|
68
|
-
}
|
|
69
66
|
function slotOrValue(slot, value) {
|
|
70
67
|
return slot ? slot() : value;
|
|
71
68
|
}
|
|
@@ -97,7 +94,7 @@ var Badge = vue.defineComponent({
|
|
|
97
94
|
}
|
|
98
95
|
}, [
|
|
99
96
|
props.icon || slots.icon ? vue.h("span", { class: "oods-badge__icon", "aria-hidden": "true" }, [slotOrValue(slots.icon, props.icon)]) : null,
|
|
100
|
-
vue.h("span", { class: "oods-badge__label" }, [slotOrValue(slots.default, props.content ??
|
|
97
|
+
vue.h("span", { class: "oods-badge__label" }, [slotOrValue(slots.default, props.content ?? componentContracts.enumOptionLabel(props.status ?? ""))])
|
|
101
98
|
]);
|
|
102
99
|
};
|
|
103
100
|
}
|
|
@@ -138,7 +135,7 @@ vue.defineComponent({
|
|
|
138
135
|
}, [
|
|
139
136
|
vue.h("div", { class: "oods-banner__content" }, [
|
|
140
137
|
props.title || props.status || slots.title ? vue.h("strong", { class: "oods-banner__title" }, [
|
|
141
|
-
slotOrValue(slots.title, props.title ||
|
|
138
|
+
slotOrValue(slots.title, props.title || componentContracts.enumOptionLabel(props.status ?? ""))
|
|
142
139
|
]) : null,
|
|
143
140
|
props.detail ? vue.h("p", { class: "oods-banner__detail" }, props.detail) : null,
|
|
144
141
|
slots.default || props.content ? vue.h(slots.default ? "div" : "p", { class: "oods-banner__body" }, [slotOrValue(slots.default, props.content)]) : null,
|
|
@@ -786,13 +783,10 @@ function firstText(record, keys) {
|
|
|
786
783
|
}
|
|
787
784
|
return void 0;
|
|
788
785
|
}
|
|
789
|
-
function statusLabel2(status) {
|
|
790
|
-
return status.split(/[_-]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1)).join(" ");
|
|
791
|
-
}
|
|
792
786
|
function getPortedStatusPresentation(domain, status) {
|
|
793
787
|
const presentation = componentContracts.getStatusPresentation(domain.toLowerCase(), status);
|
|
794
788
|
return {
|
|
795
|
-
label:
|
|
789
|
+
label: presentation.label,
|
|
796
790
|
description: presentation.description,
|
|
797
791
|
tone: presentation.tone,
|
|
798
792
|
icon: componentContracts.resolveStatusIcon(presentation.iconName)
|
|
@@ -804,7 +798,8 @@ function formatPrice(amountCents, amount, currency) {
|
|
|
804
798
|
const formatted = Number.isInteger(normalizedAmount) ? String(normalizedAmount) : normalizedAmount.toFixed(2);
|
|
805
799
|
return currency ? `${currency.toUpperCase()} ${formatted}` : formatted;
|
|
806
800
|
}
|
|
807
|
-
function normalizeTimelineEvents(raw) {
|
|
801
|
+
function normalizeTimelineEvents(raw, labels) {
|
|
802
|
+
const statusLabel = (state) => componentContracts.enumOptionLabel(state, labels);
|
|
808
803
|
if (!Array.isArray(raw)) return [];
|
|
809
804
|
const events = [];
|
|
810
805
|
for (const entry of raw) {
|
|
@@ -813,13 +808,15 @@ function normalizeTimelineEvents(raw) {
|
|
|
813
808
|
events.push({ label: String(entry) });
|
|
814
809
|
continue;
|
|
815
810
|
}
|
|
811
|
+
const event = firstText(entry, ["event"]);
|
|
812
|
+
const state = firstText(entry, ["status", "state"]);
|
|
816
813
|
const from = firstText(entry, ["from"]);
|
|
817
814
|
const to = firstText(entry, ["to"]);
|
|
818
815
|
const attribution = componentContracts.historyAttribution(entry);
|
|
819
816
|
events.push({
|
|
820
|
-
label: firstText(entry, ["label", "title"]) ?? (
|
|
817
|
+
label: firstText(entry, ["label", "title"]) ?? (event ? componentContracts.formatReadOnlyValue(event, "string", true) : void 0) ?? (state ? statusLabel(state) : void 0) ?? firstText(entry, ["text", "name"]) ?? (to ? from ? `${statusLabel(from)} \u2192 ${statusLabel(to)}` : statusLabel(to) : void 0) ?? "Event",
|
|
821
818
|
timestamp: firstText(entry, ["timestamp", "datetime", "time", "at", "createdAt", "updatedAt"]),
|
|
822
|
-
detail: firstText(entry, ["detail", "description", "message"]) ?? (to ? from ? `${
|
|
819
|
+
detail: firstText(entry, ["detail", "description", "message"]) ?? (to ? from ? `${statusLabel(from)} \u2192 ${statusLabel(to)}` : statusLabel(to) : void 0),
|
|
823
820
|
actorId: attribution?.namesActor ? void 0 : firstText(entry, ["actorId", "actor_id", "actor"]),
|
|
824
821
|
...attribution ? { attribution: attribution.text } : {},
|
|
825
822
|
reason: firstText(entry, ["reason"])
|
|
@@ -933,7 +930,10 @@ var StatusBadge = vue.defineComponent({
|
|
|
933
930
|
const status = props.status ?? props.value ?? "unknown";
|
|
934
931
|
const presentation = getPortedStatusPresentation(props.domain, status);
|
|
935
932
|
const tone = props.tone === "lifecycle" ? presentation.tone : props.tone ?? presentation.tone;
|
|
936
|
-
const
|
|
933
|
+
const children = slots.default?.();
|
|
934
|
+
const slotLabel = children?.length && children.every((node) => node.type === vue.Text) ? children.map((node) => node.children).join("") : void 0;
|
|
935
|
+
const badgeSlots = children ? { ...slots, default: () => children } : slots;
|
|
936
|
+
const ariaLabel = stringValue(attrs["aria-label"]) ?? props.label ?? `Status: ${slotLabel ?? props.content ?? presentation.label}`;
|
|
937
937
|
return vue.h(Badge, {
|
|
938
938
|
...attrs,
|
|
939
939
|
class: mergedClass("oods-status-badge", attrs.class),
|
|
@@ -945,7 +945,7 @@ var StatusBadge = vue.defineComponent({
|
|
|
945
945
|
title: stringValue(attrs.title) ?? presentation.description,
|
|
946
946
|
"aria-label": ariaLabel,
|
|
947
947
|
"data-oods-component": "StatusBadge"
|
|
948
|
-
}, props.showIcon && presentation.icon && !slots.icon ? { ...
|
|
948
|
+
}, props.showIcon && presentation.icon && !slots.icon ? { ...badgeSlots, icon: () => statusIcon(presentation.icon) } : badgeSlots);
|
|
949
949
|
};
|
|
950
950
|
}
|
|
951
951
|
});
|
|
@@ -1002,6 +1002,7 @@ var PriceBadge = vue.defineComponent({
|
|
|
1002
1002
|
};
|
|
1003
1003
|
}
|
|
1004
1004
|
});
|
|
1005
|
+
var statusLabelProps = { enumLabels: Object };
|
|
1005
1006
|
var timelineProps = {
|
|
1006
1007
|
title: String,
|
|
1007
1008
|
source: Array,
|
|
@@ -1042,11 +1043,14 @@ function timelineComponent(configuration) {
|
|
|
1042
1043
|
return vue.defineComponent({
|
|
1043
1044
|
name: `Oods${configuration.componentId}`,
|
|
1044
1045
|
inheritAttrs: false,
|
|
1045
|
-
props:
|
|
1046
|
+
props: {
|
|
1047
|
+
...timelineProps,
|
|
1048
|
+
...configuration.componentId === "StatusTimeline" ? statusLabelProps : {}
|
|
1049
|
+
},
|
|
1046
1050
|
setup(props, { attrs, slots }) {
|
|
1047
1051
|
return () => {
|
|
1048
1052
|
const rawEvents = configuration.componentId === "StatusTimeline" ? firstArray(props.source, props.events, props.history, props.entries, props.stateHistory) : firstArray(props.source, props.events, props.history, props.entries, props.auditLog);
|
|
1049
|
-
const normalized = normalizeTimelineEvents(rawEvents);
|
|
1053
|
+
const normalized = normalizeTimelineEvents(rawEvents, props.enumLabels);
|
|
1050
1054
|
const events = props.maxVisible === void 0 ? normalized : normalized.slice(0, Math.max(0, Math.floor(props.maxVisible)));
|
|
1051
1055
|
const title = props.title ?? configuration.defaultTitle;
|
|
1052
1056
|
const slottedEvents = slots.default?.();
|
|
@@ -1059,8 +1063,8 @@ function timelineComponent(configuration) {
|
|
|
1059
1063
|
"data-timeline-type": configuration.timelineType
|
|
1060
1064
|
}, [
|
|
1061
1065
|
vue.h("h2", { class: "oods-timeline__title", "data-timeline-title": "true" }, title),
|
|
1062
|
-
props.status ? vue.h("p", { class: "oods-timeline__current", "data-timeline-current": "true" }, `Current status: ${
|
|
1063
|
-
props.allowedTransitions?.length ? vue.h("p", { "data-timeline-transitions": "true" }, `Allowed transitions: ${props.allowedTransitions.join(", ")}`) : null,
|
|
1066
|
+
props.status ? vue.h("p", { class: "oods-timeline__current", "data-timeline-current": "true" }, `Current status: ${componentContracts.enumOptionLabel(props.status, props.enumLabels)}`) : null,
|
|
1067
|
+
props.allowedTransitions?.length ? vue.h("p", { "data-timeline-transitions": "true" }, `Allowed transitions: ${props.allowedTransitions.map((value) => componentContracts.enumOptionLabel(value, props.enumLabels)).join(", ")}`) : null,
|
|
1064
1068
|
vue.h("ol", { class: "oods-timeline__events", "data-timeline-events": "true" }, slottedEvents?.length ? slottedEvents : events.length ? events.map((event, index) => renderTimelineEvent(
|
|
1065
1069
|
event,
|
|
1066
1070
|
index,
|
|
@@ -1393,6 +1397,7 @@ var RelativeTimestamp = vue.defineComponent({
|
|
|
1393
1397
|
label: String,
|
|
1394
1398
|
text: String,
|
|
1395
1399
|
timezone: String,
|
|
1400
|
+
caption: String,
|
|
1396
1401
|
hideWhenEmpty: Boolean,
|
|
1397
1402
|
now: [String, Number, Date],
|
|
1398
1403
|
field: String,
|
|
@@ -1422,7 +1427,7 @@ var RelativeTimestamp = vue.defineComponent({
|
|
|
1422
1427
|
datetime: datetime || void 0,
|
|
1423
1428
|
title: stringValue(attrs.title) ?? absolute,
|
|
1424
1429
|
"data-oods-component": "RelativeTimestamp"
|
|
1425
|
-
}, content);
|
|
1430
|
+
}, props.caption ? `${props.caption}: ${content}` : content);
|
|
1426
1431
|
};
|
|
1427
1432
|
}
|
|
1428
1433
|
});
|
package/dist/ported.d.cts
CHANGED
|
@@ -71,6 +71,7 @@ type TimelineProps = {
|
|
|
71
71
|
stateHistory?: readonly unknown[];
|
|
72
72
|
auditLog?: readonly unknown[];
|
|
73
73
|
status?: string;
|
|
74
|
+
enumLabels?: Record<string, string>;
|
|
74
75
|
allowedTransitions?: readonly string[];
|
|
75
76
|
showActorId?: boolean;
|
|
76
77
|
showReason?: boolean;
|
|
@@ -145,6 +146,7 @@ type RelativeTimestampProps = {
|
|
|
145
146
|
label?: string;
|
|
146
147
|
text?: string;
|
|
147
148
|
timezone?: string;
|
|
149
|
+
caption?: string;
|
|
148
150
|
hideWhenEmpty?: boolean;
|
|
149
151
|
now?: string | number | Date;
|
|
150
152
|
field?: string;
|
|
@@ -287,6 +289,8 @@ declare const StatusTimeline: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
287
289
|
readonly eventTimestampField: StringConstructor;
|
|
288
290
|
readonly eventOptionsParameter: StringConstructor;
|
|
289
291
|
readonly showFromState: BooleanConstructor;
|
|
292
|
+
} & {
|
|
293
|
+
enumLabels: PropType<Record<string, string>>;
|
|
290
294
|
}>, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
291
295
|
[key: string]: any;
|
|
292
296
|
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
@@ -318,6 +322,8 @@ declare const StatusTimeline: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
318
322
|
readonly eventTimestampField: StringConstructor;
|
|
319
323
|
readonly eventOptionsParameter: StringConstructor;
|
|
320
324
|
readonly showFromState: BooleanConstructor;
|
|
325
|
+
} & {
|
|
326
|
+
enumLabels: PropType<Record<string, string>>;
|
|
321
327
|
}>> & Readonly<{}>, {
|
|
322
328
|
readonly showActorId: boolean;
|
|
323
329
|
readonly showReason: boolean;
|
|
@@ -352,6 +358,8 @@ declare const AuditTimeline: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
352
358
|
readonly eventTimestampField: StringConstructor;
|
|
353
359
|
readonly eventOptionsParameter: StringConstructor;
|
|
354
360
|
readonly showFromState: BooleanConstructor;
|
|
361
|
+
} & {
|
|
362
|
+
enumLabels: PropType<Record<string, string>>;
|
|
355
363
|
}>, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
356
364
|
[key: string]: any;
|
|
357
365
|
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
@@ -383,6 +391,8 @@ declare const AuditTimeline: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
383
391
|
readonly eventTimestampField: StringConstructor;
|
|
384
392
|
readonly eventOptionsParameter: StringConstructor;
|
|
385
393
|
readonly showFromState: BooleanConstructor;
|
|
394
|
+
} & {
|
|
395
|
+
enumLabels: PropType<Record<string, string>>;
|
|
386
396
|
}>> & Readonly<{}>, {
|
|
387
397
|
readonly showActorId: boolean;
|
|
388
398
|
readonly showReason: boolean;
|
|
@@ -617,6 +627,7 @@ declare const RelativeTimestamp: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
617
627
|
label: StringConstructor;
|
|
618
628
|
text: StringConstructor;
|
|
619
629
|
timezone: StringConstructor;
|
|
630
|
+
caption: StringConstructor;
|
|
620
631
|
hideWhenEmpty: BooleanConstructor;
|
|
621
632
|
now: PropType<string | number | Date>;
|
|
622
633
|
field: StringConstructor;
|
|
@@ -634,6 +645,7 @@ declare const RelativeTimestamp: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
634
645
|
label: StringConstructor;
|
|
635
646
|
text: StringConstructor;
|
|
636
647
|
timezone: StringConstructor;
|
|
648
|
+
caption: StringConstructor;
|
|
637
649
|
hideWhenEmpty: BooleanConstructor;
|
|
638
650
|
now: PropType<string | number | Date>;
|
|
639
651
|
field: StringConstructor;
|
package/dist/ported.d.ts
CHANGED
|
@@ -71,6 +71,7 @@ type TimelineProps = {
|
|
|
71
71
|
stateHistory?: readonly unknown[];
|
|
72
72
|
auditLog?: readonly unknown[];
|
|
73
73
|
status?: string;
|
|
74
|
+
enumLabels?: Record<string, string>;
|
|
74
75
|
allowedTransitions?: readonly string[];
|
|
75
76
|
showActorId?: boolean;
|
|
76
77
|
showReason?: boolean;
|
|
@@ -145,6 +146,7 @@ type RelativeTimestampProps = {
|
|
|
145
146
|
label?: string;
|
|
146
147
|
text?: string;
|
|
147
148
|
timezone?: string;
|
|
149
|
+
caption?: string;
|
|
148
150
|
hideWhenEmpty?: boolean;
|
|
149
151
|
now?: string | number | Date;
|
|
150
152
|
field?: string;
|
|
@@ -287,6 +289,8 @@ declare const StatusTimeline: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
287
289
|
readonly eventTimestampField: StringConstructor;
|
|
288
290
|
readonly eventOptionsParameter: StringConstructor;
|
|
289
291
|
readonly showFromState: BooleanConstructor;
|
|
292
|
+
} & {
|
|
293
|
+
enumLabels: PropType<Record<string, string>>;
|
|
290
294
|
}>, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
291
295
|
[key: string]: any;
|
|
292
296
|
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
@@ -318,6 +322,8 @@ declare const StatusTimeline: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
318
322
|
readonly eventTimestampField: StringConstructor;
|
|
319
323
|
readonly eventOptionsParameter: StringConstructor;
|
|
320
324
|
readonly showFromState: BooleanConstructor;
|
|
325
|
+
} & {
|
|
326
|
+
enumLabels: PropType<Record<string, string>>;
|
|
321
327
|
}>> & Readonly<{}>, {
|
|
322
328
|
readonly showActorId: boolean;
|
|
323
329
|
readonly showReason: boolean;
|
|
@@ -352,6 +358,8 @@ declare const AuditTimeline: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
352
358
|
readonly eventTimestampField: StringConstructor;
|
|
353
359
|
readonly eventOptionsParameter: StringConstructor;
|
|
354
360
|
readonly showFromState: BooleanConstructor;
|
|
361
|
+
} & {
|
|
362
|
+
enumLabels: PropType<Record<string, string>>;
|
|
355
363
|
}>, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
356
364
|
[key: string]: any;
|
|
357
365
|
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
@@ -383,6 +391,8 @@ declare const AuditTimeline: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
383
391
|
readonly eventTimestampField: StringConstructor;
|
|
384
392
|
readonly eventOptionsParameter: StringConstructor;
|
|
385
393
|
readonly showFromState: BooleanConstructor;
|
|
394
|
+
} & {
|
|
395
|
+
enumLabels: PropType<Record<string, string>>;
|
|
386
396
|
}>> & Readonly<{}>, {
|
|
387
397
|
readonly showActorId: boolean;
|
|
388
398
|
readonly showReason: boolean;
|
|
@@ -617,6 +627,7 @@ declare const RelativeTimestamp: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
617
627
|
label: StringConstructor;
|
|
618
628
|
text: StringConstructor;
|
|
619
629
|
timezone: StringConstructor;
|
|
630
|
+
caption: StringConstructor;
|
|
620
631
|
hideWhenEmpty: BooleanConstructor;
|
|
621
632
|
now: PropType<string | number | Date>;
|
|
622
633
|
field: StringConstructor;
|
|
@@ -634,6 +645,7 @@ declare const RelativeTimestamp: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
634
645
|
label: StringConstructor;
|
|
635
646
|
text: StringConstructor;
|
|
636
647
|
timezone: StringConstructor;
|
|
648
|
+
caption: StringConstructor;
|
|
637
649
|
hideWhenEmpty: BooleanConstructor;
|
|
638
650
|
now: PropType<string | number | Date>;
|
|
639
651
|
field: StringConstructor;
|
package/dist/ported.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { dateTimeInputValue, formatDateTime, formatReadOnlyValue, STATUS_ICON_SVG_ATTRS, STATUS_ICON_SHAPES, getStatusPresentation, resolveStatusIcon, currencyMinorUnits, historyAttribution } from '@oods/component-contracts';
|
|
2
|
-
import { defineComponent, h, useId, computed, ref, onMounted, onBeforeUnmount, watch } from 'vue';
|
|
1
|
+
import { enumOptionLabel, dateTimeInputValue, formatDateTime, formatReadOnlyValue, STATUS_ICON_SVG_ATTRS, STATUS_ICON_SHAPES, getStatusPresentation, resolveStatusIcon, currencyMinorUnits, historyAttribution } from '@oods/component-contracts';
|
|
2
|
+
import { defineComponent, h, useId, computed, ref, onMounted, onBeforeUnmount, watch, Text } from 'vue';
|
|
3
3
|
|
|
4
4
|
// src/ported.ts
|
|
5
5
|
function statusIcon(name) {
|
|
@@ -61,9 +61,6 @@ function tokenTone(tone) {
|
|
|
61
61
|
if (tone === "danger") return "critical";
|
|
62
62
|
return tone;
|
|
63
63
|
}
|
|
64
|
-
function statusLabel(status) {
|
|
65
|
-
return normalizeStatus(status).split("_").filter(Boolean).map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join(" ");
|
|
66
|
-
}
|
|
67
64
|
function slotOrValue(slot, value) {
|
|
68
65
|
return slot ? slot() : value;
|
|
69
66
|
}
|
|
@@ -95,7 +92,7 @@ var Badge = defineComponent({
|
|
|
95
92
|
}
|
|
96
93
|
}, [
|
|
97
94
|
props.icon || slots.icon ? h("span", { class: "oods-badge__icon", "aria-hidden": "true" }, [slotOrValue(slots.icon, props.icon)]) : null,
|
|
98
|
-
h("span", { class: "oods-badge__label" }, [slotOrValue(slots.default, props.content ??
|
|
95
|
+
h("span", { class: "oods-badge__label" }, [slotOrValue(slots.default, props.content ?? enumOptionLabel(props.status ?? ""))])
|
|
99
96
|
]);
|
|
100
97
|
};
|
|
101
98
|
}
|
|
@@ -136,7 +133,7 @@ defineComponent({
|
|
|
136
133
|
}, [
|
|
137
134
|
h("div", { class: "oods-banner__content" }, [
|
|
138
135
|
props.title || props.status || slots.title ? h("strong", { class: "oods-banner__title" }, [
|
|
139
|
-
slotOrValue(slots.title, props.title ||
|
|
136
|
+
slotOrValue(slots.title, props.title || enumOptionLabel(props.status ?? ""))
|
|
140
137
|
]) : null,
|
|
141
138
|
props.detail ? h("p", { class: "oods-banner__detail" }, props.detail) : null,
|
|
142
139
|
slots.default || props.content ? h(slots.default ? "div" : "p", { class: "oods-banner__body" }, [slotOrValue(slots.default, props.content)]) : null,
|
|
@@ -784,13 +781,10 @@ function firstText(record, keys) {
|
|
|
784
781
|
}
|
|
785
782
|
return void 0;
|
|
786
783
|
}
|
|
787
|
-
function statusLabel2(status) {
|
|
788
|
-
return status.split(/[_-]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1)).join(" ");
|
|
789
|
-
}
|
|
790
784
|
function getPortedStatusPresentation(domain, status) {
|
|
791
785
|
const presentation = getStatusPresentation(domain.toLowerCase(), status);
|
|
792
786
|
return {
|
|
793
|
-
label:
|
|
787
|
+
label: presentation.label,
|
|
794
788
|
description: presentation.description,
|
|
795
789
|
tone: presentation.tone,
|
|
796
790
|
icon: resolveStatusIcon(presentation.iconName)
|
|
@@ -802,7 +796,8 @@ function formatPrice(amountCents, amount, currency) {
|
|
|
802
796
|
const formatted = Number.isInteger(normalizedAmount) ? String(normalizedAmount) : normalizedAmount.toFixed(2);
|
|
803
797
|
return currency ? `${currency.toUpperCase()} ${formatted}` : formatted;
|
|
804
798
|
}
|
|
805
|
-
function normalizeTimelineEvents(raw) {
|
|
799
|
+
function normalizeTimelineEvents(raw, labels) {
|
|
800
|
+
const statusLabel = (state) => enumOptionLabel(state, labels);
|
|
806
801
|
if (!Array.isArray(raw)) return [];
|
|
807
802
|
const events = [];
|
|
808
803
|
for (const entry of raw) {
|
|
@@ -811,13 +806,15 @@ function normalizeTimelineEvents(raw) {
|
|
|
811
806
|
events.push({ label: String(entry) });
|
|
812
807
|
continue;
|
|
813
808
|
}
|
|
809
|
+
const event = firstText(entry, ["event"]);
|
|
810
|
+
const state = firstText(entry, ["status", "state"]);
|
|
814
811
|
const from = firstText(entry, ["from"]);
|
|
815
812
|
const to = firstText(entry, ["to"]);
|
|
816
813
|
const attribution = historyAttribution(entry);
|
|
817
814
|
events.push({
|
|
818
|
-
label: firstText(entry, ["label", "title"]) ?? (
|
|
815
|
+
label: firstText(entry, ["label", "title"]) ?? (event ? formatReadOnlyValue(event, "string", true) : void 0) ?? (state ? statusLabel(state) : void 0) ?? firstText(entry, ["text", "name"]) ?? (to ? from ? `${statusLabel(from)} \u2192 ${statusLabel(to)}` : statusLabel(to) : void 0) ?? "Event",
|
|
819
816
|
timestamp: firstText(entry, ["timestamp", "datetime", "time", "at", "createdAt", "updatedAt"]),
|
|
820
|
-
detail: firstText(entry, ["detail", "description", "message"]) ?? (to ? from ? `${
|
|
817
|
+
detail: firstText(entry, ["detail", "description", "message"]) ?? (to ? from ? `${statusLabel(from)} \u2192 ${statusLabel(to)}` : statusLabel(to) : void 0),
|
|
821
818
|
actorId: attribution?.namesActor ? void 0 : firstText(entry, ["actorId", "actor_id", "actor"]),
|
|
822
819
|
...attribution ? { attribution: attribution.text } : {},
|
|
823
820
|
reason: firstText(entry, ["reason"])
|
|
@@ -931,7 +928,10 @@ var StatusBadge = defineComponent({
|
|
|
931
928
|
const status = props.status ?? props.value ?? "unknown";
|
|
932
929
|
const presentation = getPortedStatusPresentation(props.domain, status);
|
|
933
930
|
const tone = props.tone === "lifecycle" ? presentation.tone : props.tone ?? presentation.tone;
|
|
934
|
-
const
|
|
931
|
+
const children = slots.default?.();
|
|
932
|
+
const slotLabel = children?.length && children.every((node) => node.type === Text) ? children.map((node) => node.children).join("") : void 0;
|
|
933
|
+
const badgeSlots = children ? { ...slots, default: () => children } : slots;
|
|
934
|
+
const ariaLabel = stringValue(attrs["aria-label"]) ?? props.label ?? `Status: ${slotLabel ?? props.content ?? presentation.label}`;
|
|
935
935
|
return h(Badge, {
|
|
936
936
|
...attrs,
|
|
937
937
|
class: mergedClass("oods-status-badge", attrs.class),
|
|
@@ -943,7 +943,7 @@ var StatusBadge = defineComponent({
|
|
|
943
943
|
title: stringValue(attrs.title) ?? presentation.description,
|
|
944
944
|
"aria-label": ariaLabel,
|
|
945
945
|
"data-oods-component": "StatusBadge"
|
|
946
|
-
}, props.showIcon && presentation.icon && !slots.icon ? { ...
|
|
946
|
+
}, props.showIcon && presentation.icon && !slots.icon ? { ...badgeSlots, icon: () => statusIcon(presentation.icon) } : badgeSlots);
|
|
947
947
|
};
|
|
948
948
|
}
|
|
949
949
|
});
|
|
@@ -1000,6 +1000,7 @@ var PriceBadge = defineComponent({
|
|
|
1000
1000
|
};
|
|
1001
1001
|
}
|
|
1002
1002
|
});
|
|
1003
|
+
var statusLabelProps = { enumLabels: Object };
|
|
1003
1004
|
var timelineProps = {
|
|
1004
1005
|
title: String,
|
|
1005
1006
|
source: Array,
|
|
@@ -1040,11 +1041,14 @@ function timelineComponent(configuration) {
|
|
|
1040
1041
|
return defineComponent({
|
|
1041
1042
|
name: `Oods${configuration.componentId}`,
|
|
1042
1043
|
inheritAttrs: false,
|
|
1043
|
-
props:
|
|
1044
|
+
props: {
|
|
1045
|
+
...timelineProps,
|
|
1046
|
+
...configuration.componentId === "StatusTimeline" ? statusLabelProps : {}
|
|
1047
|
+
},
|
|
1044
1048
|
setup(props, { attrs, slots }) {
|
|
1045
1049
|
return () => {
|
|
1046
1050
|
const rawEvents = configuration.componentId === "StatusTimeline" ? firstArray(props.source, props.events, props.history, props.entries, props.stateHistory) : firstArray(props.source, props.events, props.history, props.entries, props.auditLog);
|
|
1047
|
-
const normalized = normalizeTimelineEvents(rawEvents);
|
|
1051
|
+
const normalized = normalizeTimelineEvents(rawEvents, props.enumLabels);
|
|
1048
1052
|
const events = props.maxVisible === void 0 ? normalized : normalized.slice(0, Math.max(0, Math.floor(props.maxVisible)));
|
|
1049
1053
|
const title = props.title ?? configuration.defaultTitle;
|
|
1050
1054
|
const slottedEvents = slots.default?.();
|
|
@@ -1057,8 +1061,8 @@ function timelineComponent(configuration) {
|
|
|
1057
1061
|
"data-timeline-type": configuration.timelineType
|
|
1058
1062
|
}, [
|
|
1059
1063
|
h("h2", { class: "oods-timeline__title", "data-timeline-title": "true" }, title),
|
|
1060
|
-
props.status ? h("p", { class: "oods-timeline__current", "data-timeline-current": "true" }, `Current status: ${
|
|
1061
|
-
props.allowedTransitions?.length ? h("p", { "data-timeline-transitions": "true" }, `Allowed transitions: ${props.allowedTransitions.join(", ")}`) : null,
|
|
1064
|
+
props.status ? h("p", { class: "oods-timeline__current", "data-timeline-current": "true" }, `Current status: ${enumOptionLabel(props.status, props.enumLabels)}`) : null,
|
|
1065
|
+
props.allowedTransitions?.length ? h("p", { "data-timeline-transitions": "true" }, `Allowed transitions: ${props.allowedTransitions.map((value) => enumOptionLabel(value, props.enumLabels)).join(", ")}`) : null,
|
|
1062
1066
|
h("ol", { class: "oods-timeline__events", "data-timeline-events": "true" }, slottedEvents?.length ? slottedEvents : events.length ? events.map((event, index) => renderTimelineEvent(
|
|
1063
1067
|
event,
|
|
1064
1068
|
index,
|
|
@@ -1391,6 +1395,7 @@ var RelativeTimestamp = defineComponent({
|
|
|
1391
1395
|
label: String,
|
|
1392
1396
|
text: String,
|
|
1393
1397
|
timezone: String,
|
|
1398
|
+
caption: String,
|
|
1394
1399
|
hideWhenEmpty: Boolean,
|
|
1395
1400
|
now: [String, Number, Date],
|
|
1396
1401
|
field: String,
|
|
@@ -1420,7 +1425,7 @@ var RelativeTimestamp = defineComponent({
|
|
|
1420
1425
|
datetime: datetime || void 0,
|
|
1421
1426
|
title: stringValue(attrs.title) ?? absolute,
|
|
1422
1427
|
"data-oods-component": "RelativeTimestamp"
|
|
1423
|
-
}, content);
|
|
1428
|
+
}, props.caption ? `${props.caption}: ${content}` : content);
|
|
1424
1429
|
};
|
|
1425
1430
|
}
|
|
1426
1431
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oods/components-vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Vue 3 components for OODS Foundry: the controls, layouts and domain views its generated screens use.",
|
|
5
5
|
"homepage": "https://oods-foundry.com/",
|
|
6
6
|
"bugs": {
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"**/*.css"
|
|
54
54
|
],
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@oods/component-contracts": "0.
|
|
57
|
-
"@oods/component-styles": "0.
|
|
56
|
+
"@oods/component-contracts": "0.19.0",
|
|
57
|
+
"@oods/component-styles": "0.19.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"vue": "^3.5.0"
|
|
@@ -64,11 +64,11 @@
|
|
|
64
64
|
"@vue/compiler-sfc": "^3.5.42",
|
|
65
65
|
"@vue/server-renderer": "^3.5.42",
|
|
66
66
|
"@vue/test-utils": "^2.5.0",
|
|
67
|
-
"jsdom": "
|
|
67
|
+
"jsdom": "31.0.1",
|
|
68
68
|
"playwright": "^1.56.1",
|
|
69
69
|
"typescript": "^5.9.3",
|
|
70
|
-
"vite": "
|
|
71
|
-
"vitest": "
|
|
70
|
+
"vite": "6.4.6",
|
|
71
|
+
"vitest": "5.1.1",
|
|
72
72
|
"vitest-axe": "^0.1.0",
|
|
73
73
|
"vue": "^3.5.42",
|
|
74
74
|
"vue-tsc": "^3.3.11"
|