@react-spectrum/labeledvalue 3.0.0-nightly.3479 → 3.0.0-nightly.3491
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/main.css +1 -1
- package/dist/main.js +38 -30
- package/dist/main.js.map +1 -1
- package/dist/module.js +39 -31
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/LabeledValue.tsx +36 -56
package/dist/main.css
CHANGED
@@ -1 +1 @@
|
|
1
|
-
[dir=ltr] .spectrum-FieldLabel_d2db1f{text-align:left}[dir=rtl] .spectrum-FieldLabel_d2db1f{text-align:right}.spectrum-FieldLabel_d2db1f{box-sizing:border-box;padding:var(--spectrum-fieldlabel-padding-top,var(--spectrum-global-dimension-size-50))0 var(--spectrum-fieldlabel-padding-bottom,var(--spectrum-global-dimension-size-65));font-size:var(--spectrum-fieldlabel-text-size,var(--spectrum-global-dimension-font-size-75));font-weight:var(--spectrum-fieldlabel-text-font-weight,var(--spectrum-global-font-weight-regular));line-height:var(--spectrum-fieldlabel-text-line-height,var(--spectrum-global-font-line-height-small));vertical-align:top;-webkit-font-smoothing:subpixel-antialiased;-moz-osx-font-smoothing:auto;font-smoothing:subpixel-antialiased;cursor:default;flex:none;display:flex}[dir=ltr] .spectrum-FieldLabel--positionSide_d2db1f{padding-right:var(--spectrum-fieldlabel-side-padding-x,var(--spectrum-global-dimension-size-100))}[dir=rtl] .spectrum-FieldLabel--positionSide_d2db1f{padding-left:var(--spectrum-fieldlabel-side-padding-x,var(--spectrum-global-dimension-size-100))}.spectrum-FieldLabel--positionSide_d2db1f{padding-top:var(--spectrum-fieldlabel-side-padding-top,var(--spectrum-global-dimension-size-100));display:inline-flex}[dir=ltr] .spectrum-FieldLabel-requiredIcon_d2db1f{margin-right:0}[dir=rtl] .spectrum-FieldLabel-requiredIcon_d2db1f{margin-left:0}[dir=ltr] .spectrum-FieldLabel-requiredIcon_d2db1f{margin-left:var(--spectrum-fieldlabel-asterisk-gap,var(--spectrum-global-dimension-size-25))}[dir=rtl] .spectrum-FieldLabel-requiredIcon_d2db1f{margin-right:var(--spectrum-fieldlabel-asterisk-gap,var(--spectrum-global-dimension-size-25))}.spectrum-FieldLabel-requiredIcon_d2db1f{margin-top:var(--spectrum-fieldlabel-asterisk-margin-y,var(--spectrum-global-dimension-size-50));margin-bottom:0}[dir=ltr] .spectrum-FieldLabel--alignEnd_d2db1f{text-align:right}[dir=rtl] .spectrum-FieldLabel--alignEnd_d2db1f{text-align:left}.spectrum-FieldLabel--alignEnd_d2db1f{justify-content:flex-end}.spectrum-Field_d2db1f{--spectrum-field-default-width:var(--spectrum-alias-single-line-width,var(--spectrum-global-dimension-size-2400))}.spectrum-Field_d2db1f.spectrum-Field--positionTop_d2db1f{width:var(--spectrum-field-default-width);
|
1
|
+
[dir=ltr] .spectrum-FieldLabel_d2db1f{text-align:left}[dir=rtl] .spectrum-FieldLabel_d2db1f{text-align:right}.spectrum-FieldLabel_d2db1f{box-sizing:border-box;padding:var(--spectrum-fieldlabel-padding-top,var(--spectrum-global-dimension-size-50))0 var(--spectrum-fieldlabel-padding-bottom,var(--spectrum-global-dimension-size-65));font-size:var(--spectrum-fieldlabel-text-size,var(--spectrum-global-dimension-font-size-75));font-weight:var(--spectrum-fieldlabel-text-font-weight,var(--spectrum-global-font-weight-regular));line-height:var(--spectrum-fieldlabel-text-line-height,var(--spectrum-global-font-line-height-small));vertical-align:top;-webkit-font-smoothing:subpixel-antialiased;-moz-osx-font-smoothing:auto;font-smoothing:subpixel-antialiased;cursor:default;flex:none;display:flex}[dir=ltr] .spectrum-FieldLabel--positionSide_d2db1f{padding-right:var(--spectrum-fieldlabel-side-padding-x,var(--spectrum-global-dimension-size-100))}[dir=rtl] .spectrum-FieldLabel--positionSide_d2db1f{padding-left:var(--spectrum-fieldlabel-side-padding-x,var(--spectrum-global-dimension-size-100))}.spectrum-FieldLabel--positionSide_d2db1f{padding-top:var(--spectrum-fieldlabel-side-padding-top,var(--spectrum-global-dimension-size-100));display:inline-flex}[dir=ltr] .spectrum-FieldLabel-requiredIcon_d2db1f{margin-right:0}[dir=rtl] .spectrum-FieldLabel-requiredIcon_d2db1f{margin-left:0}[dir=ltr] .spectrum-FieldLabel-requiredIcon_d2db1f{margin-left:var(--spectrum-fieldlabel-asterisk-gap,var(--spectrum-global-dimension-size-25))}[dir=rtl] .spectrum-FieldLabel-requiredIcon_d2db1f{margin-right:var(--spectrum-fieldlabel-asterisk-gap,var(--spectrum-global-dimension-size-25))}.spectrum-FieldLabel-requiredIcon_d2db1f{margin-top:var(--spectrum-fieldlabel-asterisk-margin-y,var(--spectrum-global-dimension-size-50));margin-bottom:0}[dir=ltr] .spectrum-FieldLabel--alignEnd_d2db1f{text-align:right}[dir=rtl] .spectrum-FieldLabel--alignEnd_d2db1f{text-align:left}.spectrum-FieldLabel--alignEnd_d2db1f{justify-content:flex-end}.spectrum-Field_d2db1f{--spectrum-field-default-width:var(--spectrum-alias-single-line-width,var(--spectrum-global-dimension-size-2400))}.spectrum-Field_d2db1f.spectrum-Field--positionTop_d2db1f{display:-ms-inline-grid;-ms-grid-columns:auto auto minmax(0,1fr);width:var(--spectrum-field-default-width);grid-template-columns:auto auto minmax(0,1fr);grid-template-areas:"label contextualHelp.""field field field""helpText helpText helpText";align-content:start;display:inline-grid}.spectrum-Field_d2db1f.spectrum-Field--positionTop_d2db1f .spectrum-Field-field_d2db1f{width:100%;grid-area:field}.spectrum-Field_d2db1f.spectrum-Field--positionTop_d2db1f.spectrum-Field--alignEnd_d2db1f{-ms-grid-columns:1fr auto 0;grid-template-columns:1fr auto 0}.spectrum-Field_d2db1f.spectrum-Field--positionTop_d2db1f .spectrum-FieldLabel_d2db1f{grid-area:label}.spectrum-Field_d2db1f.spectrum-Field--positionSide_d2db1f{align-items:flex-start;display:inline-flex}.spectrum-Field_d2db1f.spectrum-Field--positionSide_d2db1f .spectrum-Field-wrapper_d2db1f{min-width:0;width:var(--spectrum-field-default-width);height:100%;flex:1}.spectrum-Field_d2db1f.spectrum-Field--positionSide_d2db1f .spectrum-Field-wrapper_d2db1f .spectrum-Field-field_d2db1f{width:100%}.spectrum-Field_d2db1f.spectrum-Field--positionSide_d2db1f .spectrum-Field-field_d2db1f{min-width:0;flex:1}[dir=ltr] .spectrum-Field_d2db1f.spectrum-Field--positionSide_d2db1f .spectrum-Field-contextualHelp_d2db1f{margin-right:var(--spectrum-fieldlabel-side-padding-x,var(--spectrum-global-dimension-size-100))}[dir=rtl] .spectrum-Field_d2db1f.spectrum-Field--positionSide_d2db1f .spectrum-Field-contextualHelp_d2db1f{margin-left:var(--spectrum-fieldlabel-side-padding-x,var(--spectrum-global-dimension-size-100))}.spectrum-Field_d2db1f.spectrum-Field--positionSide_d2db1f .spectrum-Field-contextualHelp_d2db1f{margin-top:var(--spectrum-global-dimension-size-65)}[dir=ltr] .spectrum-Field_d2db1f.spectrum-Field--hasContextualHelp_d2db1f .spectrum-FieldLabel_d2db1f{padding-right:0}[dir=rtl] .spectrum-Field_d2db1f.spectrum-Field--hasContextualHelp_d2db1f .spectrum-FieldLabel_d2db1f{padding-left:0}[dir=ltr] .spectrum-Field_d2db1f .spectrum-Field-contextualHelp_d2db1f{margin-left:var(--spectrum-global-dimension-size-50)}[dir=rtl] .spectrum-Field_d2db1f .spectrum-Field-contextualHelp_d2db1f{margin-right:var(--spectrum-global-dimension-size-50)}.spectrum-Field_d2db1f .spectrum-Field-contextualHelp_d2db1f{margin-top:var(--spectrum-global-dimension-size-25);grid-area:contextualHelp}[dir=ltr] .spectrum-Form_d2db1f.spectrum-Form--positionSide_d2db1f{text-align:left}[dir=rtl] .spectrum-Form_d2db1f.spectrum-Form--positionSide_d2db1f{text-align:right}.spectrum-Form_d2db1f.spectrum-Form--positionSide_d2db1f{border-collapse:separate;border-spacing:0 var(--spectrum-global-dimension-size-300);margin:calc(var(--spectrum-global-dimension-size-250)*-1)0;display:table}.spectrum-Form_d2db1f.spectrum-Form--positionSide_d2db1f .spectrum-Field_d2db1f{width:100%;display:table-row}.spectrum-Form_d2db1f.spectrum-Form--positionSide_d2db1f .spectrum-Field_d2db1f:not(.spectrum-Field--hasContextualHelp_d2db1f) .spectrum-FieldLabel_d2db1f,.spectrum-Form_d2db1f.spectrum-Form--positionSide_d2db1f .spectrum-Field_d2db1f.spectrum-Field--hasContextualHelp_d2db1f .spectrum-Field-labelCell_d2db1f{display:table-cell}.spectrum-Form_d2db1f.spectrum-Form--positionSide_d2db1f .spectrum-Field_d2db1f .spectrum-Field-labelCell_d2db1f{vertical-align:top}[dir=ltr] .spectrum-Form_d2db1f.spectrum-Form--positionSide_d2db1f .spectrum-Field_d2db1f.spectrum-Field--alignEnd_d2db1f .spectrum-Field-labelCell_d2db1f{text-align:right}[dir=rtl] .spectrum-Form_d2db1f.spectrum-Form--positionSide_d2db1f .spectrum-Field_d2db1f.spectrum-Field--alignEnd_d2db1f .spectrum-Field-labelCell_d2db1f{text-align:left}.spectrum-Form_d2db1f.spectrum-Form--positionSide_d2db1f .spectrum-Field_d2db1f .spectrum-Field-labelWrapper_d2db1f{display:inline-flex}.spectrum-Form_d2db1f.spectrum-Form--positionSide_d2db1f .spectrum-Field_d2db1f .spectrum-Field-labelWrapper_d2db1f .spectrum-FieldLabel_d2db1f{flex:1}.spectrum-Form_d2db1f.spectrum-Form--positionSide_d2db1f .spectrum-Field-wrapper_d2db1f{width:100%}.spectrum-Form_d2db1f.spectrum-Form--positionSide_d2db1f .spectrum-Field-field_d2db1f{width:auto;min-width:var(--spectrum-alias-single-line-width,var(--spectrum-global-dimension-size-2400))}.spectrum-Form_d2db1f.spectrum-Form--positionTop_d2db1f{min-width:var(--spectrum-alias-single-line-width,var(--spectrum-global-dimension-size-2400));flex-direction:column;margin:0;display:flex}.spectrum-Form_d2db1f.spectrum-Form--positionTop_d2db1f>*{margin-top:var(--spectrum-global-dimension-size-100);width:100%}.spectrum-LabeledValue_d2db1f.spectrum-Field--positionSide_d2db1f{-ms-flex-align:first baseline;align-items:baseline}.spectrum-LabeledValue_d2db1f.spectrum-Field--positionTop_d2db1f{width:unset}.spectrum-LabeledValue_d2db1f .spectrum-FieldLabel_d2db1f.spectrum-FieldLabel_d2db1f{padding-top:0}.spectrum-LabeledValue_d2db1f .spectrum-Field-wrapper_d2db1f.spectrum-Field-wrapper_d2db1f{width:unset}.spectrum-LabeledValue_d2db1f .spectrum-Field-field_d2db1f{word-break:break-word;overflow:hidden}.spectrum-LabeledValue_d2db1f .spectrum-Field-contextualHelp_d2db1f{margin-top:calc(-1*var(--spectrum-global-dimension-size-25))}.spectrum-FieldLabel_d2db1f,.spectrum-Form-itemLabel_d2db1f{color:var(--spectrum-fieldlabel-text-color,var(--spectrum-alias-label-text-color))}.spectrum-FieldLabel_d2db1f.is-disabled_d2db1f,.spectrum-Form-itemLabel_d2db1f.is-disabled_d2db1f{color:var(--spectrum-fieldlabel-text-color-disabled,var(--spectrum-alias-text-color-disabled))}.spectrum-FieldLabel_d2db1f.is-disabled_d2db1f .spectrum-FieldLabel-requiredIcon_d2db1f,.spectrum-Form-itemLabel_d2db1f.is-disabled_d2db1f .spectrum-FieldLabel-requiredIcon_d2db1f{color:var(--spectrum-fieldlabel-asterisk-color-disabled,var(--spectrum-alias-text-color-disabled))}.spectrum-FieldLabel-requiredIcon_d2db1f{color:var(--spectrum-fieldlabel-asterisk-color,var(--spectrum-global-color-gray-600))}
|
package/dist/main.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require("./main.css");
|
2
2
|
var $3cJLQ$internationalizeddate = require("@internationalized/date");
|
3
3
|
var $3cJLQ$reactspectrumutils = require("@react-spectrum/utils");
|
4
|
-
var $3cJLQ$reactariautils = require("@react-aria/utils");
|
5
4
|
var $3cJLQ$reactspectrumlabel = require("@react-spectrum/label");
|
5
|
+
var $3cJLQ$reactariautils = require("@react-aria/utils");
|
6
6
|
var $3cJLQ$react = require("react");
|
7
7
|
var $3cJLQ$reactariai18n = require("@react-aria/i18n");
|
8
8
|
|
@@ -27,10 +27,15 @@ $parcel$export($eb2fc0ee655eff6b$exports, "spectrum-FieldLabel--alignEnd", () =>
|
|
27
27
|
$parcel$export($eb2fc0ee655eff6b$exports, "spectrum-Field", () => $eb2fc0ee655eff6b$export$f6d480ae1e56eba0, (v) => $eb2fc0ee655eff6b$export$f6d480ae1e56eba0 = v);
|
28
28
|
$parcel$export($eb2fc0ee655eff6b$exports, "spectrum-Field--positionTop", () => $eb2fc0ee655eff6b$export$a4ea780a9064d7f9, (v) => $eb2fc0ee655eff6b$export$a4ea780a9064d7f9 = v);
|
29
29
|
$parcel$export($eb2fc0ee655eff6b$exports, "spectrum-Field-field", () => $eb2fc0ee655eff6b$export$3ab8a3dc7f0563d, (v) => $eb2fc0ee655eff6b$export$3ab8a3dc7f0563d = v);
|
30
|
+
$parcel$export($eb2fc0ee655eff6b$exports, "spectrum-Field--alignEnd", () => $eb2fc0ee655eff6b$export$5354c9be7ada5f83, (v) => $eb2fc0ee655eff6b$export$5354c9be7ada5f83 = v);
|
30
31
|
$parcel$export($eb2fc0ee655eff6b$exports, "spectrum-Field--positionSide", () => $eb2fc0ee655eff6b$export$2963225c91179589, (v) => $eb2fc0ee655eff6b$export$2963225c91179589 = v);
|
31
32
|
$parcel$export($eb2fc0ee655eff6b$exports, "spectrum-Field-wrapper", () => $eb2fc0ee655eff6b$export$127df0b7290eb8ef, (v) => $eb2fc0ee655eff6b$export$127df0b7290eb8ef = v);
|
33
|
+
$parcel$export($eb2fc0ee655eff6b$exports, "spectrum-Field-contextualHelp", () => $eb2fc0ee655eff6b$export$24fb860d16dd2d3f, (v) => $eb2fc0ee655eff6b$export$24fb860d16dd2d3f = v);
|
34
|
+
$parcel$export($eb2fc0ee655eff6b$exports, "spectrum-Field--hasContextualHelp", () => $eb2fc0ee655eff6b$export$9ba23707a252cdd4, (v) => $eb2fc0ee655eff6b$export$9ba23707a252cdd4 = v);
|
32
35
|
$parcel$export($eb2fc0ee655eff6b$exports, "spectrum-Form", () => $eb2fc0ee655eff6b$export$94d2bcc94afabd89, (v) => $eb2fc0ee655eff6b$export$94d2bcc94afabd89 = v);
|
33
36
|
$parcel$export($eb2fc0ee655eff6b$exports, "spectrum-Form--positionSide", () => $eb2fc0ee655eff6b$export$7f44db659563c8f4, (v) => $eb2fc0ee655eff6b$export$7f44db659563c8f4 = v);
|
37
|
+
$parcel$export($eb2fc0ee655eff6b$exports, "spectrum-Field-labelCell", () => $eb2fc0ee655eff6b$export$9cde5aecff012641, (v) => $eb2fc0ee655eff6b$export$9cde5aecff012641 = v);
|
38
|
+
$parcel$export($eb2fc0ee655eff6b$exports, "spectrum-Field-labelWrapper", () => $eb2fc0ee655eff6b$export$a872a8c78b26c9e0, (v) => $eb2fc0ee655eff6b$export$a872a8c78b26c9e0 = v);
|
34
39
|
$parcel$export($eb2fc0ee655eff6b$exports, "spectrum-Form--positionTop", () => $eb2fc0ee655eff6b$export$11b8bc81fe551057, (v) => $eb2fc0ee655eff6b$export$11b8bc81fe551057 = v);
|
35
40
|
$parcel$export($eb2fc0ee655eff6b$exports, "spectrum-LabeledValue", () => $eb2fc0ee655eff6b$export$79f9a5e9dd010c8d, (v) => $eb2fc0ee655eff6b$export$79f9a5e9dd010c8d = v);
|
36
41
|
$parcel$export($eb2fc0ee655eff6b$exports, "spectrum-Form-itemLabel", () => $eb2fc0ee655eff6b$export$51ec27881a1e3928, (v) => $eb2fc0ee655eff6b$export$51ec27881a1e3928 = v);
|
@@ -42,10 +47,15 @@ var $eb2fc0ee655eff6b$export$885efcc08143a987;
|
|
42
47
|
var $eb2fc0ee655eff6b$export$f6d480ae1e56eba0;
|
43
48
|
var $eb2fc0ee655eff6b$export$a4ea780a9064d7f9;
|
44
49
|
var $eb2fc0ee655eff6b$export$3ab8a3dc7f0563d;
|
50
|
+
var $eb2fc0ee655eff6b$export$5354c9be7ada5f83;
|
45
51
|
var $eb2fc0ee655eff6b$export$2963225c91179589;
|
46
52
|
var $eb2fc0ee655eff6b$export$127df0b7290eb8ef;
|
53
|
+
var $eb2fc0ee655eff6b$export$24fb860d16dd2d3f;
|
54
|
+
var $eb2fc0ee655eff6b$export$9ba23707a252cdd4;
|
47
55
|
var $eb2fc0ee655eff6b$export$94d2bcc94afabd89;
|
48
56
|
var $eb2fc0ee655eff6b$export$7f44db659563c8f4;
|
57
|
+
var $eb2fc0ee655eff6b$export$9cde5aecff012641;
|
58
|
+
var $eb2fc0ee655eff6b$export$a872a8c78b26c9e0;
|
49
59
|
var $eb2fc0ee655eff6b$export$11b8bc81fe551057;
|
50
60
|
var $eb2fc0ee655eff6b$export$79f9a5e9dd010c8d;
|
51
61
|
var $eb2fc0ee655eff6b$export$51ec27881a1e3928;
|
@@ -57,10 +67,15 @@ $eb2fc0ee655eff6b$export$885efcc08143a987 = "spectrum-FieldLabel--alignEnd_d2db1
|
|
57
67
|
$eb2fc0ee655eff6b$export$f6d480ae1e56eba0 = "spectrum-Field_d2db1f";
|
58
68
|
$eb2fc0ee655eff6b$export$a4ea780a9064d7f9 = "spectrum-Field--positionTop_d2db1f";
|
59
69
|
$eb2fc0ee655eff6b$export$3ab8a3dc7f0563d = "spectrum-Field-field_d2db1f";
|
70
|
+
$eb2fc0ee655eff6b$export$5354c9be7ada5f83 = "spectrum-Field--alignEnd_d2db1f";
|
60
71
|
$eb2fc0ee655eff6b$export$2963225c91179589 = "spectrum-Field--positionSide_d2db1f";
|
61
72
|
$eb2fc0ee655eff6b$export$127df0b7290eb8ef = "spectrum-Field-wrapper_d2db1f";
|
73
|
+
$eb2fc0ee655eff6b$export$24fb860d16dd2d3f = "spectrum-Field-contextualHelp_d2db1f";
|
74
|
+
$eb2fc0ee655eff6b$export$9ba23707a252cdd4 = "spectrum-Field--hasContextualHelp_d2db1f";
|
62
75
|
$eb2fc0ee655eff6b$export$94d2bcc94afabd89 = "spectrum-Form_d2db1f";
|
63
76
|
$eb2fc0ee655eff6b$export$7f44db659563c8f4 = "spectrum-Form--positionSide_d2db1f";
|
77
|
+
$eb2fc0ee655eff6b$export$9cde5aecff012641 = "spectrum-Field-labelCell_d2db1f";
|
78
|
+
$eb2fc0ee655eff6b$export$a872a8c78b26c9e0 = "spectrum-Field-labelWrapper_d2db1f";
|
64
79
|
$eb2fc0ee655eff6b$export$11b8bc81fe551057 = "spectrum-Form--positionTop_d2db1f";
|
65
80
|
$eb2fc0ee655eff6b$export$79f9a5e9dd010c8d = "spectrum-LabeledValue_d2db1f";
|
66
81
|
$eb2fc0ee655eff6b$export$51ec27881a1e3928 = "spectrum-Form-itemLabel_d2db1f";
|
@@ -69,46 +84,39 @@ $eb2fc0ee655eff6b$export$d35bc1e505d1ebbf = "is-disabled_d2db1f";
|
|
69
84
|
|
70
85
|
|
71
86
|
|
72
|
-
|
73
87
|
function $2a7417c2df2197f7$var$LabeledValue(props, ref) {
|
74
|
-
let { value: value , formatOptions: formatOptions
|
75
|
-
let
|
76
|
-
let
|
77
|
-
|
78
|
-
|
79
|
-
});
|
80
|
-
return(/*#__PURE__*/ ($parcel$interopDefault($3cJLQ$react)).createElement("div", {
|
81
|
-
...$3cJLQ$reactariautils.filterDOMProps(otherProps),
|
82
|
-
...styleProps,
|
83
|
-
className: $3cJLQ$reactspectrumutils.classNames((/*@__PURE__*/$parcel$interopDefault($eb2fc0ee655eff6b$exports)), 'spectrum-LabeledValue', {
|
84
|
-
[labelWrapperClass]: label
|
85
|
-
}, styleProps.className),
|
86
|
-
ref: ref
|
87
|
-
}, props.label && /*#__PURE__*/ ($parcel$interopDefault($3cJLQ$react)).createElement($3cJLQ$reactspectrumlabel.Label, {
|
88
|
-
labelPosition: labelPosition,
|
89
|
-
labelAlign: labelAlign,
|
90
|
-
elementType: "span"
|
91
|
-
}, props.label), /*#__PURE__*/ ($parcel$interopDefault($3cJLQ$react)).createElement("div", {
|
92
|
-
className: $3cJLQ$reactspectrumutils.classNames((/*@__PURE__*/$parcel$interopDefault($eb2fc0ee655eff6b$exports)), 'spectrum-Field-wrapper')
|
93
|
-
}, /*#__PURE__*/ ($parcel$interopDefault($3cJLQ$react)).createElement("div", {
|
94
|
-
className: $3cJLQ$reactspectrumutils.classNames((/*@__PURE__*/$parcel$interopDefault($eb2fc0ee655eff6b$exports)), 'spectrum-Field-field')
|
95
|
-
}, Array.isArray(value) && // @ts-ignore
|
96
|
-
/*#__PURE__*/ ($parcel$interopDefault($3cJLQ$react)).createElement($2a7417c2df2197f7$var$FormattedStringList, {
|
88
|
+
let { value: value , formatOptions: formatOptions } = props;
|
89
|
+
let domRef = $3cJLQ$reactspectrumutils.useDOMRef(ref);
|
90
|
+
let children;
|
91
|
+
if (Array.isArray(value)) // @ts-ignore
|
92
|
+
children = /*#__PURE__*/ ($parcel$interopDefault($3cJLQ$react)).createElement($2a7417c2df2197f7$var$FormattedStringList, {
|
97
93
|
value: value,
|
98
94
|
formatOptions: formatOptions
|
99
|
-
})
|
95
|
+
});
|
96
|
+
if (typeof value === 'object' && 'start' in value && typeof value.start === 'number' && typeof value.end === 'number') children = /*#__PURE__*/ ($parcel$interopDefault($3cJLQ$react)).createElement($2a7417c2df2197f7$var$FormattedNumber, {
|
100
97
|
value: value,
|
101
98
|
formatOptions: formatOptions
|
102
|
-
})
|
99
|
+
});
|
100
|
+
if (typeof value === 'object' && 'start' in value && typeof value.start !== 'number' && typeof value.end !== 'number') children = /*#__PURE__*/ ($parcel$interopDefault($3cJLQ$react)).createElement($2a7417c2df2197f7$var$FormattedDate, {
|
103
101
|
value: value,
|
104
102
|
formatOptions: formatOptions
|
105
|
-
})
|
103
|
+
});
|
104
|
+
if (typeof value === 'number') children = /*#__PURE__*/ ($parcel$interopDefault($3cJLQ$react)).createElement($2a7417c2df2197f7$var$FormattedNumber, {
|
106
105
|
value: value,
|
107
106
|
formatOptions: formatOptions
|
108
|
-
})
|
107
|
+
});
|
108
|
+
if (typeof value === 'object' && ('calendar' in value || 'hour' in value) || value instanceof Date) children = /*#__PURE__*/ ($parcel$interopDefault($3cJLQ$react)).createElement($2a7417c2df2197f7$var$FormattedDate, {
|
109
109
|
value: value,
|
110
110
|
formatOptions: formatOptions
|
111
|
-
})
|
111
|
+
});
|
112
|
+
if (typeof value === 'string') children = value;
|
113
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($3cJLQ$react)).createElement($3cJLQ$reactspectrumlabel.Field, {
|
114
|
+
...props,
|
115
|
+
wrapperProps: $3cJLQ$reactariautils.filterDOMProps(props),
|
116
|
+
ref: domRef,
|
117
|
+
elementType: "span",
|
118
|
+
wrapperClassName: $3cJLQ$reactspectrumutils.classNames((/*@__PURE__*/$parcel$interopDefault($eb2fc0ee655eff6b$exports)), 'spectrum-LabeledValue')
|
119
|
+
}, /*#__PURE__*/ ($parcel$interopDefault($3cJLQ$react)).createElement("span", null, children)));
|
112
120
|
}
|
113
121
|
function $2a7417c2df2197f7$var$FormattedStringList(props) {
|
114
122
|
let stringFormatter = $3cJLQ$reactariai18n.useListFormatter(props.formatOptions);
|
package/dist/main.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AEAA,GAAqC;AACrC,GAAmD;AACnD,GAAkD;AAClD,GAA+C;AAC/C,GAAgC;AAChC,GAA6C;AAC7C,GAAsC;AACtC,GAA8C;AAC9C,GAAwC;AACxC,GAA+B;AAC/B,GAA6C;AAC7C,GAA4C;AAC5C,GAAuC;AACvC,GAAyC;AACzC,GAA6B;AAd7B,wCAAqC,GAAG,CAA4B;AACpE,yCAAmD,GAAG,CAA0C;AAChG,yCAAkD,GAAG,CAAyC;AAC9F,yCAA+C,GAAG,CAAsC;AACxF,yCAAgC,GAAG,CAAuB;AAC1D,yCAA6C,GAAG,CAAoC;AACpF,wCAAsC,GAAG,CAA6B;AACtE,yCAA8C,GAAG,CAAqC;AACtF,yCAAwC,GAAG,CAA+B;AAC1E,yCAA+B,GAAG,CAAsB;AACxD,yCAA6C,GAAG,CAAoC;AACpF,yCAA4C,GAAG,CAAmC;AAClF,y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C;QAAA,SAAS,EAAE,CAAM;QAAE,SAAS,EAAE,CAAO;IAAA,CAAC;SACzC,EAAE,EAAE,CAAU,aAAI,KAAK,EAC5B,MAAM,CAAC,CAAC;QAAA,IAAI,EAAE,CAAS;QAAE,KAAK,EAAE,CAAM;QAAE,GAAG,EAAE,CAAS;QAAE,IAAI,EAAE,CAAS;QAAE,MAAM,EAAE,CAAS;QAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ;QAAE,YAAY,EAAE,CAAO;IAAA,CAAC;SACvI,EAAE,EAAE,CAAM,SAAI,KAAK,IAAI,CAAM,SAAI,KAAK,EAC3C,MAAM,CAAC,CAAC;QAAA,SAAS,EAAE,CAAM;QAAE,SAAS,EAAE,CAAO;IAAA,CAAC;SACzC,EAAE,EAAE,CAAM,SAAI,KAAK,EACxB,MAAM,CAAC,CAAC;QAAA,SAAS,EAAE,CAAO;IAAA,CAAC;SAE3B,MAAM,CAAC,CAAC;QAAA,SAAS,EAAE,CAAM;IAAA,CAAC;AAE9B,CAAC;SAEQ,kCAAY,CAAC,KAAW,EAAE,CAAC;IAClC,GAAG,CAAC,IAAI,GAAG,kCAAK,CAAC,6CAAgB;IAEjC,MAAM,CAAC,+CAAkB,CAAC,IAAI,EAAE,KAAK;AACvC,CAAC;AAED,EAEG,AAFH;;CAEG,AAFH,EAEG,CACH,GAAG,CAAC,yCAAa,iBAAG,sCAAK,CAAC,UAAU,CAAC,kCAAY","sources":["packages/@react-spectrum/labeledvalue/src/index.ts","packages/@react-spectrum/labeledvalue/src/LabeledValue.tsx","packages/@adobe/spectrum-css-temp/components/fieldlabel/vars.css"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/// <reference types=\"css-module-types\" />\n\nexport type {SpectrumLabeledValueProps} from './LabeledValue';\nexport {LabeledValue} from './LabeledValue';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CalendarDate, CalendarDateTime, getLocalTimeZone, Time, toCalendarDateTime, today, ZonedDateTime} from '@internationalized/date';\nimport {classNames} from '@react-spectrum/utils';\nimport type {DOMProps, RangeValue, SpectrumLabelableProps, StyleProps} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {Label} from '@react-spectrum/label';\nimport labelStyles from '@adobe/spectrum-css-temp/components/fieldlabel/vars.css';\nimport React, {ReactNode, RefObject} from 'react';\nimport {useDateFormatter, useListFormatter, useNumberFormatter} from '@react-aria/i18n';\nimport {useStyleProps} from '@react-spectrum/utils';\n\n// NOTE: the types here need to be synchronized with the ones in docs/types.ts, which are simpler so the documentation generator can handle them.\n\nexport interface LabeledValueBaseProps extends DOMProps, StyleProps, Omit<SpectrumLabelableProps, 'necessityIndicator' | 'isRequired'>, DOMProps {\n /** The content to display as the label. */\n label: ReactNode\n}\n\ntype NumberValue = number | RangeValue<number>;\ninterface NumberProps<T extends NumberValue> {\n /** The value to display. */\n value: T,\n /** Formatting options for the value. */\n formatOptions?: Intl.NumberFormatOptions\n}\n\nexport type DateTime = Date | CalendarDate | CalendarDateTime | ZonedDateTime | Time;\ntype RangeDateTime = RangeValue<DateTime>;\ntype DateTimeValue = DateTime | RangeDateTime;\ninterface DateProps<T extends DateTimeValue> {\n /** The value to display. */\n value: T,\n /** Formatting options for the value. */\n formatOptions?: Intl.DateTimeFormatOptions\n}\n\ninterface StringProps<T extends string> {\n /** The value to display. */\n value: T,\n /** Formatting options for the value. */\n formatOptions?: never\n}\n\ninterface StringListProps<T extends string[]> {\n /** The value to display. */\n value: T,\n /** Formatting options for the value. */\n // @ts-ignore\n formatOptions?: Intl.ListFormatOptions\n}\n\ntype LabeledValueProps<T> =\n T extends NumberValue ? NumberProps<T> :\n T extends DateTimeValue ? DateProps<T> :\n T extends string[] ? StringListProps<T> :\n T extends string ? StringProps<T> :\n never;\n\ntype SpectrumLabeledValueTypes = string[] | string | Date | CalendarDate | CalendarDateTime | ZonedDateTime | Time | number | RangeValue<number> | RangeValue<DateTime>;\nexport type SpectrumLabeledValueProps<T> = LabeledValueProps<T> & LabeledValueBaseProps;\n\nfunction LabeledValue<T extends SpectrumLabeledValueTypes>(props: SpectrumLabeledValueProps<T>, ref: RefObject<HTMLDivElement>) {\n let {\n value,\n formatOptions,\n labelPosition,\n labelAlign,\n label,\n ...otherProps\n } = props;\n let {styleProps} = useStyleProps(otherProps);\n let labelWrapperClass = classNames(\n labelStyles,\n 'spectrum-Field',\n {\n 'spectrum-Field--positionTop': labelPosition === 'top',\n 'spectrum-Field--positionSide': labelPosition === 'side'\n }\n );\n\n return (\n <div\n {...filterDOMProps(otherProps)}\n {...styleProps}\n className={classNames(labelStyles, 'spectrum-LabeledValue', {[labelWrapperClass]: label}, styleProps.className)}\n ref={ref}>\n {props.label &&\n <Label\n labelPosition={labelPosition}\n labelAlign={labelAlign}\n elementType=\"span\">\n {props.label}\n </Label>}\n <div\n className={classNames(labelStyles, 'spectrum-Field-wrapper')}>\n <div className={classNames(labelStyles, 'spectrum-Field-field')}>\n {Array.isArray(value) &&\n // @ts-ignore\n <FormattedStringList value={value} formatOptions={formatOptions as Intl.ListFormatOptions} />}\n\n {typeof value === 'object' && 'start' in value && typeof value.start === 'number' && typeof value.end === 'number' &&\n <FormattedNumber value={value as NumberValue} formatOptions={formatOptions as Intl.NumberFormatOptions} />}\n\n {typeof value === 'object' && 'start' in value && typeof value.start !== 'number' && typeof value.end !== 'number' &&\n <FormattedDate value={value as DateTimeValue} formatOptions={formatOptions as Intl.DateTimeFormatOptions} />}\n\n {typeof value === 'number' &&\n <FormattedNumber value={value} formatOptions={formatOptions as Intl.NumberFormatOptions} />}\n\n {(typeof value === 'object' && ('calendar' in value || 'hour' in value) || (value instanceof Date)) &&\n <FormattedDate value={value} formatOptions={formatOptions as Intl.DateTimeFormatOptions} />}\n\n {typeof value === 'string' &&\n value}\n </div>\n </div>\n </div>\n );\n}\n\nfunction FormattedStringList<T extends string[]>(props: StringListProps<T>) {\n let stringFormatter = useListFormatter(props.formatOptions);\n\n return (\n <>{stringFormatter.format(props.value)}</>\n );\n}\n\nfunction FormattedNumber<T extends NumberValue>(props: NumberProps<T>) {\n let numberFormatter = useNumberFormatter(props.formatOptions);\n let value = props.value;\n\n if (typeof value === 'object') {\n return <>{numberFormatter.formatRange(value.start, value.end)}</>;\n }\n\n return <>{numberFormatter.format(value)}</>;\n}\n\nfunction FormattedDate<T extends DateTimeValue>(props: DateProps<T>) {\n let {value, formatOptions} = props;\n if (!formatOptions) {\n formatOptions = getDefaultFormatOptions('start' in value ? value.start : value);\n }\n\n let dateFormatter = useDateFormatter(formatOptions);\n let timeZone = dateFormatter.resolvedOptions().timeZone || getLocalTimeZone();\n let final: Date;\n\n if ('start' in value && 'end' in value) {\n let start = value.start;\n let end = value.end;\n\n start = convertDateTime(start, timeZone);\n end = convertDateTime(end, timeZone);\n\n return <>{dateFormatter.formatRange(start, end)}</>;\n }\n\n final = convertDateTime(value, timeZone);\n return <>{dateFormatter.format(final)}</>;\n}\n\nfunction convertDateTime(value: DateTime, timeZone: any) {\n if ('timeZone' in value) {\n return value.toDate();\n } else if ('calendar' in value) {\n return value.toDate(timeZone);\n } else if (!(value instanceof Date)) {\n return convertValue(value).toDate(timeZone);\n }\n\n return value;\n}\n\nfunction getDefaultFormatOptions(value: DateTime): Intl.DateTimeFormatOptions {\n if (value instanceof Date) {\n return {dateStyle: 'long', timeStyle: 'short'};\n } else if ('timeZone' in value) {\n return {year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', timeZone: value.timeZone, timeZoneName: 'short'};\n } else if ('hour' in value && 'year' in value) {\n return {dateStyle: 'long', timeStyle: 'short'};\n } else if ('hour' in value) {\n return {timeStyle: 'short'};\n } else {\n return {dateStyle: 'long'};\n }\n}\n\nfunction convertValue(value: Time) {\n let date = today(getLocalTimeZone());\n\n return toCalendarDateTime(date, value);\n}\n\n/**\n * A LabeledValue displays a non-editable value with a label. It formats numbers, dates, times, and lists according to the user's locale.\n */\nlet _LabeledValue = React.forwardRef(LabeledValue);\nexport {_LabeledValue as LabeledValue};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n@import './index.css';\n@import './skin.css';\n"],"names":[],"version":3,"file":"main.js.map"}
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AEAA,GAAqC;AACrC,GAAmD;AACnD,GAAkD;AAClD,GAA+C;AAC/C,GAAgC;AAChC,GAA6C;AAC7C,GAAsC;AACtC,GAA0C;AAC1C,GAA8C;AAC9C,GAAwC;AACxC,GAA+C;AAC/C,GAAmD;AACnD,GAA+B;AAC/B,GAA6C;AAC7C,GAA0C;AAC1C,GAA6C;AAC7C,GAA4C;AAC5C,GAAuC;AACvC,GAAyC;AACzC,GAA6B;AAnB7B,wCAAqC,GAAG,CAA4B;A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M,CAAC,KAAK;AACd,CAAC;SAEQ,6CAAuB,CAAC,KAAe,EAA8B,CAAC;IAC7E,EAAE,EAAE,KAAK,YAAY,IAAI,EACvB,MAAM,CAAC,CAAC;QAAA,SAAS,EAAE,CAAM;QAAE,SAAS,EAAE,CAAO;IAAA,CAAC;SACzC,EAAE,EAAE,CAAU,aAAI,KAAK,EAC5B,MAAM,CAAC,CAAC;QAAA,IAAI,EAAE,CAAS;QAAE,KAAK,EAAE,CAAM;QAAE,GAAG,EAAE,CAAS;QAAE,IAAI,EAAE,CAAS;QAAE,MAAM,EAAE,CAAS;QAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ;QAAE,YAAY,EAAE,CAAO;IAAA,CAAC;SACvI,EAAE,EAAE,CAAM,SAAI,KAAK,IAAI,CAAM,SAAI,KAAK,EAC3C,MAAM,CAAC,CAAC;QAAA,SAAS,EAAE,CAAM;QAAE,SAAS,EAAE,CAAO;IAAA,CAAC;SACzC,EAAE,EAAE,CAAM,SAAI,KAAK,EACxB,MAAM,CAAC,CAAC;QAAA,SAAS,EAAE,CAAO;IAAA,CAAC;SAE3B,MAAM,CAAC,CAAC;QAAA,SAAS,EAAE,CAAM;IAAA,CAAC;AAE9B,CAAC;SAEQ,kCAAY,CAAC,KAAW,EAAE,CAAC;IAClC,GAAG,CAAC,IAAI,GAAG,kCAAK,CAAC,6CAAgB;IAEjC,MAAM,CAAC,+CAAkB,CAAC,IAAI,EAAE,KAAK;AACvC,CAAC;AAED,EAEG,AAFH;;CAEG,AAFH,EAEG,CACH,GAAG,CAAC,yCAAa,iBAAG,sCAAK,CAAC,UAAU,CAAC,kCAAY","sources":["packages/@react-spectrum/labeledvalue/src/index.ts","packages/@react-spectrum/labeledvalue/src/LabeledValue.tsx","packages/@adobe/spectrum-css-temp/components/fieldlabel/vars.css"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/// <reference types=\"css-module-types\" />\n\nexport type {SpectrumLabeledValueProps} from './LabeledValue';\nexport {LabeledValue} from './LabeledValue';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CalendarDate, CalendarDateTime, getLocalTimeZone, Time, toCalendarDateTime, today, ZonedDateTime} from '@internationalized/date';\nimport {classNames, useDOMRef} from '@react-spectrum/utils';\nimport type {DOMProps, DOMRef, RangeValue, SpectrumLabelableProps, StyleProps} from '@react-types/shared';\nimport {Field} from '@react-spectrum/label';\nimport {filterDOMProps} from '@react-aria/utils';\nimport labelStyles from '@adobe/spectrum-css-temp/components/fieldlabel/vars.css';\nimport React, {ReactNode} from 'react';\nimport {useDateFormatter, useListFormatter, useNumberFormatter} from '@react-aria/i18n';\n\n// NOTE: the types here need to be synchronized with the ones in docs/types.ts, which are simpler so the documentation generator can handle them.\n\nexport interface LabeledValueBaseProps extends DOMProps, StyleProps, Omit<SpectrumLabelableProps, 'necessityIndicator' | 'isRequired'>, DOMProps {\n /** The content to display as the label. */\n label: ReactNode\n}\n\ntype NumberValue = number | RangeValue<number>;\ninterface NumberProps<T extends NumberValue> {\n /** The value to display. */\n value: T,\n /** Formatting options for the value. */\n formatOptions?: Intl.NumberFormatOptions\n}\n\nexport type DateTime = Date | CalendarDate | CalendarDateTime | ZonedDateTime | Time;\ntype RangeDateTime = RangeValue<DateTime>;\ntype DateTimeValue = DateTime | RangeDateTime;\ninterface DateProps<T extends DateTimeValue> {\n /** The value to display. */\n value: T,\n /** Formatting options for the value. */\n formatOptions?: Intl.DateTimeFormatOptions\n}\n\ninterface StringProps<T extends string> {\n /** The value to display. */\n value: T,\n /** Formatting options for the value. */\n formatOptions?: never\n}\n\ninterface StringListProps<T extends string[]> {\n /** The value to display. */\n value: T,\n /** Formatting options for the value. */\n // @ts-ignore\n formatOptions?: Intl.ListFormatOptions\n}\n\ntype LabeledValueProps<T> =\n T extends NumberValue ? NumberProps<T> :\n T extends DateTimeValue ? DateProps<T> :\n T extends string[] ? StringListProps<T> :\n T extends string ? StringProps<T> :\n never;\n\ntype SpectrumLabeledValueTypes = string[] | string | Date | CalendarDate | CalendarDateTime | ZonedDateTime | Time | number | RangeValue<number> | RangeValue<DateTime>;\nexport type SpectrumLabeledValueProps<T> = LabeledValueProps<T> & LabeledValueBaseProps;\n\nfunction LabeledValue<T extends SpectrumLabeledValueTypes>(props: SpectrumLabeledValueProps<T>, ref: DOMRef<HTMLElement>) {\n let {\n value,\n formatOptions\n } = props;\n let domRef = useDOMRef(ref);\n\n let children;\n if (Array.isArray(value)) {\n // @ts-ignore\n children = <FormattedStringList value={value} formatOptions={formatOptions as Intl.ListFormatOptions} />;\n }\n\n if (typeof value === 'object' && 'start' in value && typeof value.start === 'number' && typeof value.end === 'number') {\n children = <FormattedNumber value={value as NumberValue} formatOptions={formatOptions as Intl.NumberFormatOptions} />;\n }\n\n if (typeof value === 'object' && 'start' in value && typeof value.start !== 'number' && typeof value.end !== 'number') {\n children = <FormattedDate value={value as DateTimeValue} formatOptions={formatOptions as Intl.DateTimeFormatOptions} />;\n }\n\n if (typeof value === 'number') {\n children = <FormattedNumber value={value} formatOptions={formatOptions as Intl.NumberFormatOptions} />;\n }\n\n if (typeof value === 'object' && ('calendar' in value || 'hour' in value) || (value instanceof Date)) {\n children = <FormattedDate value={value} formatOptions={formatOptions as Intl.DateTimeFormatOptions} />;\n }\n\n if (typeof value === 'string') {\n children = value;\n }\n\n return (\n <Field {...props as any} wrapperProps={filterDOMProps(props as any)} ref={domRef} elementType=\"span\" wrapperClassName={classNames(labelStyles, 'spectrum-LabeledValue')}>\n <span>{children}</span>\n </Field>\n );\n}\n\nfunction FormattedStringList<T extends string[]>(props: StringListProps<T>) {\n let stringFormatter = useListFormatter(props.formatOptions);\n\n return (\n <>{stringFormatter.format(props.value)}</>\n );\n}\n\nfunction FormattedNumber<T extends NumberValue>(props: NumberProps<T>) {\n let numberFormatter = useNumberFormatter(props.formatOptions);\n let value = props.value;\n\n if (typeof value === 'object') {\n return <>{numberFormatter.formatRange(value.start, value.end)}</>;\n }\n\n return <>{numberFormatter.format(value)}</>;\n}\n\nfunction FormattedDate<T extends DateTimeValue>(props: DateProps<T>) {\n let {value, formatOptions} = props;\n if (!formatOptions) {\n formatOptions = getDefaultFormatOptions('start' in value ? value.start : value);\n }\n\n let dateFormatter = useDateFormatter(formatOptions);\n let timeZone = dateFormatter.resolvedOptions().timeZone || getLocalTimeZone();\n let final: Date;\n\n if ('start' in value && 'end' in value) {\n let start = value.start;\n let end = value.end;\n\n start = convertDateTime(start, timeZone);\n end = convertDateTime(end, timeZone);\n\n return <>{dateFormatter.formatRange(start, end)}</>;\n }\n\n final = convertDateTime(value, timeZone);\n return <>{dateFormatter.format(final)}</>;\n}\n\nfunction convertDateTime(value: DateTime, timeZone: any) {\n if ('timeZone' in value) {\n return value.toDate();\n } else if ('calendar' in value) {\n return value.toDate(timeZone);\n } else if (!(value instanceof Date)) {\n return convertValue(value).toDate(timeZone);\n }\n\n return value;\n}\n\nfunction getDefaultFormatOptions(value: DateTime): Intl.DateTimeFormatOptions {\n if (value instanceof Date) {\n return {dateStyle: 'long', timeStyle: 'short'};\n } else if ('timeZone' in value) {\n return {year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', timeZone: value.timeZone, timeZoneName: 'short'};\n } else if ('hour' in value && 'year' in value) {\n return {dateStyle: 'long', timeStyle: 'short'};\n } else if ('hour' in value) {\n return {timeStyle: 'short'};\n } else {\n return {dateStyle: 'long'};\n }\n}\n\nfunction convertValue(value: Time) {\n let date = today(getLocalTimeZone());\n\n return toCalendarDateTime(date, value);\n}\n\n/**\n * A LabeledValue displays a non-editable value with a label. It formats numbers, dates, times, and lists according to the user's locale.\n */\nlet _LabeledValue = React.forwardRef(LabeledValue);\nexport {_LabeledValue as LabeledValue};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n@import './index.css';\n@import './skin.css';\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import "./main.css";
|
2
2
|
import {getLocalTimeZone as $3xnHL$getLocalTimeZone, today as $3xnHL$today, toCalendarDateTime as $3xnHL$toCalendarDateTime} from "@internationalized/date";
|
3
|
-
import {
|
3
|
+
import {useDOMRef as $3xnHL$useDOMRef, classNames as $3xnHL$classNames} from "@react-spectrum/utils";
|
4
|
+
import {Field as $3xnHL$Field} from "@react-spectrum/label";
|
4
5
|
import {filterDOMProps as $3xnHL$filterDOMProps} from "@react-aria/utils";
|
5
|
-
import {Label as $3xnHL$Label} from "@react-spectrum/label";
|
6
6
|
import $3xnHL$react from "react";
|
7
7
|
import {useListFormatter as $3xnHL$useListFormatter, useNumberFormatter as $3xnHL$useNumberFormatter, useDateFormatter as $3xnHL$useDateFormatter} from "@react-aria/i18n";
|
8
8
|
|
@@ -25,10 +25,15 @@ $parcel$export($cd231e464c886c86$exports, "spectrum-FieldLabel--alignEnd", () =>
|
|
25
25
|
$parcel$export($cd231e464c886c86$exports, "spectrum-Field", () => $cd231e464c886c86$export$f6d480ae1e56eba0, (v) => $cd231e464c886c86$export$f6d480ae1e56eba0 = v);
|
26
26
|
$parcel$export($cd231e464c886c86$exports, "spectrum-Field--positionTop", () => $cd231e464c886c86$export$a4ea780a9064d7f9, (v) => $cd231e464c886c86$export$a4ea780a9064d7f9 = v);
|
27
27
|
$parcel$export($cd231e464c886c86$exports, "spectrum-Field-field", () => $cd231e464c886c86$export$3ab8a3dc7f0563d, (v) => $cd231e464c886c86$export$3ab8a3dc7f0563d = v);
|
28
|
+
$parcel$export($cd231e464c886c86$exports, "spectrum-Field--alignEnd", () => $cd231e464c886c86$export$5354c9be7ada5f83, (v) => $cd231e464c886c86$export$5354c9be7ada5f83 = v);
|
28
29
|
$parcel$export($cd231e464c886c86$exports, "spectrum-Field--positionSide", () => $cd231e464c886c86$export$2963225c91179589, (v) => $cd231e464c886c86$export$2963225c91179589 = v);
|
29
30
|
$parcel$export($cd231e464c886c86$exports, "spectrum-Field-wrapper", () => $cd231e464c886c86$export$127df0b7290eb8ef, (v) => $cd231e464c886c86$export$127df0b7290eb8ef = v);
|
31
|
+
$parcel$export($cd231e464c886c86$exports, "spectrum-Field-contextualHelp", () => $cd231e464c886c86$export$24fb860d16dd2d3f, (v) => $cd231e464c886c86$export$24fb860d16dd2d3f = v);
|
32
|
+
$parcel$export($cd231e464c886c86$exports, "spectrum-Field--hasContextualHelp", () => $cd231e464c886c86$export$9ba23707a252cdd4, (v) => $cd231e464c886c86$export$9ba23707a252cdd4 = v);
|
30
33
|
$parcel$export($cd231e464c886c86$exports, "spectrum-Form", () => $cd231e464c886c86$export$94d2bcc94afabd89, (v) => $cd231e464c886c86$export$94d2bcc94afabd89 = v);
|
31
34
|
$parcel$export($cd231e464c886c86$exports, "spectrum-Form--positionSide", () => $cd231e464c886c86$export$7f44db659563c8f4, (v) => $cd231e464c886c86$export$7f44db659563c8f4 = v);
|
35
|
+
$parcel$export($cd231e464c886c86$exports, "spectrum-Field-labelCell", () => $cd231e464c886c86$export$9cde5aecff012641, (v) => $cd231e464c886c86$export$9cde5aecff012641 = v);
|
36
|
+
$parcel$export($cd231e464c886c86$exports, "spectrum-Field-labelWrapper", () => $cd231e464c886c86$export$a872a8c78b26c9e0, (v) => $cd231e464c886c86$export$a872a8c78b26c9e0 = v);
|
32
37
|
$parcel$export($cd231e464c886c86$exports, "spectrum-Form--positionTop", () => $cd231e464c886c86$export$11b8bc81fe551057, (v) => $cd231e464c886c86$export$11b8bc81fe551057 = v);
|
33
38
|
$parcel$export($cd231e464c886c86$exports, "spectrum-LabeledValue", () => $cd231e464c886c86$export$79f9a5e9dd010c8d, (v) => $cd231e464c886c86$export$79f9a5e9dd010c8d = v);
|
34
39
|
$parcel$export($cd231e464c886c86$exports, "spectrum-Form-itemLabel", () => $cd231e464c886c86$export$51ec27881a1e3928, (v) => $cd231e464c886c86$export$51ec27881a1e3928 = v);
|
@@ -40,10 +45,15 @@ var $cd231e464c886c86$export$885efcc08143a987;
|
|
40
45
|
var $cd231e464c886c86$export$f6d480ae1e56eba0;
|
41
46
|
var $cd231e464c886c86$export$a4ea780a9064d7f9;
|
42
47
|
var $cd231e464c886c86$export$3ab8a3dc7f0563d;
|
48
|
+
var $cd231e464c886c86$export$5354c9be7ada5f83;
|
43
49
|
var $cd231e464c886c86$export$2963225c91179589;
|
44
50
|
var $cd231e464c886c86$export$127df0b7290eb8ef;
|
51
|
+
var $cd231e464c886c86$export$24fb860d16dd2d3f;
|
52
|
+
var $cd231e464c886c86$export$9ba23707a252cdd4;
|
45
53
|
var $cd231e464c886c86$export$94d2bcc94afabd89;
|
46
54
|
var $cd231e464c886c86$export$7f44db659563c8f4;
|
55
|
+
var $cd231e464c886c86$export$9cde5aecff012641;
|
56
|
+
var $cd231e464c886c86$export$a872a8c78b26c9e0;
|
47
57
|
var $cd231e464c886c86$export$11b8bc81fe551057;
|
48
58
|
var $cd231e464c886c86$export$79f9a5e9dd010c8d;
|
49
59
|
var $cd231e464c886c86$export$51ec27881a1e3928;
|
@@ -55,10 +65,15 @@ $cd231e464c886c86$export$885efcc08143a987 = "spectrum-FieldLabel--alignEnd_d2db1
|
|
55
65
|
$cd231e464c886c86$export$f6d480ae1e56eba0 = "spectrum-Field_d2db1f";
|
56
66
|
$cd231e464c886c86$export$a4ea780a9064d7f9 = "spectrum-Field--positionTop_d2db1f";
|
57
67
|
$cd231e464c886c86$export$3ab8a3dc7f0563d = "spectrum-Field-field_d2db1f";
|
68
|
+
$cd231e464c886c86$export$5354c9be7ada5f83 = "spectrum-Field--alignEnd_d2db1f";
|
58
69
|
$cd231e464c886c86$export$2963225c91179589 = "spectrum-Field--positionSide_d2db1f";
|
59
70
|
$cd231e464c886c86$export$127df0b7290eb8ef = "spectrum-Field-wrapper_d2db1f";
|
71
|
+
$cd231e464c886c86$export$24fb860d16dd2d3f = "spectrum-Field-contextualHelp_d2db1f";
|
72
|
+
$cd231e464c886c86$export$9ba23707a252cdd4 = "spectrum-Field--hasContextualHelp_d2db1f";
|
60
73
|
$cd231e464c886c86$export$94d2bcc94afabd89 = "spectrum-Form_d2db1f";
|
61
74
|
$cd231e464c886c86$export$7f44db659563c8f4 = "spectrum-Form--positionSide_d2db1f";
|
75
|
+
$cd231e464c886c86$export$9cde5aecff012641 = "spectrum-Field-labelCell_d2db1f";
|
76
|
+
$cd231e464c886c86$export$a872a8c78b26c9e0 = "spectrum-Field-labelWrapper_d2db1f";
|
62
77
|
$cd231e464c886c86$export$11b8bc81fe551057 = "spectrum-Form--positionTop_d2db1f";
|
63
78
|
$cd231e464c886c86$export$79f9a5e9dd010c8d = "spectrum-LabeledValue_d2db1f";
|
64
79
|
$cd231e464c886c86$export$51ec27881a1e3928 = "spectrum-Form-itemLabel_d2db1f";
|
@@ -67,46 +82,39 @@ $cd231e464c886c86$export$d35bc1e505d1ebbf = "is-disabled_d2db1f";
|
|
67
82
|
|
68
83
|
|
69
84
|
|
70
|
-
|
71
85
|
function $3e9971be431adb24$var$LabeledValue(props, ref) {
|
72
|
-
let { value: value , formatOptions: formatOptions
|
73
|
-
let
|
74
|
-
let
|
75
|
-
|
76
|
-
|
77
|
-
});
|
78
|
-
return(/*#__PURE__*/ $3xnHL$react.createElement("div", {
|
79
|
-
...$3xnHL$filterDOMProps(otherProps),
|
80
|
-
...styleProps,
|
81
|
-
className: $3xnHL$classNames((/*@__PURE__*/$parcel$interopDefault($cd231e464c886c86$exports)), 'spectrum-LabeledValue', {
|
82
|
-
[labelWrapperClass]: label
|
83
|
-
}, styleProps.className),
|
84
|
-
ref: ref
|
85
|
-
}, props.label && /*#__PURE__*/ $3xnHL$react.createElement($3xnHL$Label, {
|
86
|
-
labelPosition: labelPosition,
|
87
|
-
labelAlign: labelAlign,
|
88
|
-
elementType: "span"
|
89
|
-
}, props.label), /*#__PURE__*/ $3xnHL$react.createElement("div", {
|
90
|
-
className: $3xnHL$classNames((/*@__PURE__*/$parcel$interopDefault($cd231e464c886c86$exports)), 'spectrum-Field-wrapper')
|
91
|
-
}, /*#__PURE__*/ $3xnHL$react.createElement("div", {
|
92
|
-
className: $3xnHL$classNames((/*@__PURE__*/$parcel$interopDefault($cd231e464c886c86$exports)), 'spectrum-Field-field')
|
93
|
-
}, Array.isArray(value) && // @ts-ignore
|
94
|
-
/*#__PURE__*/ $3xnHL$react.createElement($3e9971be431adb24$var$FormattedStringList, {
|
86
|
+
let { value: value , formatOptions: formatOptions } = props;
|
87
|
+
let domRef = $3xnHL$useDOMRef(ref);
|
88
|
+
let children;
|
89
|
+
if (Array.isArray(value)) // @ts-ignore
|
90
|
+
children = /*#__PURE__*/ $3xnHL$react.createElement($3e9971be431adb24$var$FormattedStringList, {
|
95
91
|
value: value,
|
96
92
|
formatOptions: formatOptions
|
97
|
-
})
|
93
|
+
});
|
94
|
+
if (typeof value === 'object' && 'start' in value && typeof value.start === 'number' && typeof value.end === 'number') children = /*#__PURE__*/ $3xnHL$react.createElement($3e9971be431adb24$var$FormattedNumber, {
|
98
95
|
value: value,
|
99
96
|
formatOptions: formatOptions
|
100
|
-
})
|
97
|
+
});
|
98
|
+
if (typeof value === 'object' && 'start' in value && typeof value.start !== 'number' && typeof value.end !== 'number') children = /*#__PURE__*/ $3xnHL$react.createElement($3e9971be431adb24$var$FormattedDate, {
|
101
99
|
value: value,
|
102
100
|
formatOptions: formatOptions
|
103
|
-
})
|
101
|
+
});
|
102
|
+
if (typeof value === 'number') children = /*#__PURE__*/ $3xnHL$react.createElement($3e9971be431adb24$var$FormattedNumber, {
|
104
103
|
value: value,
|
105
104
|
formatOptions: formatOptions
|
106
|
-
})
|
105
|
+
});
|
106
|
+
if (typeof value === 'object' && ('calendar' in value || 'hour' in value) || value instanceof Date) children = /*#__PURE__*/ $3xnHL$react.createElement($3e9971be431adb24$var$FormattedDate, {
|
107
107
|
value: value,
|
108
108
|
formatOptions: formatOptions
|
109
|
-
})
|
109
|
+
});
|
110
|
+
if (typeof value === 'string') children = value;
|
111
|
+
return(/*#__PURE__*/ $3xnHL$react.createElement($3xnHL$Field, {
|
112
|
+
...props,
|
113
|
+
wrapperProps: $3xnHL$filterDOMProps(props),
|
114
|
+
ref: domRef,
|
115
|
+
elementType: "span",
|
116
|
+
wrapperClassName: $3xnHL$classNames((/*@__PURE__*/$parcel$interopDefault($cd231e464c886c86$exports)), 'spectrum-LabeledValue')
|
117
|
+
}, /*#__PURE__*/ $3xnHL$react.createElement("span", null, children)));
|
110
118
|
}
|
111
119
|
function $3e9971be431adb24$var$FormattedStringList(props) {
|
112
120
|
let stringFormatter = $3xnHL$useListFormatter(props.formatOptions);
|
package/dist/module.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AEAA,GAAqC;AACrC,GAAmD;AACnD,GAAkD;AAClD,GAA+C;AAC/C,GAAgC;AAChC,GAA6C;AAC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E,KAAK;AACvC,CAAC;AAED,EAEG,AAFH;;CAEG,AAFH,EAEG,CACH,GAAG,CAAC,yCAAa,iBAAG,YAAK,CAAC,UAAU,CAAC,kCAAY","sources":["packages/@react-spectrum/labeledvalue/src/index.ts","packages/@react-spectrum/labeledvalue/src/LabeledValue.tsx","packages/@adobe/spectrum-css-temp/components/fieldlabel/vars.css"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/// <reference types=\"css-module-types\" />\n\nexport type {SpectrumLabeledValueProps} from './LabeledValue';\nexport {LabeledValue} from './LabeledValue';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CalendarDate, CalendarDateTime, getLocalTimeZone, Time, toCalendarDateTime, today, ZonedDateTime} from '@internationalized/date';\nimport {classNames} from '@react-spectrum/utils';\nimport type {DOMProps, RangeValue, SpectrumLabelableProps, StyleProps} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {Label} from '@react-spectrum/label';\nimport labelStyles from '@adobe/spectrum-css-temp/components/fieldlabel/vars.css';\nimport React, {ReactNode, RefObject} from 'react';\nimport {useDateFormatter, useListFormatter, useNumberFormatter} from '@react-aria/i18n';\nimport {useStyleProps} from '@react-spectrum/utils';\n\n// NOTE: the types here need to be synchronized with the ones in docs/types.ts, which are simpler so the documentation generator can handle them.\n\nexport interface LabeledValueBaseProps extends DOMProps, StyleProps, Omit<SpectrumLabelableProps, 'necessityIndicator' | 'isRequired'>, DOMProps {\n /** The content to display as the label. */\n label: ReactNode\n}\n\ntype NumberValue = number | RangeValue<number>;\ninterface NumberProps<T extends NumberValue> {\n /** The value to display. */\n value: T,\n /** Formatting options for the value. */\n formatOptions?: Intl.NumberFormatOptions\n}\n\nexport type DateTime = Date | CalendarDate | CalendarDateTime | ZonedDateTime | Time;\ntype RangeDateTime = RangeValue<DateTime>;\ntype DateTimeValue = DateTime | RangeDateTime;\ninterface DateProps<T extends DateTimeValue> {\n /** The value to display. */\n value: T,\n /** Formatting options for the value. */\n formatOptions?: Intl.DateTimeFormatOptions\n}\n\ninterface StringProps<T extends string> {\n /** The value to display. */\n value: T,\n /** Formatting options for the value. */\n formatOptions?: never\n}\n\ninterface StringListProps<T extends string[]> {\n /** The value to display. */\n value: T,\n /** Formatting options for the value. */\n // @ts-ignore\n formatOptions?: Intl.ListFormatOptions\n}\n\ntype LabeledValueProps<T> =\n T extends NumberValue ? NumberProps<T> :\n T extends DateTimeValue ? DateProps<T> :\n T extends string[] ? StringListProps<T> :\n T extends string ? StringProps<T> :\n never;\n\ntype SpectrumLabeledValueTypes = string[] | string | Date | CalendarDate | CalendarDateTime | ZonedDateTime | Time | number | RangeValue<number> | RangeValue<DateTime>;\nexport type SpectrumLabeledValueProps<T> = LabeledValueProps<T> & LabeledValueBaseProps;\n\nfunction LabeledValue<T extends SpectrumLabeledValueTypes>(props: SpectrumLabeledValueProps<T>, ref: RefObject<HTMLDivElement>) {\n let {\n value,\n formatOptions,\n labelPosition,\n labelAlign,\n label,\n ...otherProps\n } = props;\n let {styleProps} = useStyleProps(otherProps);\n let labelWrapperClass = classNames(\n labelStyles,\n 'spectrum-Field',\n {\n 'spectrum-Field--positionTop': labelPosition === 'top',\n 'spectrum-Field--positionSide': labelPosition === 'side'\n }\n );\n\n return (\n <div\n {...filterDOMProps(otherProps)}\n {...styleProps}\n className={classNames(labelStyles, 'spectrum-LabeledValue', {[labelWrapperClass]: label}, styleProps.className)}\n ref={ref}>\n {props.label &&\n <Label\n labelPosition={labelPosition}\n labelAlign={labelAlign}\n elementType=\"span\">\n {props.label}\n </Label>}\n <div\n className={classNames(labelStyles, 'spectrum-Field-wrapper')}>\n <div className={classNames(labelStyles, 'spectrum-Field-field')}>\n {Array.isArray(value) &&\n // @ts-ignore\n <FormattedStringList value={value} formatOptions={formatOptions as Intl.ListFormatOptions} />}\n\n {typeof value === 'object' && 'start' in value && typeof value.start === 'number' && typeof value.end === 'number' &&\n <FormattedNumber value={value as NumberValue} formatOptions={formatOptions as Intl.NumberFormatOptions} />}\n\n {typeof value === 'object' && 'start' in value && typeof value.start !== 'number' && typeof value.end !== 'number' &&\n <FormattedDate value={value as DateTimeValue} formatOptions={formatOptions as Intl.DateTimeFormatOptions} />}\n\n {typeof value === 'number' &&\n <FormattedNumber value={value} formatOptions={formatOptions as Intl.NumberFormatOptions} />}\n\n {(typeof value === 'object' && ('calendar' in value || 'hour' in value) || (value instanceof Date)) &&\n <FormattedDate value={value} formatOptions={formatOptions as Intl.DateTimeFormatOptions} />}\n\n {typeof value === 'string' &&\n value}\n </div>\n </div>\n </div>\n );\n}\n\nfunction FormattedStringList<T extends string[]>(props: StringListProps<T>) {\n let stringFormatter = useListFormatter(props.formatOptions);\n\n return (\n <>{stringFormatter.format(props.value)}</>\n );\n}\n\nfunction FormattedNumber<T extends NumberValue>(props: NumberProps<T>) {\n let numberFormatter = useNumberFormatter(props.formatOptions);\n let value = props.value;\n\n if (typeof value === 'object') {\n return <>{numberFormatter.formatRange(value.start, value.end)}</>;\n }\n\n return <>{numberFormatter.format(value)}</>;\n}\n\nfunction FormattedDate<T extends DateTimeValue>(props: DateProps<T>) {\n let {value, formatOptions} = props;\n if (!formatOptions) {\n formatOptions = getDefaultFormatOptions('start' in value ? value.start : value);\n }\n\n let dateFormatter = useDateFormatter(formatOptions);\n let timeZone = dateFormatter.resolvedOptions().timeZone || getLocalTimeZone();\n let final: Date;\n\n if ('start' in value && 'end' in value) {\n let start = value.start;\n let end = value.end;\n\n start = convertDateTime(start, timeZone);\n end = convertDateTime(end, timeZone);\n\n return <>{dateFormatter.formatRange(start, end)}</>;\n }\n\n final = convertDateTime(value, timeZone);\n return <>{dateFormatter.format(final)}</>;\n}\n\nfunction convertDateTime(value: DateTime, timeZone: any) {\n if ('timeZone' in value) {\n return value.toDate();\n } else if ('calendar' in value) {\n return value.toDate(timeZone);\n } else if (!(value instanceof Date)) {\n return convertValue(value).toDate(timeZone);\n }\n\n return value;\n}\n\nfunction getDefaultFormatOptions(value: DateTime): Intl.DateTimeFormatOptions {\n if (value instanceof Date) {\n return {dateStyle: 'long', timeStyle: 'short'};\n } else if ('timeZone' in value) {\n return {year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', timeZone: value.timeZone, timeZoneName: 'short'};\n } else if ('hour' in value && 'year' in value) {\n return {dateStyle: 'long', timeStyle: 'short'};\n } else if ('hour' in value) {\n return {timeStyle: 'short'};\n } else {\n return {dateStyle: 'long'};\n }\n}\n\nfunction convertValue(value: Time) {\n let date = today(getLocalTimeZone());\n\n return toCalendarDateTime(date, value);\n}\n\n/**\n * A LabeledValue displays a non-editable value with a label. It formats numbers, dates, times, and lists according to the user's locale.\n */\nlet _LabeledValue = React.forwardRef(LabeledValue);\nexport {_LabeledValue as LabeledValue};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n@import './index.css';\n@import './skin.css';\n"],"names":[],"version":3,"file":"module.js.map"}
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AEAA,GAAqC;AACrC,GAAmD;AACnD,GAAkD;AAClD,GAA+C;AAC/C,GAAgC;AAChC,GAA6C;AAC7C,GAAsC;AACtC,GAA0C;AAC1C,GAA8C;AAC9C,GAAwC;AACxC,GAA+C;AAC/C,GAAmD;AACnD,GAA+B;AAC/B,GAA6C;AAC7C,GAA0C;AAC1C,GAA6C;AAC7C,GAA4C;AAC5C,GAAuC;AACvC,GAAyC;AACzC,GAA6B;AAnB7B,wCAAqC,GAAG,CAA4B;AACpE,yCAAmD,GAAG,CAA0C;AAChG,yCAAkD,GAAG,CAAyC;AAC9F,yCAA+C,GAAG,CAAsC;AACxF,yCAAgC,GAAG,CAAuB;AAC1D,yCAA6C,GAAG,CAAoC;AACpF,wCAAsC,GAAG,CAA6B;AACtE,yCAA0C,GAAG,CAAiC;AAC9E,yCAA8C,GAAG,CAAqC;AACtF,yCAAwC,GAAG,CAA+B;AAC1E,yCAA+C,GAAG,CAAsC;AACxF,yCAAmD,GAAG,CAA0C;AAChG,yCAA+B,GAAG,CAAsB;AACxD,yCAA6C,GAAG,CAAoC;AACpF,yCAA0C,GAAG,CAAiC;AAC9E,yCAA6C,GAAG,CAAoC;AACpF,yCAA4C,GAAG,CAAmC;AAClF,yCAAuC,GAAG,CAA8B;AACxE,yCAAyC,GAAG,CAAgC;AAC5E,yCAA6B,GAAG,CAAoB;;;;;SDoD3C,kCAAY,CAAsC,KAAmC,EAAE,GAAwB,EAAE,CAAC;IACzH,GAAG,CAAC,CAAC,QACH,KAAK,kBACL,aAAa,EACf,CAAC,GAAG,KAAK;IACT,GAAG,CAAC,MAAM,GAAG,gBAAS,CAAC,GAAG;IAE1B,GAAG,CAAC,QAAQ;IACZ,EAAE,EAAE,KAAK,CAAC,OAAO,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,CAAC,KAAW,EAAE,CAAC;IAClC,GAAG,CAAC,IAAI,GAAG,YAAK,CAAC,uBAAgB;IAEjC,MAAM,CAAC,yBAAkB,CAAC,IAAI,EAAE,KAAK;AACvC,CAAC;AAED,EAEG,AAFH;;CAEG,AAFH,EAEG,CACH,GAAG,CAAC,yCAAa,iBAAG,YAAK,CAAC,UAAU,CAAC,kCAAY","sources":["packages/@react-spectrum/labeledvalue/src/index.ts","packages/@react-spectrum/labeledvalue/src/LabeledValue.tsx","packages/@adobe/spectrum-css-temp/components/fieldlabel/vars.css"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/// <reference types=\"css-module-types\" />\n\nexport type {SpectrumLabeledValueProps} from './LabeledValue';\nexport {LabeledValue} from './LabeledValue';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CalendarDate, CalendarDateTime, getLocalTimeZone, Time, toCalendarDateTime, today, ZonedDateTime} from '@internationalized/date';\nimport {classNames, useDOMRef} from '@react-spectrum/utils';\nimport type {DOMProps, DOMRef, RangeValue, SpectrumLabelableProps, StyleProps} from '@react-types/shared';\nimport {Field} from '@react-spectrum/label';\nimport {filterDOMProps} from '@react-aria/utils';\nimport labelStyles from '@adobe/spectrum-css-temp/components/fieldlabel/vars.css';\nimport React, {ReactNode} from 'react';\nimport {useDateFormatter, useListFormatter, useNumberFormatter} from '@react-aria/i18n';\n\n// NOTE: the types here need to be synchronized with the ones in docs/types.ts, which are simpler so the documentation generator can handle them.\n\nexport interface LabeledValueBaseProps extends DOMProps, StyleProps, Omit<SpectrumLabelableProps, 'necessityIndicator' | 'isRequired'>, DOMProps {\n /** The content to display as the label. */\n label: ReactNode\n}\n\ntype NumberValue = number | RangeValue<number>;\ninterface NumberProps<T extends NumberValue> {\n /** The value to display. */\n value: T,\n /** Formatting options for the value. */\n formatOptions?: Intl.NumberFormatOptions\n}\n\nexport type DateTime = Date | CalendarDate | CalendarDateTime | ZonedDateTime | Time;\ntype RangeDateTime = RangeValue<DateTime>;\ntype DateTimeValue = DateTime | RangeDateTime;\ninterface DateProps<T extends DateTimeValue> {\n /** The value to display. */\n value: T,\n /** Formatting options for the value. */\n formatOptions?: Intl.DateTimeFormatOptions\n}\n\ninterface StringProps<T extends string> {\n /** The value to display. */\n value: T,\n /** Formatting options for the value. */\n formatOptions?: never\n}\n\ninterface StringListProps<T extends string[]> {\n /** The value to display. */\n value: T,\n /** Formatting options for the value. */\n // @ts-ignore\n formatOptions?: Intl.ListFormatOptions\n}\n\ntype LabeledValueProps<T> =\n T extends NumberValue ? NumberProps<T> :\n T extends DateTimeValue ? DateProps<T> :\n T extends string[] ? StringListProps<T> :\n T extends string ? StringProps<T> :\n never;\n\ntype SpectrumLabeledValueTypes = string[] | string | Date | CalendarDate | CalendarDateTime | ZonedDateTime | Time | number | RangeValue<number> | RangeValue<DateTime>;\nexport type SpectrumLabeledValueProps<T> = LabeledValueProps<T> & LabeledValueBaseProps;\n\nfunction LabeledValue<T extends SpectrumLabeledValueTypes>(props: SpectrumLabeledValueProps<T>, ref: DOMRef<HTMLElement>) {\n let {\n value,\n formatOptions\n } = props;\n let domRef = useDOMRef(ref);\n\n let children;\n if (Array.isArray(value)) {\n // @ts-ignore\n children = <FormattedStringList value={value} formatOptions={formatOptions as Intl.ListFormatOptions} />;\n }\n\n if (typeof value === 'object' && 'start' in value && typeof value.start === 'number' && typeof value.end === 'number') {\n children = <FormattedNumber value={value as NumberValue} formatOptions={formatOptions as Intl.NumberFormatOptions} />;\n }\n\n if (typeof value === 'object' && 'start' in value && typeof value.start !== 'number' && typeof value.end !== 'number') {\n children = <FormattedDate value={value as DateTimeValue} formatOptions={formatOptions as Intl.DateTimeFormatOptions} />;\n }\n\n if (typeof value === 'number') {\n children = <FormattedNumber value={value} formatOptions={formatOptions as Intl.NumberFormatOptions} />;\n }\n\n if (typeof value === 'object' && ('calendar' in value || 'hour' in value) || (value instanceof Date)) {\n children = <FormattedDate value={value} formatOptions={formatOptions as Intl.DateTimeFormatOptions} />;\n }\n\n if (typeof value === 'string') {\n children = value;\n }\n\n return (\n <Field {...props as any} wrapperProps={filterDOMProps(props as any)} ref={domRef} elementType=\"span\" wrapperClassName={classNames(labelStyles, 'spectrum-LabeledValue')}>\n <span>{children}</span>\n </Field>\n );\n}\n\nfunction FormattedStringList<T extends string[]>(props: StringListProps<T>) {\n let stringFormatter = useListFormatter(props.formatOptions);\n\n return (\n <>{stringFormatter.format(props.value)}</>\n );\n}\n\nfunction FormattedNumber<T extends NumberValue>(props: NumberProps<T>) {\n let numberFormatter = useNumberFormatter(props.formatOptions);\n let value = props.value;\n\n if (typeof value === 'object') {\n return <>{numberFormatter.formatRange(value.start, value.end)}</>;\n }\n\n return <>{numberFormatter.format(value)}</>;\n}\n\nfunction FormattedDate<T extends DateTimeValue>(props: DateProps<T>) {\n let {value, formatOptions} = props;\n if (!formatOptions) {\n formatOptions = getDefaultFormatOptions('start' in value ? value.start : value);\n }\n\n let dateFormatter = useDateFormatter(formatOptions);\n let timeZone = dateFormatter.resolvedOptions().timeZone || getLocalTimeZone();\n let final: Date;\n\n if ('start' in value && 'end' in value) {\n let start = value.start;\n let end = value.end;\n\n start = convertDateTime(start, timeZone);\n end = convertDateTime(end, timeZone);\n\n return <>{dateFormatter.formatRange(start, end)}</>;\n }\n\n final = convertDateTime(value, timeZone);\n return <>{dateFormatter.format(final)}</>;\n}\n\nfunction convertDateTime(value: DateTime, timeZone: any) {\n if ('timeZone' in value) {\n return value.toDate();\n } else if ('calendar' in value) {\n return value.toDate(timeZone);\n } else if (!(value instanceof Date)) {\n return convertValue(value).toDate(timeZone);\n }\n\n return value;\n}\n\nfunction getDefaultFormatOptions(value: DateTime): Intl.DateTimeFormatOptions {\n if (value instanceof Date) {\n return {dateStyle: 'long', timeStyle: 'short'};\n } else if ('timeZone' in value) {\n return {year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', timeZone: value.timeZone, timeZoneName: 'short'};\n } else if ('hour' in value && 'year' in value) {\n return {dateStyle: 'long', timeStyle: 'short'};\n } else if ('hour' in value) {\n return {timeStyle: 'short'};\n } else {\n return {dateStyle: 'long'};\n }\n}\n\nfunction convertValue(value: Time) {\n let date = today(getLocalTimeZone());\n\n return toCalendarDateTime(date, value);\n}\n\n/**\n * A LabeledValue displays a non-editable value with a label. It formats numbers, dates, times, and lists according to the user's locale.\n */\nlet _LabeledValue = React.forwardRef(LabeledValue);\nexport {_LabeledValue as LabeledValue};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n@import './index.css';\n@import './skin.css';\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
CHANGED
@@ -39,6 +39,6 @@ export type SpectrumLabeledValueProps<T> = LabeledValueProps<T> & LabeledValueBa
|
|
39
39
|
/**
|
40
40
|
* A LabeledValue displays a non-editable value with a label. It formats numbers, dates, times, and lists according to the user's locale.
|
41
41
|
*/
|
42
|
-
export let LabeledValue: React.ForwardRefExoticComponent<SpectrumLabeledValueProps<SpectrumLabeledValueTypes> & React.RefAttributes<
|
42
|
+
export let LabeledValue: React.ForwardRefExoticComponent<SpectrumLabeledValueProps<SpectrumLabeledValueTypes> & React.RefAttributes<import("@react-types/shared").DOMRefValue<HTMLElement>>>;
|
43
43
|
|
44
44
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"mappings":";;;
|
1
|
+
{"mappings":";;;AAuBA,+BAAuC,SAAQ,QAAQ,EAAE,UAAU,EAAE,IAAI,CAAC,sBAAsB,EAAE,oBAAoB,GAAG,YAAY,CAAC,EAAE,QAAQ;IAC9I,2CAA2C;IAC3C,KAAK,EAAE,SAAS,CAAA;CACjB;AAED,mBAAmB,MAAM,GAAG,WAAW,MAAM,CAAC,CAAC;AAC/C,sBAAsB,CAAC,SAAS,WAAW;IACzC,4BAA4B;IAC5B,KAAK,EAAE,CAAC,CAAC;IACT,wCAAwC;IACxC,aAAa,CAAC,EAAE,KAAK,mBAAmB,CAAA;CACzC;AAED,gBAAuB,IAAI,GAAG,YAAY,GAAG,gBAAgB,GAAG,aAAa,GAAG,IAAI,CAAC;AACrF,qBAAqB,WAAW,QAAQ,CAAC,CAAC;AAC1C,qBAAqB,QAAQ,GAAG,aAAa,CAAC;AAC9C,oBAAoB,CAAC,SAAS,aAAa;IACzC,4BAA4B;IAC5B,KAAK,EAAE,CAAC,CAAC;IACT,wCAAwC;IACxC,aAAa,CAAC,EAAE,KAAK,qBAAqB,CAAA;CAC3C;AAED,sBAAsB,CAAC,SAAS,MAAM;IACpC,4BAA4B;IAC5B,KAAK,EAAE,CAAC,CAAC;IACT,wCAAwC;IACxC,aAAa,CAAC,EAAE,KAAK,CAAA;CACtB;AAED,0BAA0B,CAAC,SAAS,MAAM,EAAE;IAC1C,4BAA4B;IAC5B,KAAK,EAAE,CAAC,CAAC;IACT,wCAAwC;IAExC,aAAa,CAAC,EAAE,KAAK,iBAAiB,CAAA;CACvC;AAED,uBAAuB,CAAC,IACtB,CAAC,SAAS,WAAW,GAAG,YAAY,CAAC,CAAC,GACtC,CAAC,SAAS,aAAa,GAAG,UAAU,CAAC,CAAC,GACtC,CAAC,SAAS,MAAM,EAAE,GAAG,gBAAgB,CAAC,CAAC,GACvC,CAAC,SAAS,MAAM,GAAG,YAAY,CAAC,CAAC,GACjC,KAAK,CAAC;AAER,iCAAiC,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,GAAG,YAAY,GAAG,gBAAgB,GAAG,aAAa,GAAG,IAAI,GAAG,MAAM,GAAG,WAAW,MAAM,CAAC,GAAG,WAAW,QAAQ,CAAC,CAAC;AACxK,sCAAsC,CAAC,IAAI,kBAAkB,CAAC,CAAC,GAAG,qBAAqB,CAAC;AAqHxF;;GAEG;AACH,OAAA,IAAI,iLAA8C,CAAC","sources":["packages/@react-spectrum/labeledvalue/src/packages/@react-spectrum/labeledvalue/src/LabeledValue.tsx","packages/@react-spectrum/labeledvalue/src/packages/@react-spectrum/labeledvalue/src/index.ts","packages/@react-spectrum/labeledvalue/src/index.ts"],"sourcesContent":[null,null,"/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/// <reference types=\"css-module-types\" />\n\nexport type {SpectrumLabeledValueProps} from './LabeledValue';\nexport {LabeledValue} from './LabeledValue';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@react-spectrum/labeledvalue",
|
3
|
-
"version": "3.0.0-nightly.
|
3
|
+
"version": "3.0.0-nightly.3491+25a36b7d4",
|
4
4
|
"description": "Spectrum UI components in React",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"main": "dist/main.js",
|
@@ -32,15 +32,15 @@
|
|
32
32
|
},
|
33
33
|
"dependencies": {
|
34
34
|
"@babel/runtime": "^7.6.2",
|
35
|
-
"@internationalized/date": "3.0.2-nightly.
|
36
|
-
"@react-aria/i18n": "3.0.0-nightly.
|
37
|
-
"@react-aria/utils": "3.0.0-nightly.
|
38
|
-
"@react-spectrum/label": "3.7.2-nightly.
|
39
|
-
"@react-spectrum/utils": "3.0.0-nightly.
|
40
|
-
"@react-types/shared": "3.0.0-nightly.
|
35
|
+
"@internationalized/date": "3.0.2-nightly.3491+25a36b7d4",
|
36
|
+
"@react-aria/i18n": "3.0.0-nightly.1791+25a36b7d4",
|
37
|
+
"@react-aria/utils": "3.0.0-nightly.1791+25a36b7d4",
|
38
|
+
"@react-spectrum/label": "3.7.2-nightly.3491+25a36b7d4",
|
39
|
+
"@react-spectrum/utils": "3.0.0-nightly.1791+25a36b7d4",
|
40
|
+
"@react-types/shared": "3.0.0-nightly.1791+25a36b7d4"
|
41
41
|
},
|
42
42
|
"devDependencies": {
|
43
|
-
"@adobe/spectrum-css-temp": "3.0.0-nightly.
|
43
|
+
"@adobe/spectrum-css-temp": "3.0.0-nightly.1791+25a36b7d4"
|
44
44
|
},
|
45
45
|
"peerDependencies": {
|
46
46
|
"@react-spectrum/provider": "^3.0.0",
|
@@ -49,5 +49,5 @@
|
|
49
49
|
"publishConfig": {
|
50
50
|
"access": "public"
|
51
51
|
},
|
52
|
-
"gitHead": "
|
52
|
+
"gitHead": "25a36b7d40a7b20ff9ea67850c456119788c64d6"
|
53
53
|
}
|
package/src/LabeledValue.tsx
CHANGED
@@ -11,14 +11,13 @@
|
|
11
11
|
*/
|
12
12
|
|
13
13
|
import {CalendarDate, CalendarDateTime, getLocalTimeZone, Time, toCalendarDateTime, today, ZonedDateTime} from '@internationalized/date';
|
14
|
-
import {classNames} from '@react-spectrum/utils';
|
15
|
-
import type {DOMProps, RangeValue, SpectrumLabelableProps, StyleProps} from '@react-types/shared';
|
14
|
+
import {classNames, useDOMRef} from '@react-spectrum/utils';
|
15
|
+
import type {DOMProps, DOMRef, RangeValue, SpectrumLabelableProps, StyleProps} from '@react-types/shared';
|
16
|
+
import {Field} from '@react-spectrum/label';
|
16
17
|
import {filterDOMProps} from '@react-aria/utils';
|
17
|
-
import {Label} from '@react-spectrum/label';
|
18
18
|
import labelStyles from '@adobe/spectrum-css-temp/components/fieldlabel/vars.css';
|
19
|
-
import React, {ReactNode
|
19
|
+
import React, {ReactNode} from 'react';
|
20
20
|
import {useDateFormatter, useListFormatter, useNumberFormatter} from '@react-aria/i18n';
|
21
|
-
import {useStyleProps} from '@react-spectrum/utils';
|
22
21
|
|
23
22
|
// NOTE: the types here need to be synchronized with the ones in docs/types.ts, which are simpler so the documentation generator can handle them.
|
24
23
|
|
@@ -70,62 +69,43 @@ type LabeledValueProps<T> =
|
|
70
69
|
type SpectrumLabeledValueTypes = string[] | string | Date | CalendarDate | CalendarDateTime | ZonedDateTime | Time | number | RangeValue<number> | RangeValue<DateTime>;
|
71
70
|
export type SpectrumLabeledValueProps<T> = LabeledValueProps<T> & LabeledValueBaseProps;
|
72
71
|
|
73
|
-
function LabeledValue<T extends SpectrumLabeledValueTypes>(props: SpectrumLabeledValueProps<T>, ref:
|
72
|
+
function LabeledValue<T extends SpectrumLabeledValueTypes>(props: SpectrumLabeledValueProps<T>, ref: DOMRef<HTMLElement>) {
|
74
73
|
let {
|
75
74
|
value,
|
76
|
-
formatOptions
|
77
|
-
labelPosition,
|
78
|
-
labelAlign,
|
79
|
-
label,
|
80
|
-
...otherProps
|
75
|
+
formatOptions
|
81
76
|
} = props;
|
82
|
-
let
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
)
|
77
|
+
let domRef = useDOMRef(ref);
|
78
|
+
|
79
|
+
let children;
|
80
|
+
if (Array.isArray(value)) {
|
81
|
+
// @ts-ignore
|
82
|
+
children = <FormattedStringList value={value} formatOptions={formatOptions as Intl.ListFormatOptions} />;
|
83
|
+
}
|
84
|
+
|
85
|
+
if (typeof value === 'object' && 'start' in value && typeof value.start === 'number' && typeof value.end === 'number') {
|
86
|
+
children = <FormattedNumber value={value as NumberValue} formatOptions={formatOptions as Intl.NumberFormatOptions} />;
|
87
|
+
}
|
88
|
+
|
89
|
+
if (typeof value === 'object' && 'start' in value && typeof value.start !== 'number' && typeof value.end !== 'number') {
|
90
|
+
children = <FormattedDate value={value as DateTimeValue} formatOptions={formatOptions as Intl.DateTimeFormatOptions} />;
|
91
|
+
}
|
92
|
+
|
93
|
+
if (typeof value === 'number') {
|
94
|
+
children = <FormattedNumber value={value} formatOptions={formatOptions as Intl.NumberFormatOptions} />;
|
95
|
+
}
|
96
|
+
|
97
|
+
if (typeof value === 'object' && ('calendar' in value || 'hour' in value) || (value instanceof Date)) {
|
98
|
+
children = <FormattedDate value={value} formatOptions={formatOptions as Intl.DateTimeFormatOptions} />;
|
99
|
+
}
|
100
|
+
|
101
|
+
if (typeof value === 'string') {
|
102
|
+
children = value;
|
103
|
+
}
|
91
104
|
|
92
105
|
return (
|
93
|
-
<
|
94
|
-
{
|
95
|
-
|
96
|
-
className={classNames(labelStyles, 'spectrum-LabeledValue', {[labelWrapperClass]: label}, styleProps.className)}
|
97
|
-
ref={ref}>
|
98
|
-
{props.label &&
|
99
|
-
<Label
|
100
|
-
labelPosition={labelPosition}
|
101
|
-
labelAlign={labelAlign}
|
102
|
-
elementType="span">
|
103
|
-
{props.label}
|
104
|
-
</Label>}
|
105
|
-
<div
|
106
|
-
className={classNames(labelStyles, 'spectrum-Field-wrapper')}>
|
107
|
-
<div className={classNames(labelStyles, 'spectrum-Field-field')}>
|
108
|
-
{Array.isArray(value) &&
|
109
|
-
// @ts-ignore
|
110
|
-
<FormattedStringList value={value} formatOptions={formatOptions as Intl.ListFormatOptions} />}
|
111
|
-
|
112
|
-
{typeof value === 'object' && 'start' in value && typeof value.start === 'number' && typeof value.end === 'number' &&
|
113
|
-
<FormattedNumber value={value as NumberValue} formatOptions={formatOptions as Intl.NumberFormatOptions} />}
|
114
|
-
|
115
|
-
{typeof value === 'object' && 'start' in value && typeof value.start !== 'number' && typeof value.end !== 'number' &&
|
116
|
-
<FormattedDate value={value as DateTimeValue} formatOptions={formatOptions as Intl.DateTimeFormatOptions} />}
|
117
|
-
|
118
|
-
{typeof value === 'number' &&
|
119
|
-
<FormattedNumber value={value} formatOptions={formatOptions as Intl.NumberFormatOptions} />}
|
120
|
-
|
121
|
-
{(typeof value === 'object' && ('calendar' in value || 'hour' in value) || (value instanceof Date)) &&
|
122
|
-
<FormattedDate value={value} formatOptions={formatOptions as Intl.DateTimeFormatOptions} />}
|
123
|
-
|
124
|
-
{typeof value === 'string' &&
|
125
|
-
value}
|
126
|
-
</div>
|
127
|
-
</div>
|
128
|
-
</div>
|
106
|
+
<Field {...props as any} wrapperProps={filterDOMProps(props as any)} ref={domRef} elementType="span" wrapperClassName={classNames(labelStyles, 'spectrum-LabeledValue')}>
|
107
|
+
<span>{children}</span>
|
108
|
+
</Field>
|
129
109
|
);
|
130
110
|
}
|
131
111
|
|