@react-spectrum/labeledvalue 3.2.10 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/import.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import {LabeledValue as $3e9971be431adb24$export$d1328f67a56fa517} from "./LabeledValue.mjs";
1
+ import {LabeledValue as $c1c1ceb3364d3db2$re_export$LabeledValue} from "@adobe/react-spectrum/LabeledValue";
2
2
 
3
3
  /*
4
4
  * Copyright 2022 Adobe. All rights reserved.
@@ -14,5 +14,5 @@ import {LabeledValue as $3e9971be431adb24$export$d1328f67a56fa517} from "./Label
14
14
 
15
15
 
16
16
 
17
- export {$3e9971be431adb24$export$d1328f67a56fa517 as LabeledValue};
17
+ export {$c1c1ceb3364d3db2$re_export$LabeledValue as LabeledValue};
18
18
  //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -1,11 +1,11 @@
1
- var $2a7417c2df2197f7$exports = require("./LabeledValue.main.js");
1
+ var $55mmE$adobereactspectrumLabeledValue = require("@adobe/react-spectrum/LabeledValue");
2
2
 
3
3
 
4
4
  function $parcel$export(e, n, v, s) {
5
5
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
6
  }
7
7
 
8
- $parcel$export(module.exports, "LabeledValue", () => $2a7417c2df2197f7$exports.LabeledValue);
8
+ $parcel$export(module.exports, "LabeledValue", function () { return $55mmE$adobereactspectrumLabeledValue.LabeledValue; });
9
9
  /*
10
10
  * Copyright 2022 Adobe. All rights reserved.
11
11
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,0CAA0C","sources":["packages/@react-spectrum/labeledvalue/src/index.ts"],"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"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,0CAA0C","sources":["packages/@react-spectrum/labeledvalue/src/index.ts"],"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 {LabeledValue} from '@adobe/react-spectrum/LabeledValue';\n\nexport type {SpectrumLabeledValueProps} from '@adobe/react-spectrum/LabeledValue';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,4 +1,4 @@
1
- import {LabeledValue as $3e9971be431adb24$export$d1328f67a56fa517} from "./LabeledValue.module.js";
1
+ import {LabeledValue as $c1c1ceb3364d3db2$re_export$LabeledValue} from "@adobe/react-spectrum/LabeledValue";
2
2
 
3
3
  /*
4
4
  * Copyright 2022 Adobe. All rights reserved.
@@ -14,5 +14,5 @@ import {LabeledValue as $3e9971be431adb24$export$d1328f67a56fa517} from "./Label
14
14
 
15
15
 
16
16
 
17
- export {$3e9971be431adb24$export$d1328f67a56fa517 as LabeledValue};
17
+ export {$c1c1ceb3364d3db2$re_export$LabeledValue as LabeledValue};
18
18
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"mappings":";;AAAA;;;;;;;;;;CAUC,GAED,0CAA0C","sources":["packages/@react-spectrum/labeledvalue/src/index.ts"],"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"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC,GAED,0CAA0C","sources":["packages/@react-spectrum/labeledvalue/src/index.ts"],"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 {LabeledValue} from '@adobe/react-spectrum/LabeledValue';\n\nexport type {SpectrumLabeledValueProps} from '@adobe/react-spectrum/LabeledValue';\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -0,0 +1,2 @@
1
+ export { LabeledValue } from '@adobe/react-spectrum/LabeledValue';
2
+ export type { SpectrumLabeledValueProps } from '@adobe/react-spectrum/LabeledValue';
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "@react-spectrum/labeledvalue",
3
- "version": "3.2.10",
3
+ "version": "3.3.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/module.js",
8
8
  "exports": {
9
- "source": "./src/index.ts",
10
- "types": [
11
- "./dist/types.d.ts",
12
- "./src/index.ts"
13
- ],
14
- "import": "./dist/import.mjs",
15
- "require": "./dist/main.js"
9
+ ".": {
10
+ "source": "./src/index.ts",
11
+ "types": "./dist/types/src/index.d.ts",
12
+ "import": "./dist/import.mjs",
13
+ "require": "./dist/main.js"
14
+ },
15
+ "./package.json": "./package.json"
16
16
  },
17
- "types": "dist/types.d.ts",
17
+ "types": "dist/types/src/index.d.ts",
18
18
  "source": "src/index.ts",
19
19
  "files": [
20
20
  "dist",
@@ -24,40 +24,22 @@
24
24
  "*.css"
25
25
  ],
26
26
  "targets": {
27
- "main": {
28
- "includeNodeModules": [
29
- "@adobe/spectrum-css-temp"
30
- ]
31
- },
32
- "module": {
33
- "includeNodeModules": [
34
- "@adobe/spectrum-css-temp"
35
- ]
36
- }
27
+ "types": false
37
28
  },
38
29
  "repository": {
39
30
  "type": "git",
40
31
  "url": "https://github.com/adobe/react-spectrum"
41
32
  },
42
33
  "dependencies": {
43
- "@internationalized/date": "^3.12.0",
44
- "@react-aria/i18n": "^3.12.16",
45
- "@react-aria/utils": "^3.33.1",
46
- "@react-spectrum/label": "^3.16.22",
47
- "@react-spectrum/utils": "^3.12.12",
48
- "@react-types/shared": "^3.33.1",
34
+ "@adobe/react-spectrum": "3.47.0",
49
35
  "@swc/helpers": "^0.5.0"
50
36
  },
51
- "devDependencies": {
52
- "@adobe/spectrum-css-temp": "3.0.0-alpha.1"
53
- },
54
37
  "peerDependencies": {
55
- "@react-spectrum/provider": "^3.0.0",
56
38
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
57
39
  "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
58
40
  },
59
41
  "publishConfig": {
60
42
  "access": "public"
61
43
  },
62
- "gitHead": "8df187370053aa35f553cb388ad670f65e1ab371"
44
+ "gitHead": "a6999bdf494a2e9c0381a5881908328bdd22ddae"
63
45
  }
package/src/index.ts CHANGED
@@ -12,5 +12,6 @@
12
12
 
13
13
  /// <reference types="css-module-types" />
14
14
 
15
- export type {SpectrumLabeledValueProps} from './LabeledValue';
16
- export {LabeledValue} from './LabeledValue';
15
+ export {LabeledValue} from '@adobe/react-spectrum/LabeledValue';
16
+
17
+ export type {SpectrumLabeledValueProps} from '@adobe/react-spectrum/LabeledValue';
@@ -1,139 +0,0 @@
1
- require("./labeledvalue.1e807200.css");
2
- var $eb2fc0ee655eff6b$exports = require("./fieldlabel_vars_css.main.js");
3
- var $lcZyr$internationalizeddate = require("@internationalized/date");
4
- var $lcZyr$reactspectrumutils = require("@react-spectrum/utils");
5
- var $lcZyr$reactspectrumlabel = require("@react-spectrum/label");
6
- var $lcZyr$reactariautils = require("@react-aria/utils");
7
- var $lcZyr$react = require("react");
8
- var $lcZyr$reactariai18n = require("@react-aria/i18n");
9
-
10
-
11
- function $parcel$interopDefault(a) {
12
- return a && a.__esModule ? a.default : a;
13
- }
14
-
15
- function $parcel$export(e, n, v, s) {
16
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
17
- }
18
-
19
- $parcel$export(module.exports, "LabeledValue", () => $2a7417c2df2197f7$export$d1328f67a56fa517);
20
- /*
21
- * Copyright 2020 Adobe. All rights reserved.
22
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
23
- * you may not use this file except in compliance with the License. You may obtain a copy
24
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
25
- *
26
- * Unless required by applicable law or agreed to in writing, software distributed under
27
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
28
- * OF ANY KIND, either express or implied. See the License for the specific language
29
- * governing permissions and limitations under the License.
30
- */
31
-
32
-
33
-
34
-
35
-
36
-
37
- const $2a7417c2df2197f7$export$d1328f67a56fa517 = /*#__PURE__*/ (0, ($parcel$interopDefault($lcZyr$react))).forwardRef(function LabeledValue(props, ref) {
38
- let { value: value, formatOptions: formatOptions } = props;
39
- let domRef = (0, $lcZyr$reactspectrumutils.useDOMRef)(ref);
40
- (0, $lcZyr$react.useEffect)(()=>{
41
- if ((domRef === null || domRef === void 0 ? void 0 : domRef.current) && domRef.current.querySelectorAll('input, [contenteditable], textarea').length > 0) throw new Error('LabeledValue cannot contain an editable value.');
42
- }, [
43
- domRef
44
- ]);
45
- let children;
46
- if (Array.isArray(value)) children = /*#__PURE__*/ (0, ($parcel$interopDefault($lcZyr$react))).createElement($2a7417c2df2197f7$var$FormattedStringList, {
47
- value: value,
48
- formatOptions: formatOptions
49
- });
50
- if (typeof value === 'object' && 'start' in value && typeof value.start === 'number' && typeof value.end === 'number') children = /*#__PURE__*/ (0, ($parcel$interopDefault($lcZyr$react))).createElement($2a7417c2df2197f7$var$FormattedNumber, {
51
- value: value,
52
- formatOptions: formatOptions
53
- });
54
- if (typeof value === 'object' && 'start' in value && typeof value.start !== 'number' && typeof value.end !== 'number') children = /*#__PURE__*/ (0, ($parcel$interopDefault($lcZyr$react))).createElement($2a7417c2df2197f7$var$FormattedDate, {
55
- value: value,
56
- formatOptions: formatOptions
57
- });
58
- if (typeof value === 'number') children = /*#__PURE__*/ (0, ($parcel$interopDefault($lcZyr$react))).createElement($2a7417c2df2197f7$var$FormattedNumber, {
59
- value: value,
60
- formatOptions: formatOptions
61
- });
62
- if (typeof value === 'object' && ('calendar' in value || 'hour' in value) || value instanceof Date) children = /*#__PURE__*/ (0, ($parcel$interopDefault($lcZyr$react))).createElement($2a7417c2df2197f7$var$FormattedDate, {
63
- value: value,
64
- formatOptions: formatOptions
65
- });
66
- if (typeof value === 'string') children = value;
67
- if (/*#__PURE__*/ (0, ($parcel$interopDefault($lcZyr$react))).isValidElement(value)) children = value;
68
- return /*#__PURE__*/ (0, ($parcel$interopDefault($lcZyr$react))).createElement((0, $lcZyr$reactspectrumlabel.Field), {
69
- ...props,
70
- wrapperProps: (0, $lcZyr$reactariautils.filterDOMProps)(props),
71
- ref: domRef,
72
- elementType: "span",
73
- wrapperClassName: (0, $lcZyr$reactspectrumutils.classNames)((0, ($parcel$interopDefault($eb2fc0ee655eff6b$exports))), 'spectrum-LabeledValue')
74
- }, /*#__PURE__*/ (0, ($parcel$interopDefault($lcZyr$react))).createElement("span", null, children));
75
- });
76
- function $2a7417c2df2197f7$var$FormattedStringList(props) {
77
- let stringFormatter = (0, $lcZyr$reactariai18n.useListFormatter)(props.formatOptions);
78
- return /*#__PURE__*/ (0, ($parcel$interopDefault($lcZyr$react))).createElement((0, ($parcel$interopDefault($lcZyr$react))).Fragment, null, stringFormatter.format(props.value));
79
- }
80
- function $2a7417c2df2197f7$var$FormattedNumber(props) {
81
- let numberFormatter = (0, $lcZyr$reactariai18n.useNumberFormatter)(props.formatOptions);
82
- let value = props.value;
83
- if (typeof value === 'object') return /*#__PURE__*/ (0, ($parcel$interopDefault($lcZyr$react))).createElement((0, ($parcel$interopDefault($lcZyr$react))).Fragment, null, numberFormatter.formatRange(value.start, value.end));
84
- return /*#__PURE__*/ (0, ($parcel$interopDefault($lcZyr$react))).createElement((0, ($parcel$interopDefault($lcZyr$react))).Fragment, null, numberFormatter.format(value));
85
- }
86
- function $2a7417c2df2197f7$var$FormattedDate(props) {
87
- let { value: value, formatOptions: formatOptions } = props;
88
- if (!formatOptions) formatOptions = $2a7417c2df2197f7$var$getDefaultFormatOptions('start' in value ? value.start : value);
89
- let dateFormatter = (0, $lcZyr$reactariai18n.useDateFormatter)(formatOptions);
90
- let timeZone = dateFormatter.resolvedOptions().timeZone || (0, $lcZyr$internationalizeddate.getLocalTimeZone)();
91
- let final;
92
- if ('start' in value && 'end' in value) {
93
- let start = value.start;
94
- let end = value.end;
95
- start = $2a7417c2df2197f7$var$convertDateTime(start, timeZone);
96
- end = $2a7417c2df2197f7$var$convertDateTime(end, timeZone);
97
- return /*#__PURE__*/ (0, ($parcel$interopDefault($lcZyr$react))).createElement((0, ($parcel$interopDefault($lcZyr$react))).Fragment, null, dateFormatter.formatRange(start, end));
98
- }
99
- final = $2a7417c2df2197f7$var$convertDateTime(value, timeZone);
100
- return /*#__PURE__*/ (0, ($parcel$interopDefault($lcZyr$react))).createElement((0, ($parcel$interopDefault($lcZyr$react))).Fragment, null, dateFormatter.format(final));
101
- }
102
- function $2a7417c2df2197f7$var$convertDateTime(value, timeZone) {
103
- if ('timeZone' in value) return value.toDate();
104
- else if ('calendar' in value) return value.toDate(timeZone);
105
- else if (!(value instanceof Date)) return $2a7417c2df2197f7$var$convertValue(value).toDate(timeZone);
106
- return value;
107
- }
108
- function $2a7417c2df2197f7$var$getDefaultFormatOptions(value) {
109
- if (value instanceof Date) return {
110
- dateStyle: 'long',
111
- timeStyle: 'short'
112
- };
113
- else if ('timeZone' in value) return {
114
- year: 'numeric',
115
- month: 'long',
116
- day: 'numeric',
117
- hour: 'numeric',
118
- minute: 'numeric',
119
- timeZone: value.timeZone,
120
- timeZoneName: 'short'
121
- };
122
- else if ('hour' in value && 'year' in value) return {
123
- dateStyle: 'long',
124
- timeStyle: 'short'
125
- };
126
- else if ('hour' in value) return {
127
- timeStyle: 'short'
128
- };
129
- else return {
130
- dateStyle: 'long'
131
- };
132
- }
133
- function $2a7417c2df2197f7$var$convertValue(value) {
134
- let date = (0, $lcZyr$internationalizeddate.today)((0, $lcZyr$internationalizeddate.getLocalTimeZone)());
135
- return (0, $lcZyr$internationalizeddate.toCalendarDateTime)(date, value);
136
- }
137
-
138
-
139
- //# sourceMappingURL=LabeledValue.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAuEM,MAAM,0DAAe,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC,SAAS,aAAkD,KAAm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C,IAAI,cAAc,OACvB,OAAO;QAAC,MAAM;QAAW,OAAO;QAAQ,KAAK;QAAW,MAAM;QAAW,QAAQ;QAAW,UAAU,MAAM,QAAQ;QAAE,cAAc;IAAO;SACtI,IAAI,UAAU,SAAS,UAAU,OACtC,OAAO;QAAC,WAAW;QAAQ,WAAW;IAAO;SACxC,IAAI,UAAU,OACnB,OAAO;QAAC,WAAW;IAAO;SAE1B,OAAO;QAAC,WAAW;IAAM;AAE7B;AAEA,SAAS,mCAAa,KAAW;IAC/B,IAAI,OAAO,CAAA,GAAA,kCAAI,EAAE,CAAA,GAAA,6CAAe;IAEhC,OAAO,CAAA,GAAA,+CAAiB,EAAE,MAAM;AAClC","sources":["packages/@react-spectrum/labeledvalue/src/LabeledValue.tsx"],"sourcesContent":["/*\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, {ReactElement, ReactNode, useEffect} 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 formatOptions?: Intl.ListFormatOptions\n}\n\ninterface ReactElementProps<T extends ReactElement> {\n /** The value to display. */\n value: T,\n /** Formatting options for the value. */\n formatOptions?: never\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 T extends ReactElement ? ReactElementProps<T> :\n never;\n\ntype SpectrumLabeledValueTypes = string[] | string | Date | CalendarDate | CalendarDateTime | ZonedDateTime | Time | number | RangeValue<number> | RangeValue<DateTime> | ReactElement;\nexport type SpectrumLabeledValueProps<T> = LabeledValueProps<T> & LabeledValueBaseProps;\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 */\nexport const LabeledValue = React.forwardRef(function 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 useEffect(() => {\n if (\n domRef?.current &&\n domRef.current.querySelectorAll('input, [contenteditable], textarea')\n .length > 0\n ) {\n throw new Error('LabeledValue cannot contain an editable value.');\n }\n }, [domRef]);\n \n\n let children;\n if (Array.isArray(value)) {\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 if (React.isValidElement(value)) {\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"],"names":[],"version":3,"file":"LabeledValue.main.js.map"}
@@ -1,134 +0,0 @@
1
- import "./labeledvalue.1e807200.css";
2
- import $fhlTD$fieldlabel_vars_cssmodulejs from "./fieldlabel_vars_css.mjs";
3
- import {getLocalTimeZone as $fhlTD$getLocalTimeZone, today as $fhlTD$today, toCalendarDateTime as $fhlTD$toCalendarDateTime} from "@internationalized/date";
4
- import {useDOMRef as $fhlTD$useDOMRef, classNames as $fhlTD$classNames} from "@react-spectrum/utils";
5
- import {Field as $fhlTD$Field} from "@react-spectrum/label";
6
- import {filterDOMProps as $fhlTD$filterDOMProps} from "@react-aria/utils";
7
- import $fhlTD$react, {useEffect as $fhlTD$useEffect} from "react";
8
- import {useListFormatter as $fhlTD$useListFormatter, useNumberFormatter as $fhlTD$useNumberFormatter, useDateFormatter as $fhlTD$useDateFormatter} from "@react-aria/i18n";
9
-
10
-
11
- function $parcel$interopDefault(a) {
12
- return a && a.__esModule ? a.default : a;
13
- }
14
- /*
15
- * Copyright 2020 Adobe. All rights reserved.
16
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
17
- * you may not use this file except in compliance with the License. You may obtain a copy
18
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
19
- *
20
- * Unless required by applicable law or agreed to in writing, software distributed under
21
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
22
- * OF ANY KIND, either express or implied. See the License for the specific language
23
- * governing permissions and limitations under the License.
24
- */
25
-
26
-
27
-
28
-
29
-
30
-
31
- const $3e9971be431adb24$export$d1328f67a56fa517 = /*#__PURE__*/ (0, $fhlTD$react).forwardRef(function LabeledValue(props, ref) {
32
- let { value: value, formatOptions: formatOptions } = props;
33
- let domRef = (0, $fhlTD$useDOMRef)(ref);
34
- (0, $fhlTD$useEffect)(()=>{
35
- if ((domRef === null || domRef === void 0 ? void 0 : domRef.current) && domRef.current.querySelectorAll('input, [contenteditable], textarea').length > 0) throw new Error('LabeledValue cannot contain an editable value.');
36
- }, [
37
- domRef
38
- ]);
39
- let children;
40
- if (Array.isArray(value)) children = /*#__PURE__*/ (0, $fhlTD$react).createElement($3e9971be431adb24$var$FormattedStringList, {
41
- value: value,
42
- formatOptions: formatOptions
43
- });
44
- if (typeof value === 'object' && 'start' in value && typeof value.start === 'number' && typeof value.end === 'number') children = /*#__PURE__*/ (0, $fhlTD$react).createElement($3e9971be431adb24$var$FormattedNumber, {
45
- value: value,
46
- formatOptions: formatOptions
47
- });
48
- if (typeof value === 'object' && 'start' in value && typeof value.start !== 'number' && typeof value.end !== 'number') children = /*#__PURE__*/ (0, $fhlTD$react).createElement($3e9971be431adb24$var$FormattedDate, {
49
- value: value,
50
- formatOptions: formatOptions
51
- });
52
- if (typeof value === 'number') children = /*#__PURE__*/ (0, $fhlTD$react).createElement($3e9971be431adb24$var$FormattedNumber, {
53
- value: value,
54
- formatOptions: formatOptions
55
- });
56
- if (typeof value === 'object' && ('calendar' in value || 'hour' in value) || value instanceof Date) children = /*#__PURE__*/ (0, $fhlTD$react).createElement($3e9971be431adb24$var$FormattedDate, {
57
- value: value,
58
- formatOptions: formatOptions
59
- });
60
- if (typeof value === 'string') children = value;
61
- if (/*#__PURE__*/ (0, $fhlTD$react).isValidElement(value)) children = value;
62
- return /*#__PURE__*/ (0, $fhlTD$react).createElement((0, $fhlTD$Field), {
63
- ...props,
64
- wrapperProps: (0, $fhlTD$filterDOMProps)(props),
65
- ref: domRef,
66
- elementType: "span",
67
- wrapperClassName: (0, $fhlTD$classNames)((0, ($parcel$interopDefault($fhlTD$fieldlabel_vars_cssmodulejs))), 'spectrum-LabeledValue')
68
- }, /*#__PURE__*/ (0, $fhlTD$react).createElement("span", null, children));
69
- });
70
- function $3e9971be431adb24$var$FormattedStringList(props) {
71
- let stringFormatter = (0, $fhlTD$useListFormatter)(props.formatOptions);
72
- return /*#__PURE__*/ (0, $fhlTD$react).createElement((0, $fhlTD$react).Fragment, null, stringFormatter.format(props.value));
73
- }
74
- function $3e9971be431adb24$var$FormattedNumber(props) {
75
- let numberFormatter = (0, $fhlTD$useNumberFormatter)(props.formatOptions);
76
- let value = props.value;
77
- if (typeof value === 'object') return /*#__PURE__*/ (0, $fhlTD$react).createElement((0, $fhlTD$react).Fragment, null, numberFormatter.formatRange(value.start, value.end));
78
- return /*#__PURE__*/ (0, $fhlTD$react).createElement((0, $fhlTD$react).Fragment, null, numberFormatter.format(value));
79
- }
80
- function $3e9971be431adb24$var$FormattedDate(props) {
81
- let { value: value, formatOptions: formatOptions } = props;
82
- if (!formatOptions) formatOptions = $3e9971be431adb24$var$getDefaultFormatOptions('start' in value ? value.start : value);
83
- let dateFormatter = (0, $fhlTD$useDateFormatter)(formatOptions);
84
- let timeZone = dateFormatter.resolvedOptions().timeZone || (0, $fhlTD$getLocalTimeZone)();
85
- let final;
86
- if ('start' in value && 'end' in value) {
87
- let start = value.start;
88
- let end = value.end;
89
- start = $3e9971be431adb24$var$convertDateTime(start, timeZone);
90
- end = $3e9971be431adb24$var$convertDateTime(end, timeZone);
91
- return /*#__PURE__*/ (0, $fhlTD$react).createElement((0, $fhlTD$react).Fragment, null, dateFormatter.formatRange(start, end));
92
- }
93
- final = $3e9971be431adb24$var$convertDateTime(value, timeZone);
94
- return /*#__PURE__*/ (0, $fhlTD$react).createElement((0, $fhlTD$react).Fragment, null, dateFormatter.format(final));
95
- }
96
- function $3e9971be431adb24$var$convertDateTime(value, timeZone) {
97
- if ('timeZone' in value) return value.toDate();
98
- else if ('calendar' in value) return value.toDate(timeZone);
99
- else if (!(value instanceof Date)) return $3e9971be431adb24$var$convertValue(value).toDate(timeZone);
100
- return value;
101
- }
102
- function $3e9971be431adb24$var$getDefaultFormatOptions(value) {
103
- if (value instanceof Date) return {
104
- dateStyle: 'long',
105
- timeStyle: 'short'
106
- };
107
- else if ('timeZone' in value) return {
108
- year: 'numeric',
109
- month: 'long',
110
- day: 'numeric',
111
- hour: 'numeric',
112
- minute: 'numeric',
113
- timeZone: value.timeZone,
114
- timeZoneName: 'short'
115
- };
116
- else if ('hour' in value && 'year' in value) return {
117
- dateStyle: 'long',
118
- timeStyle: 'short'
119
- };
120
- else if ('hour' in value) return {
121
- timeStyle: 'short'
122
- };
123
- else return {
124
- dateStyle: 'long'
125
- };
126
- }
127
- function $3e9971be431adb24$var$convertValue(value) {
128
- let date = (0, $fhlTD$today)((0, $fhlTD$getLocalTimeZone)());
129
- return (0, $fhlTD$toCalendarDateTime)(date, value);
130
- }
131
-
132
-
133
- export {$3e9971be431adb24$export$d1328f67a56fa517 as LabeledValue};
134
- //# sourceMappingURL=LabeledValue.module.js.map
@@ -1,134 +0,0 @@
1
- import "./labeledvalue.1e807200.css";
2
- import $fhlTD$fieldlabel_vars_cssmodulejs from "./fieldlabel_vars_css.module.js";
3
- import {getLocalTimeZone as $fhlTD$getLocalTimeZone, today as $fhlTD$today, toCalendarDateTime as $fhlTD$toCalendarDateTime} from "@internationalized/date";
4
- import {useDOMRef as $fhlTD$useDOMRef, classNames as $fhlTD$classNames} from "@react-spectrum/utils";
5
- import {Field as $fhlTD$Field} from "@react-spectrum/label";
6
- import {filterDOMProps as $fhlTD$filterDOMProps} from "@react-aria/utils";
7
- import $fhlTD$react, {useEffect as $fhlTD$useEffect} from "react";
8
- import {useListFormatter as $fhlTD$useListFormatter, useNumberFormatter as $fhlTD$useNumberFormatter, useDateFormatter as $fhlTD$useDateFormatter} from "@react-aria/i18n";
9
-
10
-
11
- function $parcel$interopDefault(a) {
12
- return a && a.__esModule ? a.default : a;
13
- }
14
- /*
15
- * Copyright 2020 Adobe. All rights reserved.
16
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
17
- * you may not use this file except in compliance with the License. You may obtain a copy
18
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
19
- *
20
- * Unless required by applicable law or agreed to in writing, software distributed under
21
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
22
- * OF ANY KIND, either express or implied. See the License for the specific language
23
- * governing permissions and limitations under the License.
24
- */
25
-
26
-
27
-
28
-
29
-
30
-
31
- const $3e9971be431adb24$export$d1328f67a56fa517 = /*#__PURE__*/ (0, $fhlTD$react).forwardRef(function LabeledValue(props, ref) {
32
- let { value: value, formatOptions: formatOptions } = props;
33
- let domRef = (0, $fhlTD$useDOMRef)(ref);
34
- (0, $fhlTD$useEffect)(()=>{
35
- if ((domRef === null || domRef === void 0 ? void 0 : domRef.current) && domRef.current.querySelectorAll('input, [contenteditable], textarea').length > 0) throw new Error('LabeledValue cannot contain an editable value.');
36
- }, [
37
- domRef
38
- ]);
39
- let children;
40
- if (Array.isArray(value)) children = /*#__PURE__*/ (0, $fhlTD$react).createElement($3e9971be431adb24$var$FormattedStringList, {
41
- value: value,
42
- formatOptions: formatOptions
43
- });
44
- if (typeof value === 'object' && 'start' in value && typeof value.start === 'number' && typeof value.end === 'number') children = /*#__PURE__*/ (0, $fhlTD$react).createElement($3e9971be431adb24$var$FormattedNumber, {
45
- value: value,
46
- formatOptions: formatOptions
47
- });
48
- if (typeof value === 'object' && 'start' in value && typeof value.start !== 'number' && typeof value.end !== 'number') children = /*#__PURE__*/ (0, $fhlTD$react).createElement($3e9971be431adb24$var$FormattedDate, {
49
- value: value,
50
- formatOptions: formatOptions
51
- });
52
- if (typeof value === 'number') children = /*#__PURE__*/ (0, $fhlTD$react).createElement($3e9971be431adb24$var$FormattedNumber, {
53
- value: value,
54
- formatOptions: formatOptions
55
- });
56
- if (typeof value === 'object' && ('calendar' in value || 'hour' in value) || value instanceof Date) children = /*#__PURE__*/ (0, $fhlTD$react).createElement($3e9971be431adb24$var$FormattedDate, {
57
- value: value,
58
- formatOptions: formatOptions
59
- });
60
- if (typeof value === 'string') children = value;
61
- if (/*#__PURE__*/ (0, $fhlTD$react).isValidElement(value)) children = value;
62
- return /*#__PURE__*/ (0, $fhlTD$react).createElement((0, $fhlTD$Field), {
63
- ...props,
64
- wrapperProps: (0, $fhlTD$filterDOMProps)(props),
65
- ref: domRef,
66
- elementType: "span",
67
- wrapperClassName: (0, $fhlTD$classNames)((0, ($parcel$interopDefault($fhlTD$fieldlabel_vars_cssmodulejs))), 'spectrum-LabeledValue')
68
- }, /*#__PURE__*/ (0, $fhlTD$react).createElement("span", null, children));
69
- });
70
- function $3e9971be431adb24$var$FormattedStringList(props) {
71
- let stringFormatter = (0, $fhlTD$useListFormatter)(props.formatOptions);
72
- return /*#__PURE__*/ (0, $fhlTD$react).createElement((0, $fhlTD$react).Fragment, null, stringFormatter.format(props.value));
73
- }
74
- function $3e9971be431adb24$var$FormattedNumber(props) {
75
- let numberFormatter = (0, $fhlTD$useNumberFormatter)(props.formatOptions);
76
- let value = props.value;
77
- if (typeof value === 'object') return /*#__PURE__*/ (0, $fhlTD$react).createElement((0, $fhlTD$react).Fragment, null, numberFormatter.formatRange(value.start, value.end));
78
- return /*#__PURE__*/ (0, $fhlTD$react).createElement((0, $fhlTD$react).Fragment, null, numberFormatter.format(value));
79
- }
80
- function $3e9971be431adb24$var$FormattedDate(props) {
81
- let { value: value, formatOptions: formatOptions } = props;
82
- if (!formatOptions) formatOptions = $3e9971be431adb24$var$getDefaultFormatOptions('start' in value ? value.start : value);
83
- let dateFormatter = (0, $fhlTD$useDateFormatter)(formatOptions);
84
- let timeZone = dateFormatter.resolvedOptions().timeZone || (0, $fhlTD$getLocalTimeZone)();
85
- let final;
86
- if ('start' in value && 'end' in value) {
87
- let start = value.start;
88
- let end = value.end;
89
- start = $3e9971be431adb24$var$convertDateTime(start, timeZone);
90
- end = $3e9971be431adb24$var$convertDateTime(end, timeZone);
91
- return /*#__PURE__*/ (0, $fhlTD$react).createElement((0, $fhlTD$react).Fragment, null, dateFormatter.formatRange(start, end));
92
- }
93
- final = $3e9971be431adb24$var$convertDateTime(value, timeZone);
94
- return /*#__PURE__*/ (0, $fhlTD$react).createElement((0, $fhlTD$react).Fragment, null, dateFormatter.format(final));
95
- }
96
- function $3e9971be431adb24$var$convertDateTime(value, timeZone) {
97
- if ('timeZone' in value) return value.toDate();
98
- else if ('calendar' in value) return value.toDate(timeZone);
99
- else if (!(value instanceof Date)) return $3e9971be431adb24$var$convertValue(value).toDate(timeZone);
100
- return value;
101
- }
102
- function $3e9971be431adb24$var$getDefaultFormatOptions(value) {
103
- if (value instanceof Date) return {
104
- dateStyle: 'long',
105
- timeStyle: 'short'
106
- };
107
- else if ('timeZone' in value) return {
108
- year: 'numeric',
109
- month: 'long',
110
- day: 'numeric',
111
- hour: 'numeric',
112
- minute: 'numeric',
113
- timeZone: value.timeZone,
114
- timeZoneName: 'short'
115
- };
116
- else if ('hour' in value && 'year' in value) return {
117
- dateStyle: 'long',
118
- timeStyle: 'short'
119
- };
120
- else if ('hour' in value) return {
121
- timeStyle: 'short'
122
- };
123
- else return {
124
- dateStyle: 'long'
125
- };
126
- }
127
- function $3e9971be431adb24$var$convertValue(value) {
128
- let date = (0, $fhlTD$today)((0, $fhlTD$getLocalTimeZone)());
129
- return (0, $fhlTD$toCalendarDateTime)(date, value);
130
- }
131
-
132
-
133
- export {$3e9971be431adb24$export$d1328f67a56fa517 as LabeledValue};
134
- //# sourceMappingURL=LabeledValue.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAuEM,MAAM,0DAAe,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC,SAAS,aAAkD,KAAmC,EAAE,GAAwB;IACnK,IAAI,SACF,KAAK,iBACL,aAAa,EACd,GAAG;IACJ,IAAI,SAAS,CAAA,GAAA,gBAAQ,EAAE;IAEvB,CAAA,GAAA,gBAAQ,EAAE;QACR,IACE,CAAA,mBAAA,6BAAA,OAAQ,OAAO,KACf,OAAO,OAAO,CAAC,gBAAgB,CAAC,sCAC7B,MAAM,GAAG,GAEZ,MAAM,IAAI,MAAM;IAEpB,GAAG;QAAC;KAAO;IAGX,IAAI;IACJ,IAAI,MAAM,OAAO,CAAC,QAChB,yBAAW,gCAAC;QAAoB,OAAO;QAAO,eAAe;;IAG/D,IAAI,OAAO,UAAU,YAAY,WAAW,SAAS,OAAO,MAAM,KAAK,KAAK,YAAY,OAAO,MAAM,GAAG,KAAK,UAC3G,yBAAW,gCAAC;QAAgB,OAAO;QAAsB,eAAe;;IAG1E,IAAI,OAAO,UAAU,YAAY,WAAW,SAAS,OAAO,MAAM,KAAK,KAAK,YAAY,OAAO,MAAM,GAAG,KAAK,UAC3G,yBAAW,gCAAC;QAAc,OAAO;QAAwB,eAAe;;IAG1E,IAAI,OAAO,UAAU,UACnB,yBAAW,gCAAC;QAAgB,OAAO;QAAO,eAAe;;IAG3D,IAAI,OAAO,UAAU,YAAa,CAAA,cAAc,SAAS,UAAU,KAAI,KAAO,iBAAiB,MAC7F,yBAAW,gCAAC;QAAc,OAAO;QA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AgB,OAAO;IAC/B,qBAAO,kEAAG,cAAc,MAAM,CAAC;AACjC;AAEA,SAAS,sCAAgB,KAAe,EAAE,QAAa;IACrD,IAAI,cAAc,OAChB,OAAO,MAAM,MAAM;SACd,IAAI,cAAc,OACvB,OAAO,MAAM,MAAM,CAAC;SACf,IAAI,CAAE,CAAA,iBAAiB,IAAG,GAC/B,OAAO,mCAAa,OAAO,MAAM,CAAC;IAGpC,OAAO;AACT;AAEA,SAAS,8CAAwB,KAAe;IAC9C,IAAI,iBAAiB,MACnB,OAAO;QAAC,WAAW;QAAQ,WAAW;IAAO;SACxC,IAAI,cAAc,OACvB,OAAO;QAAC,MAAM;QAAW,OAAO;QAAQ,KAAK;QAAW,MAAM;QAAW,QAAQ;QAAW,UAAU,MAAM,QAAQ;QAAE,cAAc;IAAO;SACtI,IAAI,UAAU,SAAS,UAAU,OACtC,OAAO;QAAC,WAAW;QAAQ,WAAW;IAAO;SACxC,IAAI,UAAU,OACnB,OAAO;QAAC,WAAW;IAAO;SAE1B,OAAO;QAAC,WAAW;IAAM;AAE7B;AAEA,SAAS,mCAAa,KAAW;IAC/B,IAAI,OAAO,CAAA,GAAA,YAAI,EAAE,CAAA,GAAA,uBAAe;IAEhC,OAAO,CAAA,GAAA,yBAAiB,EAAE,MAAM;AAClC","sources":["packages/@react-spectrum/labeledvalue/src/LabeledValue.tsx"],"sourcesContent":["/*\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, {ReactElement, ReactNode, useEffect} 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 formatOptions?: Intl.ListFormatOptions\n}\n\ninterface ReactElementProps<T extends ReactElement> {\n /** The value to display. */\n value: T,\n /** Formatting options for the value. */\n formatOptions?: never\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 T extends ReactElement ? ReactElementProps<T> :\n never;\n\ntype SpectrumLabeledValueTypes = string[] | string | Date | CalendarDate | CalendarDateTime | ZonedDateTime | Time | number | RangeValue<number> | RangeValue<DateTime> | ReactElement;\nexport type SpectrumLabeledValueProps<T> = LabeledValueProps<T> & LabeledValueBaseProps;\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 */\nexport const LabeledValue = React.forwardRef(function 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 useEffect(() => {\n if (\n domRef?.current &&\n domRef.current.querySelectorAll('input, [contenteditable], textarea')\n .length > 0\n ) {\n throw new Error('LabeledValue cannot contain an editable value.');\n }\n }, [domRef]);\n \n\n let children;\n if (Array.isArray(value)) {\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 if (React.isValidElement(value)) {\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"],"names":[],"version":3,"file":"LabeledValue.module.js.map"}