@react-stately/datepicker 3.12.0 → 3.13.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/placeholders.main.js +1 -1
- package/dist/placeholders.main.js.map +1 -1
- package/dist/placeholders.mjs +1 -1
- package/dist/placeholders.module.js +1 -1
- package/dist/placeholders.module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/useDateFieldState.main.js +67 -16
- package/dist/useDateFieldState.main.js.map +1 -1
- package/dist/useDateFieldState.mjs +67 -16
- package/dist/useDateFieldState.module.js +67 -16
- package/dist/useDateFieldState.module.js.map +1 -1
- package/package.json +6 -6
- package/src/placeholders.ts +1 -1
- package/src/useDateFieldState.ts +72 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAID,8EAA8E;AAC9E,4EAA4E;AAC5E,mDAAmD;AACnD,MAAM,qCAAe,IAAI,CAAA,GAAA,wDAAwB,EAAE;IACjD,KAAK;QAAC,MAAM;QAAS,OAAO;QAAO,KAAK;IAAM;IAC9C,IAAI;QAAC,MAAM;QAAQ,OAAO;QAAM,KAAK;IAAI;IACzC,IAAI;QAAC,MAAM;QAAQ,OAAO;QAAM,KAAK;IAAI;IACzC,IAAI;QAAC,MAAM;QAAQ,OAAO;QAAM,KAAK;IAAI;IACzC,IAAI;QAAC,MAAM;QAAO,OAAO;QAAO,KAAK;IAAK;IAC1C,KAAK;QAAC,MAAM;QAAQ,OAAO;QAAM,KAAK;IAAI;IAC1C,IAAI;QAAC,MAAM;QAAQ,OAAO;QAAM,KAAK;IAAI;IACzC,IAAI;QAAC,MAAM;QAAQ,OAAO;QAAM,KAAK;IAAI;IACzC,IAAI;QAAC,MAAM;QAAQ,OAAO;QAAM,KAAK;IAAI;IACzC,IAAI;QAAC,MAAM;QAAQ,OAAO;QAAQ,KAAK;IAAI;IAC3C,IAAI;QAAC,MAAM;QAAQ,OAAO;QAA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U,UAAU,WAAW,UAAU,OACrD,OAAO,mCAAa,kBAAkB,CAAC,OAAO;IAGhD,gFAAgF;IAChF,OAAO;AACT","sources":["packages/@react-stately/datepicker/src/placeholders.ts"],"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 {LocalizedStringDictionary} from '@internationalized/string';\n\n// These placeholders are based on the strings used by the <input type=\"date\">\n// implementations in Chrome and Firefox. Additional languages are supported\n// here than React Spectrum's typical translations.\nconst placeholders = new LocalizedStringDictionary({\n ach: {year: 'mwaka', month: 'dwe', day: 'nino'},\n af: {year: 'jjjj', month: 'mm', day: 'dd'},\n am: {year: 'ዓዓዓዓ', month: 'ሚሜ', day: 'ቀቀ'},\n an: {year: 'aaaa', month: 'mm', day: 'dd'},\n ar: {year: 'سنة', month: 'شهر', day: 'يوم'},\n ast: {year: 'aaaa', month: 'mm', day: 'dd'},\n az: {year: 'iiii', month: 'aa', day: 'gg'},\n be: {year: 'гггг', month: 'мм', day: 'дд'},\n bg: {year: 'гггг', month: 'мм', day: 'дд'},\n bn: {year: 'yyyy', month: 'মিমি', day: 'dd'},\n br: {year: 'bbbb', month: 'mm', day: 'dd'},\n bs: {year: 'gggg', month: 'mm', day: 'dd'},\n ca: {year: 'aaaa', month: 'mm', day: 'dd'},\n cak: {year: 'jjjj', month: 'ii', day: \"q'q'\"},\n ckb: {year: 'ساڵ', month: 'مانگ', day: 'ڕۆژ'},\n cs: {year: 'rrrr', month: 'mm', day: 'dd'},\n cy: {year: 'bbbb', month: 'mm', day: 'dd'},\n da: {year: 'åååå', month: 'mm', day: 'dd'},\n de: {year: 'jjjj', month: 'mm', day: 'tt'},\n dsb: {year: 'llll', month: 'mm', day: 'źź'},\n el: {year: 'εεεε', month: 'μμ', day: 'ηη'},\n en: {year: 'yyyy', month: 'mm', day: 'dd'},\n eo: {year: 'jjjj', month: 'mm', day: 'tt'},\n es: {year: 'aaaa', month: 'mm', day: 'dd'},\n et: {year: 'aaaa', month: 'kk', day: 'pp'},\n eu: {year: 'uuuu', month: 'hh', day: 'ee'},\n fa: {year: 'سال', month: 'ماه', day: 'روز'},\n ff: {year: 'hhhh', month: 'll', day: 'ññ'},\n fi: {year: 'vvvv', month: 'kk', day: 'pp'},\n fr: {year: 'aaaa', month: 'mm', day: 'jj'},\n fy: {year: 'jjjj', month: 'mm', day: 'dd'},\n ga: {year: 'bbbb', month: 'mm', day: 'll'},\n gd: {year: 'bbbb', month: 'mm', day: 'll'},\n gl: {year: 'aaaa', month: 'mm', day: 'dd'},\n he: {year: 'שנה', month: 'חודש', day: 'יום'},\n hr: {year: 'gggg', month: 'mm', day: 'dd'},\n hsb: {year: 'llll', month: 'mm', day: 'dd'},\n hu: {year: 'éééé', month: 'hh', day: 'nn'},\n ia: {year: 'aaaa', month: 'mm', day: 'dd'},\n id: {year: 'tttt', month: 'bb', day: 'hh'},\n it: {year: 'aaaa', month: 'mm', day: 'gg'},\n ja: {year: '年', month: '月', day: '日'},\n ka: {year: 'წწწწ', month: 'თთ', day: 'რრ'},\n kk: {year: 'жжжж', month: 'аа', day: 'кк'},\n kn: {year: 'ವವವವ', month: 'ಮಿಮೀ', day: 'ದಿದಿ'},\n ko: {year: '연도', month: '월', day: '일'},\n lb: {year: 'jjjj', month: 'mm', day: 'dd'},\n lo: {year: 'ປປປປ', month: 'ດດ', day: 'ວວ'},\n lt: {year: 'mmmm', month: 'mm', day: 'dd'},\n lv: {year: 'gggg', month: 'mm', day: 'dd'},\n meh: {year: 'aaaa', month: 'mm', day: 'dd'},\n ml: {year: 'വർഷം', month: 'മാസം', day: 'തീയതി'},\n ms: {year: 'tttt', month: 'mm', day: 'hh'},\n nl: {year: 'jjjj', month: 'mm', day: 'dd'},\n nn: {year: 'åååå', month: 'mm', day: 'dd'},\n no: {year: 'åååå', month: 'mm', day: 'dd'},\n oc: {year: 'aaaa', month: 'mm', day: 'jj'},\n pl: {year: 'rrrr', month: 'mm', day: 'dd'},\n pt: {year: 'aaaa', month: 'mm', day: 'dd'},\n rm: {year: 'oooo', month: 'mm', day: 'dd'},\n ro: {year: 'aaaa', month: 'll', day: 'zz'},\n ru: {year: 'гггг', month: 'мм', day: 'дд'},\n sc: {year: 'aaaa', month: 'mm', day: 'dd'},\n scn: {year: 'aaaa', month: 'mm', day: 'jj'},\n sk: {year: 'rrrr', month: 'mm', day: 'dd'},\n sl: {year: 'llll', month: 'mm', day: 'dd'},\n sr: {year: 'гггг', month: 'мм', day: 'дд'},\n sv: {year: 'åååå', month: 'mm', day: 'dd'},\n szl: {year: 'rrrr', month: 'mm', day: 'dd'},\n tg: {year: 'сссс', month: 'мм', day: 'рр'},\n th: {year: 'ปปปป', month: 'ดด', day: 'วว'},\n tr: {year: 'yyyy', month: 'aa', day: 'gg'},\n uk: {year: 'рррр', month: 'мм', day: 'дд'},\n 'zh-CN': {year: '年', month: '月', day: '日'},\n 'zh-TW': {year: '年', month: '月', day: '日'}\n}, 'en');\n\nexport function getPlaceholder(field: string, value: string, locale: string) {\n // Use the actual placeholder value for the era and day period fields.\n if (field === 'era' || field === 'dayPeriod') {\n return value;\n }\n\n if (field === 'year' || field === 'month' || field === 'day') {\n return placeholders.getStringForLocale(field, locale);\n }\n\n // For time fields (e.g. hour, minute, etc.), use two dashes as the placeholder.\n return '––';\n}\n"],"names":[],"version":3,"file":"placeholders.main.js.map"}
|
package/dist/placeholders.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAID,8EAA8E;AAC9E,4EAA4E;AAC5E,mDAAmD;AACnD,MAAM,qCAAe,IAAI,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M;QAAQ,OAAO;QAAM,KAAK;IAAI;IACzC,IAAI;QAAC,MAAM;QAAQ,OAAO;QAAM,KAAK;IAAI;IACzC,KAAK;QAAC,MAAM;QAAQ,OAAO;QAAM,KAAK;IAAI;IAC1C,IAAI;QAAC,MAAM;QAAQ,OAAO;QAAM,KAAK;IAAI;IACzC,IAAI;QAAC,MAAM;QAAQ,OAAO;QAAM,KAAK;IAAI;IACzC,IAAI;QAAC,MAAM;QAAQ,OAAO;QAAM,KAAK;IAAI;IACzC,IAAI;QAAC,MAAM;QAAQ,OAAO;QAAM,KAAK;IAAI;IACzC,SAAS;QAAC,MAAM;QAAK,OAAO;QAAK,KAAK;IAAG;IACzC,SAAS;QAAC,MAAM;QAAK,OAAO;QAAK,KAAK;IAAG;AAC3C,GAAG;AAEI,SAAS,0CAAe,KAAa,EAAE,KAAa,EAAE,MAAc;IACzE,sEAAsE;IACtE,IAAI,UAAU,SAAS,UAAU,aAC/B,OAAO;IAGT,IAAI,UAAU,UAAU,UAAU,WAAW,UAAU,OACrD,OAAO,mCAAa,kBAAkB,CAAC,OAAO;IAGhD,gFAAgF;IAChF,OAAO;AACT","sources":["packages/@react-stately/datepicker/src/placeholders.ts"],"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 {LocalizedStringDictionary} from '@internationalized/string';\n\n// These placeholders are based on the strings used by the <input type=\"date\">\n// implementations in Chrome and Firefox. Additional languages are supported\n// here than React Spectrum's typical translations.\nconst placeholders = new LocalizedStringDictionary({\n ach: {year: 'mwaka', month: 'dwe', day: 'nino'},\n af: {year: 'jjjj', month: 'mm', day: 'dd'},\n am: {year: 'ዓዓዓዓ', month: 'ሚሜ', day: 'ቀቀ'},\n an: {year: 'aaaa', month: 'mm', day: 'dd'},\n ar: {year: 'سنة', month: 'شهر', day: 'يوم'},\n ast: {year: 'aaaa', month: 'mm', day: 'dd'},\n az: {year: 'iiii', month: 'aa', day: 'gg'},\n be: {year: 'гггг', month: 'мм', day: 'дд'},\n bg: {year: 'гггг', month: 'мм', day: 'дд'},\n bn: {year: 'yyyy', month: 'মিমি', day: 'dd'},\n br: {year: 'bbbb', month: 'mm', day: 'dd'},\n bs: {year: 'gggg', month: 'mm', day: 'dd'},\n ca: {year: 'aaaa', month: 'mm', day: 'dd'},\n cak: {year: 'jjjj', month: 'ii', day: \"q'q'\"},\n ckb: {year: 'ساڵ', month: 'مانگ', day: 'ڕۆژ'},\n cs: {year: 'rrrr', month: 'mm', day: 'dd'},\n cy: {year: 'bbbb', month: 'mm', day: 'dd'},\n da: {year: 'åååå', month: 'mm', day: 'dd'},\n de: {year: 'jjjj', month: 'mm', day: 'tt'},\n dsb: {year: 'llll', month: 'mm', day: 'źź'},\n el: {year: 'εεεε', month: 'μμ', day: 'ηη'},\n en: {year: 'yyyy', month: 'mm', day: 'dd'},\n eo: {year: 'jjjj', month: 'mm', day: 'tt'},\n es: {year: 'aaaa', month: 'mm', day: 'dd'},\n et: {year: 'aaaa', month: 'kk', day: 'pp'},\n eu: {year: 'uuuu', month: 'hh', day: 'ee'},\n fa: {year: 'سال', month: 'ماه', day: 'روز'},\n ff: {year: 'hhhh', month: 'll', day: 'ññ'},\n fi: {year: 'vvvv', month: 'kk', day: 'pp'},\n fr: {year: 'aaaa', month: 'mm', day: 'jj'},\n fy: {year: 'jjjj', month: 'mm', day: 'dd'},\n ga: {year: 'bbbb', month: 'mm', day: 'll'},\n gd: {year: 'bbbb', month: 'mm', day: 'll'},\n gl: {year: 'aaaa', month: 'mm', day: 'dd'},\n he: {year: 'שנה', month: 'חודש', day: 'יום'},\n hr: {year: 'gggg', month: 'mm', day: 'dd'},\n hsb: {year: 'llll', month: 'mm', day: 'dd'},\n hu: {year: 'éééé', month: 'hh', day: 'nn'},\n ia: {year: 'aaaa', month: 'mm', day: 'dd'},\n id: {year: 'tttt', month: 'bb', day: 'hh'},\n it: {year: 'aaaa', month: 'mm', day: 'gg'},\n ja: {year: '年', month: '月', day: '日'},\n ka: {year: 'წწწწ', month: 'თთ', day: 'რრ'},\n kk: {year: 'жжжж', month: 'аа', day: 'кк'},\n kn: {year: 'ವವವವ', month: 'ಮಿಮೀ', day: 'ದಿದಿ'},\n ko: {year: '연도', month: '월', day: '일'},\n lb: {year: 'jjjj', month: 'mm', day: 'dd'},\n lo: {year: 'ປປປປ', month: 'ດດ', day: 'ວວ'},\n lt: {year: 'mmmm', month: 'mm', day: 'dd'},\n lv: {year: 'gggg', month: 'mm', day: 'dd'},\n meh: {year: 'aaaa', month: 'mm', day: 'dd'},\n ml: {year: 'വർഷം', month: 'മാസം', day: 'തീയതി'},\n ms: {year: 'tttt', month: 'mm', day: 'hh'},\n nl: {year: 'jjjj', month: 'mm', day: 'dd'},\n nn: {year: 'åååå', month: 'mm', day: 'dd'},\n no: {year: 'åååå', month: 'mm', day: 'dd'},\n oc: {year: 'aaaa', month: 'mm', day: 'jj'},\n pl: {year: 'rrrr', month: 'mm', day: 'dd'},\n pt: {year: 'aaaa', month: 'mm', day: 'dd'},\n rm: {year: 'oooo', month: 'mm', day: 'dd'},\n ro: {year: 'aaaa', month: 'll', day: 'zz'},\n ru: {year: 'гггг', month: 'мм', day: 'дд'},\n sc: {year: 'aaaa', month: 'mm', day: 'dd'},\n scn: {year: 'aaaa', month: 'mm', day: 'jj'},\n sk: {year: 'rrrr', month: 'mm', day: 'dd'},\n sl: {year: 'llll', month: 'mm', day: 'dd'},\n sr: {year: 'гггг', month: 'мм', day: 'дд'},\n sv: {year: 'åååå', month: 'mm', day: 'dd'},\n szl: {year: 'rrrr', month: 'mm', day: 'dd'},\n tg: {year: 'сссс', month: 'мм', day: 'рр'},\n th: {year: 'ปปปป', month: 'ดด', day: 'วว'},\n tr: {year: 'yyyy', month: 'aa', day: 'gg'},\n uk: {year: 'рррр', month: 'мм', day: 'дд'},\n 'zh-CN': {year: '年', month: '月', day: '日'},\n 'zh-TW': {year: '年', month: '月', day: '日'}\n}, 'en');\n\nexport function getPlaceholder(field: string, value: string, locale: string) {\n // Use the actual placeholder value for the era and day period fields.\n if (field === 'era' || field === 'dayPeriod') {\n return value;\n }\n\n if (field === 'year' || field === 'month' || field === 'day') {\n return placeholders.getStringForLocale(field, locale);\n }\n\n // For time fields (e.g. hour, minute, etc.), use two dashes as the placeholder.\n return '––';\n}\n"],"names":[],"version":3,"file":"placeholders.module.js.map"}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;AA2HA,oBAA2B,IAAI,CAAC,KAAK,qBAAqB,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC,CAAC;AACrH;IACE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,gBAAgB,GAAG,CAAC,CAAC,aAAa,CAAC,CAAC;IAClD,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,gBAAgB,GAAG,CAAC,CAAC,aAAa,CAAC,CAAC;IACxE,SAAS,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uBAAuB,CAAC,EAAE,OAAO,CAAA;CAClC;AC/GD,wCAAwC,CAAC,SAAS,SAAS,CAAE,SAAQ,gBAAgB,CAAC,CAAC;IACrF;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,CAAA;CAChD;AAED,gCAAiC,SAAQ,mBAAmB,EAAE,mBAAmB;IAC/E,m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C;IACjB,sDAAsD;IACtD,MAAM,EAAE,OAAO,CAAC;IAChB,iDAAiD;IACjD,OAAO,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B;;;OAGG;IACH,eAAe,EAAE,eAAe,GAAG,IAAI,CAAC;IACxC,4GAA4G;IAC5G,SAAS,EAAE,OAAO,CAAC;IACnB,0DAA0D;IAC1D,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,GAAG;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAC,GAAG,IAAI,CAAC;IAC7F,+CAA+C;IAC/C,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,gBAAgB,GAAG,aAAa,CAAA;CACjF;AAED;;;;GAIG;AACH,wCAAwC,CAAC,SAAS,SAAS,GAAG,SAAS,EAAE,KAAK,EAAE,4BAA4B,CAAC,CAAC,GAAG,oBAAoB,CA6OpI;AC7SD,uCAAuC,CAAC,SAAS,SAAS,GAAG,SAAS,CAAE,SAAQ,gBAAgB,CAAC,CAAC;IAChG,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAA;CACf;AAED,+BAAgC,SAAQ,cAAc;IACpD,8BAA8B;IAC9B,SAAS,EAAE,IAAI,CAAA;CAChB;AAED;;;;GAIG;AACH,kCAAkC,CAAC,SAAS,SAAS,GAAG,SAAS,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC,GAAG,cAAc,CAmDlH","sources":["packages/@react-stately/datepicker/src/packages/@react-stately/datepicker/src/utils.ts","packages/@react-stately/datepicker/src/packages/@react-stately/datepicker/src/useDatePickerState.ts","packages/@react-stately/datepicker/src/packages/@react-stately/datepicker/src/placeholders.ts","packages/@react-stately/datepicker/src/packages/@react-stately/datepicker/src/useDateFieldState.ts","packages/@react-stately/datepicker/src/packages/@react-stately/datepicker/src/useDateRangePickerState.ts","packages/@react-stately/datepicker/src/packages/@react-stately/datepicker/src/useTimeFieldState.ts","packages/@react-stately/datepicker/src/packages/@react-stately/datepicker/src/index.ts","packages/@react-stately/datepicker/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,"/*\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\nexport {useDatePickerState} from './useDatePickerState';\nexport {useDateFieldState} from './useDateFieldState';\nexport {useDateRangePickerState} from './useDateRangePickerState';\nexport {useTimeFieldState} from './useTimeFieldState';\n\nexport type {DateFieldStateOptions, DateFieldState, DateSegment, SegmentType} from './useDateFieldState';\nexport type {DatePickerStateOptions, DatePickerState} from './useDatePickerState';\nexport type {DateRangePickerStateOptions, DateRangePickerState} from './useDateRangePickerState';\nexport type {TimeFieldStateOptions, TimeFieldState} from './useTimeFieldState';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
|
@@ -168,27 +168,15 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
168
168
|
displayValue,
|
|
169
169
|
timeZone
|
|
170
170
|
]);
|
|
171
|
-
let segments = (0, $iqS8N$react.useMemo)(()
|
|
172
|
-
let isEditable = $596a1f0f523d6752$var$EDITABLE_SEGMENTS[segment.type];
|
|
173
|
-
if (segment.type === 'era' && calendar.getEras().length === 1) isEditable = false;
|
|
174
|
-
let isPlaceholder = $596a1f0f523d6752$var$EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type];
|
|
175
|
-
let placeholder = $596a1f0f523d6752$var$EDITABLE_SEGMENTS[segment.type] ? (0, $e1e8ada727fae1a1$exports.getPlaceholder)(segment.type, segment.value, locale) : null;
|
|
176
|
-
return {
|
|
177
|
-
type: $596a1f0f523d6752$var$TYPE_MAPPING[segment.type] || segment.type,
|
|
178
|
-
text: isPlaceholder ? placeholder : segment.value,
|
|
179
|
-
...$596a1f0f523d6752$var$getSegmentLimits(displayValue, segment.type, resolvedOptions),
|
|
180
|
-
isPlaceholder: isPlaceholder,
|
|
181
|
-
placeholder: placeholder,
|
|
182
|
-
isEditable: isEditable
|
|
183
|
-
};
|
|
184
|
-
}), [
|
|
171
|
+
let segments = (0, $iqS8N$react.useMemo)(()=>$596a1f0f523d6752$var$processSegments(dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity), [
|
|
185
172
|
dateValue,
|
|
186
173
|
validSegments,
|
|
187
174
|
dateFormatter,
|
|
188
175
|
resolvedOptions,
|
|
189
176
|
displayValue,
|
|
190
177
|
calendar,
|
|
191
|
-
locale
|
|
178
|
+
locale,
|
|
179
|
+
granularity
|
|
192
180
|
]);
|
|
193
181
|
// When the era field appears, mark it valid if the year field is already valid.
|
|
194
182
|
// If the era field disappears, remove it from the valid segments.
|
|
@@ -295,7 +283,10 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
295
283
|
else if (!isPM && shouldBePM) value = displayValue.set({
|
|
296
284
|
hour: displayValue.hour + 12
|
|
297
285
|
});
|
|
298
|
-
} else if (part in displayValue) value = displayValue.set({
|
|
286
|
+
} else if (part === 'hour' && 'hour' in displayValue && displayValue.hour >= 12 && validSegments.dayPeriod) value = displayValue.set({
|
|
287
|
+
hour: placeholder['hour'] + 12
|
|
288
|
+
});
|
|
289
|
+
else if (part in displayValue) value = displayValue.set({
|
|
299
290
|
[part]: placeholder[part]
|
|
300
291
|
});
|
|
301
292
|
setDate(null);
|
|
@@ -317,6 +308,66 @@ function $596a1f0f523d6752$export$60e84778edff6d26(props) {
|
|
|
317
308
|
}
|
|
318
309
|
};
|
|
319
310
|
}
|
|
311
|
+
function $596a1f0f523d6752$var$processSegments(dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity) {
|
|
312
|
+
let timeValue = [
|
|
313
|
+
'hour',
|
|
314
|
+
'minute',
|
|
315
|
+
'second'
|
|
316
|
+
];
|
|
317
|
+
let segments = dateFormatter.formatToParts(dateValue);
|
|
318
|
+
let processedSegments = [];
|
|
319
|
+
for (let segment of segments){
|
|
320
|
+
let isEditable = $596a1f0f523d6752$var$EDITABLE_SEGMENTS[segment.type];
|
|
321
|
+
if (segment.type === 'era' && calendar.getEras().length === 1) isEditable = false;
|
|
322
|
+
let isPlaceholder = $596a1f0f523d6752$var$EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type];
|
|
323
|
+
let placeholder = $596a1f0f523d6752$var$EDITABLE_SEGMENTS[segment.type] ? (0, $e1e8ada727fae1a1$exports.getPlaceholder)(segment.type, segment.value, locale) : null;
|
|
324
|
+
let dateSegment = {
|
|
325
|
+
type: $596a1f0f523d6752$var$TYPE_MAPPING[segment.type] || segment.type,
|
|
326
|
+
text: isPlaceholder ? placeholder : segment.value,
|
|
327
|
+
...$596a1f0f523d6752$var$getSegmentLimits(displayValue, segment.type, resolvedOptions),
|
|
328
|
+
isPlaceholder: isPlaceholder,
|
|
329
|
+
placeholder: placeholder,
|
|
330
|
+
isEditable: isEditable
|
|
331
|
+
};
|
|
332
|
+
// There is an issue in RTL languages where time fields render (minute:hour) instead of (hour:minute).
|
|
333
|
+
// To force an LTR direction on the time field since, we wrap the time segments in LRI (left-to-right) isolate unicode. See https://www.w3.org/International/questions/qa-bidi-unicode-controls.
|
|
334
|
+
// These unicode characters will be added to the array of processed segments as literals and will mark the start and end of the embedded direction change.
|
|
335
|
+
if (segment.type === 'hour') {
|
|
336
|
+
// This marks the start of the embedded direction change.
|
|
337
|
+
processedSegments.push({
|
|
338
|
+
type: 'literal',
|
|
339
|
+
text: '\u2066',
|
|
340
|
+
...$596a1f0f523d6752$var$getSegmentLimits(displayValue, 'literal', resolvedOptions),
|
|
341
|
+
isPlaceholder: false,
|
|
342
|
+
placeholder: '',
|
|
343
|
+
isEditable: false
|
|
344
|
+
});
|
|
345
|
+
processedSegments.push(dateSegment);
|
|
346
|
+
// This marks the end of the embedded direction change in the case that the granularity it set to "hour".
|
|
347
|
+
if (segment.type === granularity) processedSegments.push({
|
|
348
|
+
type: 'literal',
|
|
349
|
+
text: '\u2069',
|
|
350
|
+
...$596a1f0f523d6752$var$getSegmentLimits(displayValue, 'literal', resolvedOptions),
|
|
351
|
+
isPlaceholder: false,
|
|
352
|
+
placeholder: '',
|
|
353
|
+
isEditable: false
|
|
354
|
+
});
|
|
355
|
+
} else if (timeValue.includes(segment.type) && segment.type === granularity) {
|
|
356
|
+
processedSegments.push(dateSegment);
|
|
357
|
+
// This marks the end of the embedded direction change.
|
|
358
|
+
processedSegments.push({
|
|
359
|
+
type: 'literal',
|
|
360
|
+
text: '\u2069',
|
|
361
|
+
...$596a1f0f523d6752$var$getSegmentLimits(displayValue, 'literal', resolvedOptions),
|
|
362
|
+
isPlaceholder: false,
|
|
363
|
+
placeholder: '',
|
|
364
|
+
isEditable: false
|
|
365
|
+
});
|
|
366
|
+
} else // We only want to "wrap" the unicode around segments that are hour, minute, or second. If they aren't, just process as normal.
|
|
367
|
+
processedSegments.push(dateSegment);
|
|
368
|
+
}
|
|
369
|
+
return processedSegments;
|
|
370
|
+
}
|
|
320
371
|
function $596a1f0f523d6752$var$getSegmentLimits(date, type, options) {
|
|
321
372
|
switch(type){
|
|
322
373
|
case 'era':
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AA0FD,MAAM,0CAAoB;IACxB,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,KAAK;AACP;AAEA,MAAM,kCAAY;IAChB,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,QAAQ;IACR,QAAQ;AACV;AAEA,mDAAmD;AACnD,MAAM,qCAAe;IACnB,WAAW;AAC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Q,MAAM,IAAI;gBACtB,IAAI,QAAQ,SAAS;gBACrB,IAAI,OAAO,gBAAgB;gBAC3B,IAAI,SAAS,OACX,OAAO;gBAET,OAAO,MAAM,GAAG,CAAC;oBAAC,MAAM,QAAQ,QAAQ,KAAK,QAAQ;gBAAE;YACzD;QACA,KAAK;YACH,qDAAqD;YACrD,IAAI,QAAQ,MAAM,EAAE;gBAClB,IAAI,QAAQ,MAAM,IAAI;gBACtB,IAAI,QAAQ,SAAS;gBACrB,IAAI,CAAC,SAAS,iBAAiB,IAC7B,eAAe;gBAEjB,IAAI,SAAS,eAAe,IAC1B,gBAAgB;YAEpB;QACA,cAAc;QAChB,KAAK;QACL,KAAK;YACH,OAAO,MAAM,GAAG,CAAC;gBAAC,CAAC,KAAK,EAAE;YAAY;IAC1C;IAGF,MAAM,IAAI,MAAM,sBAAsB;AACxC","sources":["packages/@react-stately/datepicker/src/useDateFieldState.ts"],"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 {Calendar, DateFormatter, getMinimumDayInMonth, getMinimumMonthInYear, GregorianCalendar, toCalendar} from '@internationalized/date';\nimport {convertValue, createPlaceholderDate, FieldOptions, FormatterOptions, getFormatOptions, getValidationResult, useDefaultProps} from './utils';\nimport {DatePickerProps, DateValue, Granularity, MappedDateValue} from '@react-types/datepicker';\nimport {FormValidationState, useFormValidationState} from '@react-stately/form';\nimport {getPlaceholder} from './placeholders';\nimport {useControlledState} from '@react-stately/utils';\nimport {useEffect, useMemo, useRef, useState} from 'react';\nimport {ValidationState} from '@react-types/shared';\n\nexport type SegmentType = 'era' | 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'dayPeriod' | 'literal' | 'timeZoneName';\nexport interface DateSegment {\n /** The type of segment. */\n type: SegmentType,\n /** The formatted text for the segment. */\n text: string,\n /** The numeric value for the segment, if applicable. */\n value?: number,\n /** The minimum numeric value for the segment, if applicable. */\n minValue?: number,\n /** The maximum numeric value for the segment, if applicable. */\n maxValue?: number,\n /** Whether the value is a placeholder. */\n isPlaceholder: boolean,\n /** A placeholder string for the segment. */\n placeholder: string,\n /** Whether the segment is editable. */\n isEditable: boolean\n}\n\nexport interface DateFieldState extends FormValidationState {\n /** The current field value. */\n value: DateValue | null,\n /** The current value, converted to a native JavaScript `Date` object. */\n dateValue: Date,\n /** The calendar system currently in use. */\n calendar: Calendar,\n /** Sets the field's value. */\n setValue(value: DateValue | null): void,\n /** A list of segments for the current value. */\n segments: DateSegment[],\n /** A date formatter configured for the current locale and format. */\n dateFormatter: DateFormatter,\n /**\n * The current validation state of the date field, based on the `validationState`, `minValue`, and `maxValue` props.\n * @deprecated Use `isInvalid` instead.\n */\n validationState: ValidationState | null,\n /** Whether the date field is invalid, based on the `isInvalid`, `minValue`, and `maxValue` props. */\n isInvalid: boolean,\n /** The granularity for the field, based on the `granularity` prop and current value. */\n granularity: Granularity,\n /** The maximum date or time unit that is displayed in the field. */\n maxGranularity: 'year' | 'month' | Granularity,\n /** Whether the field is disabled. */\n isDisabled: boolean,\n /** Whether the field is read only. */\n isReadOnly: boolean,\n /** Whether the field is required. */\n isRequired: boolean,\n /** Increments the given segment. Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */\n increment(type: SegmentType): void,\n /** Decrements the given segment. Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */\n decrement(type: SegmentType): void,\n /**\n * Increments the given segment by a larger amount, rounding it to the nearest increment.\n * The amount to increment by depends on the field, for example 15 minutes, 7 days, and 5 years.\n * Upon reaching the minimum or maximum value, the value wraps around to the opposite limit.\n */\n incrementPage(type: SegmentType): void,\n /**\n * Decrements the given segment by a larger amount, rounding it to the nearest increment.\n * The amount to decrement by depends on the field, for example 15 minutes, 7 days, and 5 years.\n * Upon reaching the minimum or maximum value, the value wraps around to the opposite limit.\n */\n decrementPage(type: SegmentType): void,\n /** Sets the value of the given segment. */\n setSegment(type: 'era', value: string): void,\n setSegment(type: SegmentType, value: number): void,\n /** Updates the remaining unfilled segments with the placeholder value. */\n confirmPlaceholder(): void,\n /** Clears the value of the given segment, reverting it to the placeholder. */\n clearSegment(type: SegmentType): void,\n /** Formats the current date value using the given options. */\n formatValue(fieldOptions: FieldOptions): string,\n /** Gets a formatter based on state's props. */\n getDateFormatter(locale: string, formatOptions: FormatterOptions): DateFormatter\n}\n\nconst EDITABLE_SEGMENTS = {\n year: true,\n month: true,\n day: true,\n hour: true,\n minute: true,\n second: true,\n dayPeriod: true,\n era: true\n};\n\nconst PAGE_STEP = {\n year: 5,\n month: 2,\n day: 7,\n hour: 2,\n minute: 15,\n second: 15\n};\n\n// Node seems to convert everything to lowercase...\nconst TYPE_MAPPING = {\n dayperiod: 'dayPeriod'\n};\n\nexport interface DateFieldStateOptions<T extends DateValue = DateValue> extends DatePickerProps<T> {\n /**\n * The maximum unit to display in the date field.\n * @default 'year'\n */\n maxGranularity?: 'year' | 'month' | Granularity,\n /** The locale to display and edit the value according to. */\n locale: string,\n /**\n * A function that creates a [Calendar](../internationalized/date/Calendar.html)\n * object for a given calendar identifier. Such a function may be imported from the\n * `@internationalized/date` package, or manually implemented to include support for\n * only certain calendars.\n */\n createCalendar: (name: string) => Calendar\n}\n\n/**\n * Provides state management for a date field component.\n * A date field allows users to enter and edit date and time values using a keyboard.\n * Each part of a date value is displayed in an individually editable segment.\n */\nexport function useDateFieldState<T extends DateValue = DateValue>(props: DateFieldStateOptions<T>): DateFieldState {\n let {\n locale,\n createCalendar,\n hideTimeZone,\n isDisabled = false,\n isReadOnly = false,\n isRequired = false,\n minValue,\n maxValue,\n isDateUnavailable\n } = props;\n\n let v: DateValue | null = props.value || props.defaultValue || props.placeholderValue || null;\n let [granularity, defaultTimeZone] = useDefaultProps(v, props.granularity);\n let timeZone = defaultTimeZone || 'UTC';\n\n // props.granularity must actually exist in the value if one is provided.\n if (v && !(granularity in v)) {\n throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());\n }\n\n let defaultFormatter = useMemo(() => new DateFormatter(locale), [locale]);\n let calendar = useMemo(() => createCalendar(defaultFormatter.resolvedOptions().calendar), [createCalendar, defaultFormatter]);\n\n let [value, setDate] = useControlledState<DateValue | null, MappedDateValue<T> | null>(\n props.value,\n props.defaultValue ?? null,\n props.onChange\n );\n\n let calendarValue = useMemo(() => convertValue(value, calendar) ?? null, [value, calendar]);\n\n // We keep track of the placeholder date separately in state so that onChange is not called\n // until all segments are set. If the value === null (not undefined), then assume the component\n // is controlled, so use the placeholder as the value until all segments are entered so it doesn't\n // change from uncontrolled to controlled and emit a warning.\n let [placeholderDate, setPlaceholderDate] = useState(\n () => createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone)\n );\n\n let val = calendarValue || placeholderDate;\n let showEra = calendar.identifier === 'gregory' && val.era === 'BC';\n let formatOpts = useMemo(() => ({\n granularity,\n maxGranularity: props.maxGranularity ?? 'year',\n timeZone: defaultTimeZone,\n hideTimeZone,\n hourCycle: props.hourCycle,\n showEra,\n shouldForceLeadingZeros: props.shouldForceLeadingZeros\n }), [props.maxGranularity, granularity, props.hourCycle, props.shouldForceLeadingZeros, defaultTimeZone, hideTimeZone, showEra]);\n let opts = useMemo(() => getFormatOptions({}, formatOpts), [formatOpts]);\n\n let dateFormatter = useMemo(() => new DateFormatter(locale, opts), [locale, opts]);\n let resolvedOptions = useMemo(() => dateFormatter.resolvedOptions(), [dateFormatter]);\n\n // Determine how many editable segments there are for validation purposes.\n // The result is cached for performance.\n let allSegments: Partial<typeof EDITABLE_SEGMENTS> = useMemo(() =>\n dateFormatter.formatToParts(new Date())\n .filter(seg => EDITABLE_SEGMENTS[seg.type])\n .reduce((p, seg) => (p[seg.type] = true, p), {})\n , [dateFormatter]);\n\n let [validSegments, setValidSegments] = useState<Partial<typeof EDITABLE_SEGMENTS>>(\n () => props.value || props.defaultValue ? {...allSegments} : {}\n );\n\n let clearedSegment = useRef<string | null>(null);\n\n // Reset placeholder when calendar changes\n let lastCalendarIdentifier = useRef(calendar.identifier);\n useEffect(() => {\n if (calendar.identifier !== lastCalendarIdentifier.current) {\n lastCalendarIdentifier.current = calendar.identifier;\n setPlaceholderDate(placeholder =>\n Object.keys(validSegments).length > 0\n ? toCalendar(placeholder, calendar)\n : createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone)\n );\n }\n }, [calendar, granularity, validSegments, defaultTimeZone, props.placeholderValue]);\n\n // If there is a value prop, and some segments were previously placeholders, mark them all as valid.\n if (value && Object.keys(validSegments).length < Object.keys(allSegments).length) {\n validSegments = {...allSegments};\n setValidSegments(validSegments);\n }\n\n // If the value is set to null and all segments are valid, reset the placeholder.\n if (value == null && Object.keys(validSegments).length === Object.keys(allSegments).length) {\n validSegments = {};\n setValidSegments(validSegments);\n setPlaceholderDate(createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone));\n }\n\n // If all segments are valid, use the date from state, otherwise use the placeholder date.\n let displayValue = calendarValue && Object.keys(validSegments).length >= Object.keys(allSegments).length ? calendarValue : placeholderDate;\n let setValue = (newValue: DateValue) => {\n if (props.isDisabled || props.isReadOnly) {\n return;\n }\n let validKeys = Object.keys(validSegments);\n let allKeys = Object.keys(allSegments);\n\n // if all the segments are completed or a timefield with everything but am/pm set the time, also ignore when am/pm cleared\n if (newValue == null) {\n setDate(null);\n setPlaceholderDate(createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone));\n setValidSegments({});\n } else if (validKeys.length >= allKeys.length || (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod && clearedSegment.current !== 'dayPeriod')) {\n // The display calendar should not have any effect on the emitted value.\n // Emit dates in the same calendar as the original value, if any, otherwise gregorian.\n newValue = toCalendar(newValue, v?.calendar || new GregorianCalendar());\n setDate(newValue);\n } else {\n setPlaceholderDate(newValue);\n }\n clearedSegment.current = null;\n };\n\n let dateValue = useMemo(() => displayValue.toDate(timeZone), [displayValue, timeZone]);\n let segments = useMemo(() =>\n dateFormatter.formatToParts(dateValue)\n .map(segment => {\n let isEditable = EDITABLE_SEGMENTS[segment.type];\n if (segment.type === 'era' && calendar.getEras().length === 1) {\n isEditable = false;\n }\n\n let isPlaceholder = EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type];\n let placeholder = EDITABLE_SEGMENTS[segment.type] ? getPlaceholder(segment.type, segment.value, locale) : null;\n return {\n type: TYPE_MAPPING[segment.type] || segment.type,\n text: isPlaceholder ? placeholder : segment.value,\n ...getSegmentLimits(displayValue, segment.type, resolvedOptions),\n isPlaceholder,\n placeholder,\n isEditable\n } as DateSegment;\n })\n , [dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale]);\n\n // When the era field appears, mark it valid if the year field is already valid.\n // If the era field disappears, remove it from the valid segments.\n if (allSegments.era && validSegments.year && !validSegments.era) {\n validSegments.era = true;\n setValidSegments({...validSegments});\n } else if (!allSegments.era && validSegments.era) {\n delete validSegments.era;\n setValidSegments({...validSegments});\n }\n\n let markValid = (part: Intl.DateTimeFormatPartTypes) => {\n validSegments[part] = true;\n if (part === 'year' && allSegments.era) {\n validSegments.era = true;\n }\n setValidSegments({...validSegments});\n };\n\n let adjustSegment = (type: Intl.DateTimeFormatPartTypes, amount: number) => {\n if (!validSegments[type]) {\n markValid(type);\n let validKeys = Object.keys(validSegments);\n let allKeys = Object.keys(allSegments);\n if (validKeys.length >= allKeys.length || (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod)) {\n setValue(displayValue);\n }\n } else {\n setValue(addSegment(displayValue, type, amount, resolvedOptions));\n }\n };\n\n let builtinValidation = useMemo(() => getValidationResult(\n value,\n minValue,\n maxValue,\n isDateUnavailable,\n formatOpts\n ), [value, minValue, maxValue, isDateUnavailable, formatOpts]);\n\n let validation = useFormValidationState({\n ...props,\n value: value as MappedDateValue<T> | null,\n builtinValidation\n });\n\n let isValueInvalid = validation.displayValidation.isInvalid;\n let validationState: ValidationState | null = props.validationState || (isValueInvalid ? 'invalid' : null);\n\n return {\n ...validation,\n value: calendarValue,\n dateValue,\n calendar,\n setValue,\n segments,\n dateFormatter,\n validationState,\n isInvalid: isValueInvalid,\n granularity,\n maxGranularity: props.maxGranularity ?? 'year',\n isDisabled,\n isReadOnly,\n isRequired,\n increment(part) {\n adjustSegment(part, 1);\n },\n decrement(part) {\n adjustSegment(part, -1);\n },\n incrementPage(part) {\n adjustSegment(part, PAGE_STEP[part] || 1);\n },\n decrementPage(part) {\n adjustSegment(part, -(PAGE_STEP[part] || 1));\n },\n setSegment(part, v: string | number) {\n markValid(part);\n setValue(setSegment(displayValue, part, v, resolvedOptions));\n },\n confirmPlaceholder() {\n if (props.isDisabled || props.isReadOnly) {\n return;\n }\n\n // Confirm the placeholder if only the day period is not filled in.\n let validKeys = Object.keys(validSegments);\n let allKeys = Object.keys(allSegments);\n if (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod) {\n validSegments = {...allSegments};\n setValidSegments(validSegments);\n setValue(displayValue.copy());\n }\n },\n clearSegment(part) {\n delete validSegments[part];\n clearedSegment.current = part;\n setValidSegments({...validSegments});\n\n let placeholder = createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone);\n let value = displayValue;\n\n // Reset day period to default without changing the hour.\n if (part === 'dayPeriod' && 'hour' in displayValue && 'hour' in placeholder) {\n let isPM = displayValue.hour >= 12;\n let shouldBePM = placeholder.hour >= 12;\n if (isPM && !shouldBePM) {\n value = displayValue.set({hour: displayValue.hour - 12});\n } else if (!isPM && shouldBePM) {\n value = displayValue.set({hour: displayValue.hour + 12});\n }\n } else if (part in displayValue) {\n value = displayValue.set({[part]: placeholder[part]});\n }\n\n setDate(null);\n setValue(value);\n },\n formatValue(fieldOptions: FieldOptions) {\n if (!calendarValue) {\n return '';\n }\n\n let formatOptions = getFormatOptions(fieldOptions, formatOpts);\n let formatter = new DateFormatter(locale, formatOptions);\n return formatter.format(dateValue);\n },\n getDateFormatter(locale, formatOptions: FormatterOptions) {\n let newOptions = {...formatOpts, ...formatOptions};\n let newFormatOptions = getFormatOptions({}, newOptions);\n return new DateFormatter(locale, newFormatOptions);\n }\n };\n}\n\nfunction getSegmentLimits(date: DateValue, type: string, options: Intl.ResolvedDateTimeFormatOptions) {\n switch (type) {\n case 'era': {\n let eras = date.calendar.getEras();\n return {\n value: eras.indexOf(date.era),\n minValue: 0,\n maxValue: eras.length - 1\n };\n }\n case 'year':\n return {\n value: date.year,\n minValue: 1,\n maxValue: date.calendar.getYearsInEra(date)\n };\n case 'month':\n return {\n value: date.month,\n minValue: getMinimumMonthInYear(date),\n maxValue: date.calendar.getMonthsInYear(date)\n };\n case 'day':\n return {\n value: date.day,\n minValue: getMinimumDayInMonth(date),\n maxValue: date.calendar.getDaysInMonth(date)\n };\n }\n\n if ('hour' in date) {\n switch (type) {\n case 'dayPeriod':\n return {\n value: date.hour >= 12 ? 12 : 0,\n minValue: 0,\n maxValue: 12\n };\n case 'hour':\n if (options.hour12) {\n let isPM = date.hour >= 12;\n return {\n value: date.hour,\n minValue: isPM ? 12 : 0,\n maxValue: isPM ? 23 : 11\n };\n }\n\n return {\n value: date.hour,\n minValue: 0,\n maxValue: 23\n };\n case 'minute':\n return {\n value: date.minute,\n minValue: 0,\n maxValue: 59\n };\n case 'second':\n return {\n value: date.second,\n minValue: 0,\n maxValue: 59\n };\n }\n }\n\n return {};\n}\n\nfunction addSegment(value: DateValue, part: string, amount: number, options: Intl.ResolvedDateTimeFormatOptions) {\n switch (part) {\n case 'era':\n case 'year':\n case 'month':\n case 'day':\n return value.cycle(part, amount, {round: part === 'year'});\n }\n\n if ('hour' in value) {\n switch (part) {\n case 'dayPeriod': {\n let hours = value.hour;\n let isPM = hours >= 12;\n return value.set({hour: isPM ? hours - 12 : hours + 12});\n }\n case 'hour':\n case 'minute':\n case 'second':\n return value.cycle(part, amount, {\n round: part !== 'hour',\n hourCycle: options.hour12 ? 12 : 24\n });\n }\n }\n\n throw new Error('Unknown segment: ' + part);\n}\n\nfunction setSegment(value: DateValue, part: string, segmentValue: number | string, options: Intl.ResolvedDateTimeFormatOptions) {\n switch (part) {\n case 'day':\n case 'month':\n case 'year':\n case 'era':\n return value.set({[part]: segmentValue});\n }\n\n if ('hour' in value && typeof segmentValue === 'number') {\n switch (part) {\n case 'dayPeriod': {\n let hours = value.hour;\n let wasPM = hours >= 12;\n let isPM = segmentValue >= 12;\n if (isPM === wasPM) {\n return value;\n }\n return value.set({hour: wasPM ? hours - 12 : hours + 12});\n }\n case 'hour':\n // In 12 hour time, ensure that AM/PM does not change\n if (options.hour12) {\n let hours = value.hour;\n let wasPM = hours >= 12;\n if (!wasPM && segmentValue === 12) {\n segmentValue = 0;\n }\n if (wasPM && segmentValue < 12) {\n segmentValue += 12;\n }\n }\n // fallthrough\n case 'minute':\n case 'second':\n return value.set({[part]: segmentValue});\n }\n }\n\n throw new Error('Unknown segment: ' + part);\n}\n"],"names":[],"version":3,"file":"useDateFieldState.main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AA0FD,MAAM,0CAAoB;IACxB,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,KAAK;AACP;AAEA,MAAM,kCAAY;IAChB,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,QAAQ;IACR,QAAQ;AACV;AAEA,mDAAmD;AACnD,MAAM,qCAAe;IACnB,WAAW;AACb;AAwBO,SAAS,0CAAmD,KAA+B;IAChG,IAAI,UACF,MAAM,kBACN,cAAc,gBACd,YAAY,cACZ,aAAa,mBACb,aAAa,mBACb,aA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AAQ,QAAQ,KAAK,QAAQ;gBAAE;YACzD;QACA,KAAK;YACH,qDAAqD;YACrD,IAAI,QAAQ,MAAM,EAAE;gBAClB,IAAI,QAAQ,MAAM,IAAI;gBACtB,IAAI,QAAQ,SAAS;gBACrB,IAAI,CAAC,SAAS,iBAAiB,IAC7B,eAAe;gBAEjB,IAAI,SAAS,eAAe,IAC1B,gBAAgB;YAEpB;QACA,cAAc;QAChB,KAAK;QACL,KAAK;YACH,OAAO,MAAM,GAAG,CAAC;gBAAC,CAAC,KAAK,EAAE;YAAY;IAC1C;IAGF,MAAM,IAAI,MAAM,sBAAsB;AACxC","sources":["packages/@react-stately/datepicker/src/useDateFieldState.ts"],"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 {Calendar, DateFormatter, getMinimumDayInMonth, getMinimumMonthInYear, GregorianCalendar, toCalendar} from '@internationalized/date';\nimport {convertValue, createPlaceholderDate, FieldOptions, FormatterOptions, getFormatOptions, getValidationResult, useDefaultProps} from './utils';\nimport {DatePickerProps, DateValue, Granularity, MappedDateValue} from '@react-types/datepicker';\nimport {FormValidationState, useFormValidationState} from '@react-stately/form';\nimport {getPlaceholder} from './placeholders';\nimport {useControlledState} from '@react-stately/utils';\nimport {useEffect, useMemo, useRef, useState} from 'react';\nimport {ValidationState} from '@react-types/shared';\n\nexport type SegmentType = 'era' | 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'dayPeriod' | 'literal' | 'timeZoneName';\nexport interface DateSegment {\n /** The type of segment. */\n type: SegmentType,\n /** The formatted text for the segment. */\n text: string,\n /** The numeric value for the segment, if applicable. */\n value?: number,\n /** The minimum numeric value for the segment, if applicable. */\n minValue?: number,\n /** The maximum numeric value for the segment, if applicable. */\n maxValue?: number,\n /** Whether the value is a placeholder. */\n isPlaceholder: boolean,\n /** A placeholder string for the segment. */\n placeholder: string,\n /** Whether the segment is editable. */\n isEditable: boolean\n}\n\nexport interface DateFieldState extends FormValidationState {\n /** The current field value. */\n value: DateValue | null,\n /** The current value, converted to a native JavaScript `Date` object. */\n dateValue: Date,\n /** The calendar system currently in use. */\n calendar: Calendar,\n /** Sets the field's value. */\n setValue(value: DateValue | null): void,\n /** A list of segments for the current value. */\n segments: DateSegment[],\n /** A date formatter configured for the current locale and format. */\n dateFormatter: DateFormatter,\n /**\n * The current validation state of the date field, based on the `validationState`, `minValue`, and `maxValue` props.\n * @deprecated Use `isInvalid` instead.\n */\n validationState: ValidationState | null,\n /** Whether the date field is invalid, based on the `isInvalid`, `minValue`, and `maxValue` props. */\n isInvalid: boolean,\n /** The granularity for the field, based on the `granularity` prop and current value. */\n granularity: Granularity,\n /** The maximum date or time unit that is displayed in the field. */\n maxGranularity: 'year' | 'month' | Granularity,\n /** Whether the field is disabled. */\n isDisabled: boolean,\n /** Whether the field is read only. */\n isReadOnly: boolean,\n /** Whether the field is required. */\n isRequired: boolean,\n /** Increments the given segment. Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */\n increment(type: SegmentType): void,\n /** Decrements the given segment. Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */\n decrement(type: SegmentType): void,\n /**\n * Increments the given segment by a larger amount, rounding it to the nearest increment.\n * The amount to increment by depends on the field, for example 15 minutes, 7 days, and 5 years.\n * Upon reaching the minimum or maximum value, the value wraps around to the opposite limit.\n */\n incrementPage(type: SegmentType): void,\n /**\n * Decrements the given segment by a larger amount, rounding it to the nearest increment.\n * The amount to decrement by depends on the field, for example 15 minutes, 7 days, and 5 years.\n * Upon reaching the minimum or maximum value, the value wraps around to the opposite limit.\n */\n decrementPage(type: SegmentType): void,\n /** Sets the value of the given segment. */\n setSegment(type: 'era', value: string): void,\n setSegment(type: SegmentType, value: number): void,\n /** Updates the remaining unfilled segments with the placeholder value. */\n confirmPlaceholder(): void,\n /** Clears the value of the given segment, reverting it to the placeholder. */\n clearSegment(type: SegmentType): void,\n /** Formats the current date value using the given options. */\n formatValue(fieldOptions: FieldOptions): string,\n /** Gets a formatter based on state's props. */\n getDateFormatter(locale: string, formatOptions: FormatterOptions): DateFormatter\n}\n\nconst EDITABLE_SEGMENTS = {\n year: true,\n month: true,\n day: true,\n hour: true,\n minute: true,\n second: true,\n dayPeriod: true,\n era: true\n};\n\nconst PAGE_STEP = {\n year: 5,\n month: 2,\n day: 7,\n hour: 2,\n minute: 15,\n second: 15\n};\n\n// Node seems to convert everything to lowercase...\nconst TYPE_MAPPING = {\n dayperiod: 'dayPeriod'\n};\n\nexport interface DateFieldStateOptions<T extends DateValue = DateValue> extends DatePickerProps<T> {\n /**\n * The maximum unit to display in the date field.\n * @default 'year'\n */\n maxGranularity?: 'year' | 'month' | Granularity,\n /** The locale to display and edit the value according to. */\n locale: string,\n /**\n * A function that creates a [Calendar](../internationalized/date/Calendar.html)\n * object for a given calendar identifier. Such a function may be imported from the\n * `@internationalized/date` package, or manually implemented to include support for\n * only certain calendars.\n */\n createCalendar: (name: string) => Calendar\n}\n\n/**\n * Provides state management for a date field component.\n * A date field allows users to enter and edit date and time values using a keyboard.\n * Each part of a date value is displayed in an individually editable segment.\n */\nexport function useDateFieldState<T extends DateValue = DateValue>(props: DateFieldStateOptions<T>): DateFieldState {\n let {\n locale,\n createCalendar,\n hideTimeZone,\n isDisabled = false,\n isReadOnly = false,\n isRequired = false,\n minValue,\n maxValue,\n isDateUnavailable\n } = props;\n\n let v: DateValue | null = props.value || props.defaultValue || props.placeholderValue || null;\n let [granularity, defaultTimeZone] = useDefaultProps(v, props.granularity);\n let timeZone = defaultTimeZone || 'UTC';\n\n // props.granularity must actually exist in the value if one is provided.\n if (v && !(granularity in v)) {\n throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());\n }\n\n let defaultFormatter = useMemo(() => new DateFormatter(locale), [locale]);\n let calendar = useMemo(() => createCalendar(defaultFormatter.resolvedOptions().calendar), [createCalendar, defaultFormatter]);\n\n let [value, setDate] = useControlledState<DateValue | null, MappedDateValue<T> | null>(\n props.value,\n props.defaultValue ?? null,\n props.onChange\n );\n\n let calendarValue = useMemo(() => convertValue(value, calendar) ?? null, [value, calendar]);\n\n // We keep track of the placeholder date separately in state so that onChange is not called\n // until all segments are set. If the value === null (not undefined), then assume the component\n // is controlled, so use the placeholder as the value until all segments are entered so it doesn't\n // change from uncontrolled to controlled and emit a warning.\n let [placeholderDate, setPlaceholderDate] = useState(\n () => createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone)\n );\n\n let val = calendarValue || placeholderDate;\n let showEra = calendar.identifier === 'gregory' && val.era === 'BC';\n let formatOpts = useMemo(() => ({\n granularity,\n maxGranularity: props.maxGranularity ?? 'year',\n timeZone: defaultTimeZone,\n hideTimeZone,\n hourCycle: props.hourCycle,\n showEra,\n shouldForceLeadingZeros: props.shouldForceLeadingZeros\n }), [props.maxGranularity, granularity, props.hourCycle, props.shouldForceLeadingZeros, defaultTimeZone, hideTimeZone, showEra]);\n let opts = useMemo(() => getFormatOptions({}, formatOpts), [formatOpts]);\n\n let dateFormatter = useMemo(() => new DateFormatter(locale, opts), [locale, opts]);\n let resolvedOptions = useMemo(() => dateFormatter.resolvedOptions(), [dateFormatter]);\n\n // Determine how many editable segments there are for validation purposes.\n // The result is cached for performance.\n let allSegments: Partial<typeof EDITABLE_SEGMENTS> = useMemo(() =>\n dateFormatter.formatToParts(new Date())\n .filter(seg => EDITABLE_SEGMENTS[seg.type])\n .reduce((p, seg) => (p[seg.type] = true, p), {})\n , [dateFormatter]);\n\n let [validSegments, setValidSegments] = useState<Partial<typeof EDITABLE_SEGMENTS>>(\n () => props.value || props.defaultValue ? {...allSegments} : {}\n );\n\n let clearedSegment = useRef<string | null>(null);\n\n // Reset placeholder when calendar changes\n let lastCalendarIdentifier = useRef(calendar.identifier);\n useEffect(() => {\n if (calendar.identifier !== lastCalendarIdentifier.current) {\n lastCalendarIdentifier.current = calendar.identifier;\n setPlaceholderDate(placeholder =>\n Object.keys(validSegments).length > 0\n ? toCalendar(placeholder, calendar)\n : createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone)\n );\n }\n }, [calendar, granularity, validSegments, defaultTimeZone, props.placeholderValue]);\n\n // If there is a value prop, and some segments were previously placeholders, mark them all as valid.\n if (value && Object.keys(validSegments).length < Object.keys(allSegments).length) {\n validSegments = {...allSegments};\n setValidSegments(validSegments);\n }\n\n // If the value is set to null and all segments are valid, reset the placeholder.\n if (value == null && Object.keys(validSegments).length === Object.keys(allSegments).length) {\n validSegments = {};\n setValidSegments(validSegments);\n setPlaceholderDate(createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone));\n }\n\n // If all segments are valid, use the date from state, otherwise use the placeholder date.\n let displayValue = calendarValue && Object.keys(validSegments).length >= Object.keys(allSegments).length ? calendarValue : placeholderDate;\n let setValue = (newValue: DateValue) => {\n if (props.isDisabled || props.isReadOnly) {\n return;\n }\n let validKeys = Object.keys(validSegments);\n let allKeys = Object.keys(allSegments);\n\n // if all the segments are completed or a timefield with everything but am/pm set the time, also ignore when am/pm cleared\n if (newValue == null) {\n setDate(null);\n setPlaceholderDate(createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone));\n setValidSegments({});\n } else if (validKeys.length >= allKeys.length || (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod && clearedSegment.current !== 'dayPeriod')) {\n // The display calendar should not have any effect on the emitted value.\n // Emit dates in the same calendar as the original value, if any, otherwise gregorian.\n newValue = toCalendar(newValue, v?.calendar || new GregorianCalendar());\n setDate(newValue);\n } else {\n setPlaceholderDate(newValue);\n }\n clearedSegment.current = null;\n };\n\n let dateValue = useMemo(() => displayValue.toDate(timeZone), [displayValue, timeZone]);\n let segments = useMemo(() => \n processSegments(dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity), \n [dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity]);\n\n // When the era field appears, mark it valid if the year field is already valid.\n // If the era field disappears, remove it from the valid segments.\n if (allSegments.era && validSegments.year && !validSegments.era) {\n validSegments.era = true;\n setValidSegments({...validSegments});\n } else if (!allSegments.era && validSegments.era) {\n delete validSegments.era;\n setValidSegments({...validSegments});\n }\n\n let markValid = (part: Intl.DateTimeFormatPartTypes) => {\n validSegments[part] = true;\n if (part === 'year' && allSegments.era) {\n validSegments.era = true;\n }\n setValidSegments({...validSegments});\n };\n\n let adjustSegment = (type: Intl.DateTimeFormatPartTypes, amount: number) => {\n if (!validSegments[type]) {\n markValid(type);\n let validKeys = Object.keys(validSegments);\n let allKeys = Object.keys(allSegments);\n if (validKeys.length >= allKeys.length || (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod)) {\n setValue(displayValue);\n }\n } else {\n setValue(addSegment(displayValue, type, amount, resolvedOptions));\n }\n };\n\n let builtinValidation = useMemo(() => getValidationResult(\n value,\n minValue,\n maxValue,\n isDateUnavailable,\n formatOpts\n ), [value, minValue, maxValue, isDateUnavailable, formatOpts]);\n\n let validation = useFormValidationState({\n ...props,\n value: value as MappedDateValue<T> | null,\n builtinValidation\n });\n\n let isValueInvalid = validation.displayValidation.isInvalid;\n let validationState: ValidationState | null = props.validationState || (isValueInvalid ? 'invalid' : null);\n\n return {\n ...validation,\n value: calendarValue,\n dateValue,\n calendar,\n setValue,\n segments,\n dateFormatter,\n validationState,\n isInvalid: isValueInvalid,\n granularity,\n maxGranularity: props.maxGranularity ?? 'year',\n isDisabled,\n isReadOnly,\n isRequired,\n increment(part) {\n adjustSegment(part, 1);\n },\n decrement(part) {\n adjustSegment(part, -1);\n },\n incrementPage(part) {\n adjustSegment(part, PAGE_STEP[part] || 1);\n },\n decrementPage(part) {\n adjustSegment(part, -(PAGE_STEP[part] || 1));\n },\n setSegment(part, v: string | number) {\n markValid(part);\n setValue(setSegment(displayValue, part, v, resolvedOptions));\n },\n confirmPlaceholder() {\n if (props.isDisabled || props.isReadOnly) {\n return;\n }\n\n // Confirm the placeholder if only the day period is not filled in.\n let validKeys = Object.keys(validSegments);\n let allKeys = Object.keys(allSegments);\n if (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod) {\n validSegments = {...allSegments};\n setValidSegments(validSegments);\n setValue(displayValue.copy());\n }\n },\n clearSegment(part) {\n delete validSegments[part];\n clearedSegment.current = part;\n setValidSegments({...validSegments});\n\n let placeholder = createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone);\n let value = displayValue;\n\n // Reset day period to default without changing the hour.\n if (part === 'dayPeriod' && 'hour' in displayValue && 'hour' in placeholder) {\n let isPM = displayValue.hour >= 12;\n let shouldBePM = placeholder.hour >= 12;\n if (isPM && !shouldBePM) {\n value = displayValue.set({hour: displayValue.hour - 12});\n } else if (!isPM && shouldBePM) {\n value = displayValue.set({hour: displayValue.hour + 12});\n }\n } else if (part === 'hour' && 'hour' in displayValue && displayValue.hour >= 12 && validSegments.dayPeriod) {\n value = displayValue.set({hour: placeholder['hour'] + 12});\n } else if (part in displayValue) {\n value = displayValue.set({[part]: placeholder[part]});\n }\n\n setDate(null);\n setValue(value);\n },\n formatValue(fieldOptions: FieldOptions) {\n if (!calendarValue) {\n return '';\n }\n\n let formatOptions = getFormatOptions(fieldOptions, formatOpts);\n let formatter = new DateFormatter(locale, formatOptions);\n return formatter.format(dateValue);\n },\n getDateFormatter(locale, formatOptions: FormatterOptions) {\n let newOptions = {...formatOpts, ...formatOptions};\n let newFormatOptions = getFormatOptions({}, newOptions);\n return new DateFormatter(locale, newFormatOptions);\n }\n };\n}\n\nfunction processSegments(dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity) : DateSegment[] {\n let timeValue = ['hour', 'minute', 'second'];\n let segments = dateFormatter.formatToParts(dateValue);\n let processedSegments: DateSegment[] = [];\n for (let segment of segments) {\n let isEditable = EDITABLE_SEGMENTS[segment.type];\n if (segment.type === 'era' && calendar.getEras().length === 1) {\n isEditable = false;\n }\n\n let isPlaceholder = EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type];\n let placeholder = EDITABLE_SEGMENTS[segment.type] ? getPlaceholder(segment.type, segment.value, locale) : null;\n\n let dateSegment = {\n type: TYPE_MAPPING[segment.type] || segment.type,\n text: isPlaceholder ? placeholder : segment.value,\n ...getSegmentLimits(displayValue, segment.type, resolvedOptions),\n isPlaceholder,\n placeholder,\n isEditable\n } as DateSegment;\n\n // There is an issue in RTL languages where time fields render (minute:hour) instead of (hour:minute).\n // To force an LTR direction on the time field since, we wrap the time segments in LRI (left-to-right) isolate unicode. See https://www.w3.org/International/questions/qa-bidi-unicode-controls.\n // These unicode characters will be added to the array of processed segments as literals and will mark the start and end of the embedded direction change. \n if (segment.type === 'hour') {\n // This marks the start of the embedded direction change. \n processedSegments.push({\n type: 'literal',\n text: '\\u2066',\n ...getSegmentLimits(displayValue, 'literal', resolvedOptions),\n isPlaceholder: false,\n placeholder: '',\n isEditable: false\n });\n processedSegments.push(dateSegment);\n // This marks the end of the embedded direction change in the case that the granularity it set to \"hour\".\n if (segment.type === granularity) {\n processedSegments.push({\n type: 'literal',\n text: '\\u2069',\n ...getSegmentLimits(displayValue, 'literal', resolvedOptions),\n isPlaceholder: false,\n placeholder: '',\n isEditable: false\n });\n }\n } else if (timeValue.includes(segment.type) && segment.type === granularity) {\n processedSegments.push(dateSegment);\n // This marks the end of the embedded direction change.\n processedSegments.push({\n type: 'literal',\n text: '\\u2069',\n ...getSegmentLimits(displayValue, 'literal', resolvedOptions),\n isPlaceholder: false,\n placeholder: '',\n isEditable: false\n });\n } else {\n // We only want to \"wrap\" the unicode around segments that are hour, minute, or second. If they aren't, just process as normal. \n processedSegments.push(dateSegment);\n }\n }\n\n return processedSegments;\n}\n\nfunction getSegmentLimits(date: DateValue, type: string, options: Intl.ResolvedDateTimeFormatOptions) {\n switch (type) {\n case 'era': {\n let eras = date.calendar.getEras();\n return {\n value: eras.indexOf(date.era),\n minValue: 0,\n maxValue: eras.length - 1\n };\n }\n case 'year':\n return {\n value: date.year,\n minValue: 1,\n maxValue: date.calendar.getYearsInEra(date)\n };\n case 'month':\n return {\n value: date.month,\n minValue: getMinimumMonthInYear(date),\n maxValue: date.calendar.getMonthsInYear(date)\n };\n case 'day':\n return {\n value: date.day,\n minValue: getMinimumDayInMonth(date),\n maxValue: date.calendar.getDaysInMonth(date)\n };\n }\n\n if ('hour' in date) {\n switch (type) {\n case 'dayPeriod':\n return {\n value: date.hour >= 12 ? 12 : 0,\n minValue: 0,\n maxValue: 12\n };\n case 'hour':\n if (options.hour12) {\n let isPM = date.hour >= 12;\n return {\n value: date.hour,\n minValue: isPM ? 12 : 0,\n maxValue: isPM ? 23 : 11\n };\n }\n\n return {\n value: date.hour,\n minValue: 0,\n maxValue: 23\n };\n case 'minute':\n return {\n value: date.minute,\n minValue: 0,\n maxValue: 59\n };\n case 'second':\n return {\n value: date.second,\n minValue: 0,\n maxValue: 59\n };\n }\n }\n\n return {};\n}\n\nfunction addSegment(value: DateValue, part: string, amount: number, options: Intl.ResolvedDateTimeFormatOptions) {\n switch (part) {\n case 'era':\n case 'year':\n case 'month':\n case 'day':\n return value.cycle(part, amount, {round: part === 'year'});\n }\n\n if ('hour' in value) {\n switch (part) {\n case 'dayPeriod': {\n let hours = value.hour;\n let isPM = hours >= 12;\n return value.set({hour: isPM ? hours - 12 : hours + 12});\n }\n case 'hour':\n case 'minute':\n case 'second':\n return value.cycle(part, amount, {\n round: part !== 'hour',\n hourCycle: options.hour12 ? 12 : 24\n });\n }\n }\n\n throw new Error('Unknown segment: ' + part);\n}\n\nfunction setSegment(value: DateValue, part: string, segmentValue: number | string, options: Intl.ResolvedDateTimeFormatOptions) {\n switch (part) {\n case 'day':\n case 'month':\n case 'year':\n case 'era':\n return value.set({[part]: segmentValue});\n }\n\n if ('hour' in value && typeof segmentValue === 'number') {\n switch (part) {\n case 'dayPeriod': {\n let hours = value.hour;\n let wasPM = hours >= 12;\n let isPM = segmentValue >= 12;\n if (isPM === wasPM) {\n return value;\n }\n return value.set({hour: wasPM ? hours - 12 : hours + 12});\n }\n case 'hour':\n // In 12 hour time, ensure that AM/PM does not change\n if (options.hour12) {\n let hours = value.hour;\n let wasPM = hours >= 12;\n if (!wasPM && segmentValue === 12) {\n segmentValue = 0;\n }\n if (wasPM && segmentValue < 12) {\n segmentValue += 12;\n }\n }\n // fallthrough\n case 'minute':\n case 'second':\n return value.set({[part]: segmentValue});\n }\n }\n\n throw new Error('Unknown segment: ' + part);\n}\n"],"names":[],"version":3,"file":"useDateFieldState.main.js.map"}
|
|
@@ -162,27 +162,15 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
|
|
|
162
162
|
displayValue,
|
|
163
163
|
timeZone
|
|
164
164
|
]);
|
|
165
|
-
let segments = (0, $g03ag$useMemo)(()
|
|
166
|
-
let isEditable = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type];
|
|
167
|
-
if (segment.type === 'era' && calendar.getEras().length === 1) isEditable = false;
|
|
168
|
-
let isPlaceholder = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type];
|
|
169
|
-
let placeholder = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type] ? (0, $3e3ed55ab2966714$export$d3f5c5e0a5023fa0)(segment.type, segment.value, locale) : null;
|
|
170
|
-
return {
|
|
171
|
-
type: $3c0fc76039f1c516$var$TYPE_MAPPING[segment.type] || segment.type,
|
|
172
|
-
text: isPlaceholder ? placeholder : segment.value,
|
|
173
|
-
...$3c0fc76039f1c516$var$getSegmentLimits(displayValue, segment.type, resolvedOptions),
|
|
174
|
-
isPlaceholder: isPlaceholder,
|
|
175
|
-
placeholder: placeholder,
|
|
176
|
-
isEditable: isEditable
|
|
177
|
-
};
|
|
178
|
-
}), [
|
|
165
|
+
let segments = (0, $g03ag$useMemo)(()=>$3c0fc76039f1c516$var$processSegments(dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity), [
|
|
179
166
|
dateValue,
|
|
180
167
|
validSegments,
|
|
181
168
|
dateFormatter,
|
|
182
169
|
resolvedOptions,
|
|
183
170
|
displayValue,
|
|
184
171
|
calendar,
|
|
185
|
-
locale
|
|
172
|
+
locale,
|
|
173
|
+
granularity
|
|
186
174
|
]);
|
|
187
175
|
// When the era field appears, mark it valid if the year field is already valid.
|
|
188
176
|
// If the era field disappears, remove it from the valid segments.
|
|
@@ -289,7 +277,10 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
|
|
|
289
277
|
else if (!isPM && shouldBePM) value = displayValue.set({
|
|
290
278
|
hour: displayValue.hour + 12
|
|
291
279
|
});
|
|
292
|
-
} else if (part in displayValue) value = displayValue.set({
|
|
280
|
+
} else if (part === 'hour' && 'hour' in displayValue && displayValue.hour >= 12 && validSegments.dayPeriod) value = displayValue.set({
|
|
281
|
+
hour: placeholder['hour'] + 12
|
|
282
|
+
});
|
|
283
|
+
else if (part in displayValue) value = displayValue.set({
|
|
293
284
|
[part]: placeholder[part]
|
|
294
285
|
});
|
|
295
286
|
setDate(null);
|
|
@@ -311,6 +302,66 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
|
|
|
311
302
|
}
|
|
312
303
|
};
|
|
313
304
|
}
|
|
305
|
+
function $3c0fc76039f1c516$var$processSegments(dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity) {
|
|
306
|
+
let timeValue = [
|
|
307
|
+
'hour',
|
|
308
|
+
'minute',
|
|
309
|
+
'second'
|
|
310
|
+
];
|
|
311
|
+
let segments = dateFormatter.formatToParts(dateValue);
|
|
312
|
+
let processedSegments = [];
|
|
313
|
+
for (let segment of segments){
|
|
314
|
+
let isEditable = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type];
|
|
315
|
+
if (segment.type === 'era' && calendar.getEras().length === 1) isEditable = false;
|
|
316
|
+
let isPlaceholder = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type];
|
|
317
|
+
let placeholder = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type] ? (0, $3e3ed55ab2966714$export$d3f5c5e0a5023fa0)(segment.type, segment.value, locale) : null;
|
|
318
|
+
let dateSegment = {
|
|
319
|
+
type: $3c0fc76039f1c516$var$TYPE_MAPPING[segment.type] || segment.type,
|
|
320
|
+
text: isPlaceholder ? placeholder : segment.value,
|
|
321
|
+
...$3c0fc76039f1c516$var$getSegmentLimits(displayValue, segment.type, resolvedOptions),
|
|
322
|
+
isPlaceholder: isPlaceholder,
|
|
323
|
+
placeholder: placeholder,
|
|
324
|
+
isEditable: isEditable
|
|
325
|
+
};
|
|
326
|
+
// There is an issue in RTL languages where time fields render (minute:hour) instead of (hour:minute).
|
|
327
|
+
// To force an LTR direction on the time field since, we wrap the time segments in LRI (left-to-right) isolate unicode. See https://www.w3.org/International/questions/qa-bidi-unicode-controls.
|
|
328
|
+
// These unicode characters will be added to the array of processed segments as literals and will mark the start and end of the embedded direction change.
|
|
329
|
+
if (segment.type === 'hour') {
|
|
330
|
+
// This marks the start of the embedded direction change.
|
|
331
|
+
processedSegments.push({
|
|
332
|
+
type: 'literal',
|
|
333
|
+
text: '\u2066',
|
|
334
|
+
...$3c0fc76039f1c516$var$getSegmentLimits(displayValue, 'literal', resolvedOptions),
|
|
335
|
+
isPlaceholder: false,
|
|
336
|
+
placeholder: '',
|
|
337
|
+
isEditable: false
|
|
338
|
+
});
|
|
339
|
+
processedSegments.push(dateSegment);
|
|
340
|
+
// This marks the end of the embedded direction change in the case that the granularity it set to "hour".
|
|
341
|
+
if (segment.type === granularity) processedSegments.push({
|
|
342
|
+
type: 'literal',
|
|
343
|
+
text: '\u2069',
|
|
344
|
+
...$3c0fc76039f1c516$var$getSegmentLimits(displayValue, 'literal', resolvedOptions),
|
|
345
|
+
isPlaceholder: false,
|
|
346
|
+
placeholder: '',
|
|
347
|
+
isEditable: false
|
|
348
|
+
});
|
|
349
|
+
} else if (timeValue.includes(segment.type) && segment.type === granularity) {
|
|
350
|
+
processedSegments.push(dateSegment);
|
|
351
|
+
// This marks the end of the embedded direction change.
|
|
352
|
+
processedSegments.push({
|
|
353
|
+
type: 'literal',
|
|
354
|
+
text: '\u2069',
|
|
355
|
+
...$3c0fc76039f1c516$var$getSegmentLimits(displayValue, 'literal', resolvedOptions),
|
|
356
|
+
isPlaceholder: false,
|
|
357
|
+
placeholder: '',
|
|
358
|
+
isEditable: false
|
|
359
|
+
});
|
|
360
|
+
} else // We only want to "wrap" the unicode around segments that are hour, minute, or second. If they aren't, just process as normal.
|
|
361
|
+
processedSegments.push(dateSegment);
|
|
362
|
+
}
|
|
363
|
+
return processedSegments;
|
|
364
|
+
}
|
|
314
365
|
function $3c0fc76039f1c516$var$getSegmentLimits(date, type, options) {
|
|
315
366
|
switch(type){
|
|
316
367
|
case 'era':
|
|
@@ -162,27 +162,15 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
|
|
|
162
162
|
displayValue,
|
|
163
163
|
timeZone
|
|
164
164
|
]);
|
|
165
|
-
let segments = (0, $g03ag$useMemo)(()
|
|
166
|
-
let isEditable = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type];
|
|
167
|
-
if (segment.type === 'era' && calendar.getEras().length === 1) isEditable = false;
|
|
168
|
-
let isPlaceholder = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type];
|
|
169
|
-
let placeholder = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type] ? (0, $3e3ed55ab2966714$export$d3f5c5e0a5023fa0)(segment.type, segment.value, locale) : null;
|
|
170
|
-
return {
|
|
171
|
-
type: $3c0fc76039f1c516$var$TYPE_MAPPING[segment.type] || segment.type,
|
|
172
|
-
text: isPlaceholder ? placeholder : segment.value,
|
|
173
|
-
...$3c0fc76039f1c516$var$getSegmentLimits(displayValue, segment.type, resolvedOptions),
|
|
174
|
-
isPlaceholder: isPlaceholder,
|
|
175
|
-
placeholder: placeholder,
|
|
176
|
-
isEditable: isEditable
|
|
177
|
-
};
|
|
178
|
-
}), [
|
|
165
|
+
let segments = (0, $g03ag$useMemo)(()=>$3c0fc76039f1c516$var$processSegments(dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity), [
|
|
179
166
|
dateValue,
|
|
180
167
|
validSegments,
|
|
181
168
|
dateFormatter,
|
|
182
169
|
resolvedOptions,
|
|
183
170
|
displayValue,
|
|
184
171
|
calendar,
|
|
185
|
-
locale
|
|
172
|
+
locale,
|
|
173
|
+
granularity
|
|
186
174
|
]);
|
|
187
175
|
// When the era field appears, mark it valid if the year field is already valid.
|
|
188
176
|
// If the era field disappears, remove it from the valid segments.
|
|
@@ -289,7 +277,10 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
|
|
|
289
277
|
else if (!isPM && shouldBePM) value = displayValue.set({
|
|
290
278
|
hour: displayValue.hour + 12
|
|
291
279
|
});
|
|
292
|
-
} else if (part in displayValue) value = displayValue.set({
|
|
280
|
+
} else if (part === 'hour' && 'hour' in displayValue && displayValue.hour >= 12 && validSegments.dayPeriod) value = displayValue.set({
|
|
281
|
+
hour: placeholder['hour'] + 12
|
|
282
|
+
});
|
|
283
|
+
else if (part in displayValue) value = displayValue.set({
|
|
293
284
|
[part]: placeholder[part]
|
|
294
285
|
});
|
|
295
286
|
setDate(null);
|
|
@@ -311,6 +302,66 @@ function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
|
|
|
311
302
|
}
|
|
312
303
|
};
|
|
313
304
|
}
|
|
305
|
+
function $3c0fc76039f1c516$var$processSegments(dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity) {
|
|
306
|
+
let timeValue = [
|
|
307
|
+
'hour',
|
|
308
|
+
'minute',
|
|
309
|
+
'second'
|
|
310
|
+
];
|
|
311
|
+
let segments = dateFormatter.formatToParts(dateValue);
|
|
312
|
+
let processedSegments = [];
|
|
313
|
+
for (let segment of segments){
|
|
314
|
+
let isEditable = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type];
|
|
315
|
+
if (segment.type === 'era' && calendar.getEras().length === 1) isEditable = false;
|
|
316
|
+
let isPlaceholder = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type];
|
|
317
|
+
let placeholder = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type] ? (0, $3e3ed55ab2966714$export$d3f5c5e0a5023fa0)(segment.type, segment.value, locale) : null;
|
|
318
|
+
let dateSegment = {
|
|
319
|
+
type: $3c0fc76039f1c516$var$TYPE_MAPPING[segment.type] || segment.type,
|
|
320
|
+
text: isPlaceholder ? placeholder : segment.value,
|
|
321
|
+
...$3c0fc76039f1c516$var$getSegmentLimits(displayValue, segment.type, resolvedOptions),
|
|
322
|
+
isPlaceholder: isPlaceholder,
|
|
323
|
+
placeholder: placeholder,
|
|
324
|
+
isEditable: isEditable
|
|
325
|
+
};
|
|
326
|
+
// There is an issue in RTL languages where time fields render (minute:hour) instead of (hour:minute).
|
|
327
|
+
// To force an LTR direction on the time field since, we wrap the time segments in LRI (left-to-right) isolate unicode. See https://www.w3.org/International/questions/qa-bidi-unicode-controls.
|
|
328
|
+
// These unicode characters will be added to the array of processed segments as literals and will mark the start and end of the embedded direction change.
|
|
329
|
+
if (segment.type === 'hour') {
|
|
330
|
+
// This marks the start of the embedded direction change.
|
|
331
|
+
processedSegments.push({
|
|
332
|
+
type: 'literal',
|
|
333
|
+
text: '\u2066',
|
|
334
|
+
...$3c0fc76039f1c516$var$getSegmentLimits(displayValue, 'literal', resolvedOptions),
|
|
335
|
+
isPlaceholder: false,
|
|
336
|
+
placeholder: '',
|
|
337
|
+
isEditable: false
|
|
338
|
+
});
|
|
339
|
+
processedSegments.push(dateSegment);
|
|
340
|
+
// This marks the end of the embedded direction change in the case that the granularity it set to "hour".
|
|
341
|
+
if (segment.type === granularity) processedSegments.push({
|
|
342
|
+
type: 'literal',
|
|
343
|
+
text: '\u2069',
|
|
344
|
+
...$3c0fc76039f1c516$var$getSegmentLimits(displayValue, 'literal', resolvedOptions),
|
|
345
|
+
isPlaceholder: false,
|
|
346
|
+
placeholder: '',
|
|
347
|
+
isEditable: false
|
|
348
|
+
});
|
|
349
|
+
} else if (timeValue.includes(segment.type) && segment.type === granularity) {
|
|
350
|
+
processedSegments.push(dateSegment);
|
|
351
|
+
// This marks the end of the embedded direction change.
|
|
352
|
+
processedSegments.push({
|
|
353
|
+
type: 'literal',
|
|
354
|
+
text: '\u2069',
|
|
355
|
+
...$3c0fc76039f1c516$var$getSegmentLimits(displayValue, 'literal', resolvedOptions),
|
|
356
|
+
isPlaceholder: false,
|
|
357
|
+
placeholder: '',
|
|
358
|
+
isEditable: false
|
|
359
|
+
});
|
|
360
|
+
} else // We only want to "wrap" the unicode around segments that are hour, minute, or second. If they aren't, just process as normal.
|
|
361
|
+
processedSegments.push(dateSegment);
|
|
362
|
+
}
|
|
363
|
+
return processedSegments;
|
|
364
|
+
}
|
|
314
365
|
function $3c0fc76039f1c516$var$getSegmentLimits(date, type, options) {
|
|
315
366
|
switch(type){
|
|
316
367
|
case 'era':
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AA0FD,MAAM,0CAAoB;IACxB,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,KAAK;AACP;AAEA,MAAM,kCAAY;IAChB,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,QAAQ;IACR,QAAQ;AACV;AAEA,mDAAmD;AACnD,MAAM,qCAAe;IACnB,WAAW;AACb;AAwBO,SAAS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Q,SAAS;gBACrB,IAAI,OAAO,gBAAgB;gBAC3B,IAAI,SAAS,OACX,OAAO;gBAET,OAAO,MAAM,GAAG,CAAC;oBAAC,MAAM,QAAQ,QAAQ,KAAK,QAAQ;gBAAE;YACzD;QACA,KAAK;YACH,qDAAqD;YACrD,IAAI,QAAQ,MAAM,EAAE;gBAClB,IAAI,QAAQ,MAAM,IAAI;gBACtB,IAAI,QAAQ,SAAS;gBACrB,IAAI,CAAC,SAAS,iBAAiB,IAC7B,eAAe;gBAEjB,IAAI,SAAS,eAAe,IAC1B,gBAAgB;YAEpB;QACA,cAAc;QAChB,KAAK;QACL,KAAK;YACH,OAAO,MAAM,GAAG,CAAC;gBAAC,CAAC,KAAK,EAAE;YAAY;IAC1C;IAGF,MAAM,IAAI,MAAM,sBAAsB;AACxC","sources":["packages/@react-stately/datepicker/src/useDateFieldState.ts"],"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 {Calendar, DateFormatter, getMinimumDayInMonth, getMinimumMonthInYear, GregorianCalendar, toCalendar} from '@internationalized/date';\nimport {convertValue, createPlaceholderDate, FieldOptions, FormatterOptions, getFormatOptions, getValidationResult, useDefaultProps} from './utils';\nimport {DatePickerProps, DateValue, Granularity, MappedDateValue} from '@react-types/datepicker';\nimport {FormValidationState, useFormValidationState} from '@react-stately/form';\nimport {getPlaceholder} from './placeholders';\nimport {useControlledState} from '@react-stately/utils';\nimport {useEffect, useMemo, useRef, useState} from 'react';\nimport {ValidationState} from '@react-types/shared';\n\nexport type SegmentType = 'era' | 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'dayPeriod' | 'literal' | 'timeZoneName';\nexport interface DateSegment {\n /** The type of segment. */\n type: SegmentType,\n /** The formatted text for the segment. */\n text: string,\n /** The numeric value for the segment, if applicable. */\n value?: number,\n /** The minimum numeric value for the segment, if applicable. */\n minValue?: number,\n /** The maximum numeric value for the segment, if applicable. */\n maxValue?: number,\n /** Whether the value is a placeholder. */\n isPlaceholder: boolean,\n /** A placeholder string for the segment. */\n placeholder: string,\n /** Whether the segment is editable. */\n isEditable: boolean\n}\n\nexport interface DateFieldState extends FormValidationState {\n /** The current field value. */\n value: DateValue | null,\n /** The current value, converted to a native JavaScript `Date` object. */\n dateValue: Date,\n /** The calendar system currently in use. */\n calendar: Calendar,\n /** Sets the field's value. */\n setValue(value: DateValue | null): void,\n /** A list of segments for the current value. */\n segments: DateSegment[],\n /** A date formatter configured for the current locale and format. */\n dateFormatter: DateFormatter,\n /**\n * The current validation state of the date field, based on the `validationState`, `minValue`, and `maxValue` props.\n * @deprecated Use `isInvalid` instead.\n */\n validationState: ValidationState | null,\n /** Whether the date field is invalid, based on the `isInvalid`, `minValue`, and `maxValue` props. */\n isInvalid: boolean,\n /** The granularity for the field, based on the `granularity` prop and current value. */\n granularity: Granularity,\n /** The maximum date or time unit that is displayed in the field. */\n maxGranularity: 'year' | 'month' | Granularity,\n /** Whether the field is disabled. */\n isDisabled: boolean,\n /** Whether the field is read only. */\n isReadOnly: boolean,\n /** Whether the field is required. */\n isRequired: boolean,\n /** Increments the given segment. Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */\n increment(type: SegmentType): void,\n /** Decrements the given segment. Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */\n decrement(type: SegmentType): void,\n /**\n * Increments the given segment by a larger amount, rounding it to the nearest increment.\n * The amount to increment by depends on the field, for example 15 minutes, 7 days, and 5 years.\n * Upon reaching the minimum or maximum value, the value wraps around to the opposite limit.\n */\n incrementPage(type: SegmentType): void,\n /**\n * Decrements the given segment by a larger amount, rounding it to the nearest increment.\n * The amount to decrement by depends on the field, for example 15 minutes, 7 days, and 5 years.\n * Upon reaching the minimum or maximum value, the value wraps around to the opposite limit.\n */\n decrementPage(type: SegmentType): void,\n /** Sets the value of the given segment. */\n setSegment(type: 'era', value: string): void,\n setSegment(type: SegmentType, value: number): void,\n /** Updates the remaining unfilled segments with the placeholder value. */\n confirmPlaceholder(): void,\n /** Clears the value of the given segment, reverting it to the placeholder. */\n clearSegment(type: SegmentType): void,\n /** Formats the current date value using the given options. */\n formatValue(fieldOptions: FieldOptions): string,\n /** Gets a formatter based on state's props. */\n getDateFormatter(locale: string, formatOptions: FormatterOptions): DateFormatter\n}\n\nconst EDITABLE_SEGMENTS = {\n year: true,\n month: true,\n day: true,\n hour: true,\n minute: true,\n second: true,\n dayPeriod: true,\n era: true\n};\n\nconst PAGE_STEP = {\n year: 5,\n month: 2,\n day: 7,\n hour: 2,\n minute: 15,\n second: 15\n};\n\n// Node seems to convert everything to lowercase...\nconst TYPE_MAPPING = {\n dayperiod: 'dayPeriod'\n};\n\nexport interface DateFieldStateOptions<T extends DateValue = DateValue> extends DatePickerProps<T> {\n /**\n * The maximum unit to display in the date field.\n * @default 'year'\n */\n maxGranularity?: 'year' | 'month' | Granularity,\n /** The locale to display and edit the value according to. */\n locale: string,\n /**\n * A function that creates a [Calendar](../internationalized/date/Calendar.html)\n * object for a given calendar identifier. Such a function may be imported from the\n * `@internationalized/date` package, or manually implemented to include support for\n * only certain calendars.\n */\n createCalendar: (name: string) => Calendar\n}\n\n/**\n * Provides state management for a date field component.\n * A date field allows users to enter and edit date and time values using a keyboard.\n * Each part of a date value is displayed in an individually editable segment.\n */\nexport function useDateFieldState<T extends DateValue = DateValue>(props: DateFieldStateOptions<T>): DateFieldState {\n let {\n locale,\n createCalendar,\n hideTimeZone,\n isDisabled = false,\n isReadOnly = false,\n isRequired = false,\n minValue,\n maxValue,\n isDateUnavailable\n } = props;\n\n let v: DateValue | null = props.value || props.defaultValue || props.placeholderValue || null;\n let [granularity, defaultTimeZone] = useDefaultProps(v, props.granularity);\n let timeZone = defaultTimeZone || 'UTC';\n\n // props.granularity must actually exist in the value if one is provided.\n if (v && !(granularity in v)) {\n throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());\n }\n\n let defaultFormatter = useMemo(() => new DateFormatter(locale), [locale]);\n let calendar = useMemo(() => createCalendar(defaultFormatter.resolvedOptions().calendar), [createCalendar, defaultFormatter]);\n\n let [value, setDate] = useControlledState<DateValue | null, MappedDateValue<T> | null>(\n props.value,\n props.defaultValue ?? null,\n props.onChange\n );\n\n let calendarValue = useMemo(() => convertValue(value, calendar) ?? null, [value, calendar]);\n\n // We keep track of the placeholder date separately in state so that onChange is not called\n // until all segments are set. If the value === null (not undefined), then assume the component\n // is controlled, so use the placeholder as the value until all segments are entered so it doesn't\n // change from uncontrolled to controlled and emit a warning.\n let [placeholderDate, setPlaceholderDate] = useState(\n () => createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone)\n );\n\n let val = calendarValue || placeholderDate;\n let showEra = calendar.identifier === 'gregory' && val.era === 'BC';\n let formatOpts = useMemo(() => ({\n granularity,\n maxGranularity: props.maxGranularity ?? 'year',\n timeZone: defaultTimeZone,\n hideTimeZone,\n hourCycle: props.hourCycle,\n showEra,\n shouldForceLeadingZeros: props.shouldForceLeadingZeros\n }), [props.maxGranularity, granularity, props.hourCycle, props.shouldForceLeadingZeros, defaultTimeZone, hideTimeZone, showEra]);\n let opts = useMemo(() => getFormatOptions({}, formatOpts), [formatOpts]);\n\n let dateFormatter = useMemo(() => new DateFormatter(locale, opts), [locale, opts]);\n let resolvedOptions = useMemo(() => dateFormatter.resolvedOptions(), [dateFormatter]);\n\n // Determine how many editable segments there are for validation purposes.\n // The result is cached for performance.\n let allSegments: Partial<typeof EDITABLE_SEGMENTS> = useMemo(() =>\n dateFormatter.formatToParts(new Date())\n .filter(seg => EDITABLE_SEGMENTS[seg.type])\n .reduce((p, seg) => (p[seg.type] = true, p), {})\n , [dateFormatter]);\n\n let [validSegments, setValidSegments] = useState<Partial<typeof EDITABLE_SEGMENTS>>(\n () => props.value || props.defaultValue ? {...allSegments} : {}\n );\n\n let clearedSegment = useRef<string | null>(null);\n\n // Reset placeholder when calendar changes\n let lastCalendarIdentifier = useRef(calendar.identifier);\n useEffect(() => {\n if (calendar.identifier !== lastCalendarIdentifier.current) {\n lastCalendarIdentifier.current = calendar.identifier;\n setPlaceholderDate(placeholder =>\n Object.keys(validSegments).length > 0\n ? toCalendar(placeholder, calendar)\n : createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone)\n );\n }\n }, [calendar, granularity, validSegments, defaultTimeZone, props.placeholderValue]);\n\n // If there is a value prop, and some segments were previously placeholders, mark them all as valid.\n if (value && Object.keys(validSegments).length < Object.keys(allSegments).length) {\n validSegments = {...allSegments};\n setValidSegments(validSegments);\n }\n\n // If the value is set to null and all segments are valid, reset the placeholder.\n if (value == null && Object.keys(validSegments).length === Object.keys(allSegments).length) {\n validSegments = {};\n setValidSegments(validSegments);\n setPlaceholderDate(createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone));\n }\n\n // If all segments are valid, use the date from state, otherwise use the placeholder date.\n let displayValue = calendarValue && Object.keys(validSegments).length >= Object.keys(allSegments).length ? calendarValue : placeholderDate;\n let setValue = (newValue: DateValue) => {\n if (props.isDisabled || props.isReadOnly) {\n return;\n }\n let validKeys = Object.keys(validSegments);\n let allKeys = Object.keys(allSegments);\n\n // if all the segments are completed or a timefield with everything but am/pm set the time, also ignore when am/pm cleared\n if (newValue == null) {\n setDate(null);\n setPlaceholderDate(createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone));\n setValidSegments({});\n } else if (validKeys.length >= allKeys.length || (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod && clearedSegment.current !== 'dayPeriod')) {\n // The display calendar should not have any effect on the emitted value.\n // Emit dates in the same calendar as the original value, if any, otherwise gregorian.\n newValue = toCalendar(newValue, v?.calendar || new GregorianCalendar());\n setDate(newValue);\n } else {\n setPlaceholderDate(newValue);\n }\n clearedSegment.current = null;\n };\n\n let dateValue = useMemo(() => displayValue.toDate(timeZone), [displayValue, timeZone]);\n let segments = useMemo(() =>\n dateFormatter.formatToParts(dateValue)\n .map(segment => {\n let isEditable = EDITABLE_SEGMENTS[segment.type];\n if (segment.type === 'era' && calendar.getEras().length === 1) {\n isEditable = false;\n }\n\n let isPlaceholder = EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type];\n let placeholder = EDITABLE_SEGMENTS[segment.type] ? getPlaceholder(segment.type, segment.value, locale) : null;\n return {\n type: TYPE_MAPPING[segment.type] || segment.type,\n text: isPlaceholder ? placeholder : segment.value,\n ...getSegmentLimits(displayValue, segment.type, resolvedOptions),\n isPlaceholder,\n placeholder,\n isEditable\n } as DateSegment;\n })\n , [dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale]);\n\n // When the era field appears, mark it valid if the year field is already valid.\n // If the era field disappears, remove it from the valid segments.\n if (allSegments.era && validSegments.year && !validSegments.era) {\n validSegments.era = true;\n setValidSegments({...validSegments});\n } else if (!allSegments.era && validSegments.era) {\n delete validSegments.era;\n setValidSegments({...validSegments});\n }\n\n let markValid = (part: Intl.DateTimeFormatPartTypes) => {\n validSegments[part] = true;\n if (part === 'year' && allSegments.era) {\n validSegments.era = true;\n }\n setValidSegments({...validSegments});\n };\n\n let adjustSegment = (type: Intl.DateTimeFormatPartTypes, amount: number) => {\n if (!validSegments[type]) {\n markValid(type);\n let validKeys = Object.keys(validSegments);\n let allKeys = Object.keys(allSegments);\n if (validKeys.length >= allKeys.length || (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod)) {\n setValue(displayValue);\n }\n } else {\n setValue(addSegment(displayValue, type, amount, resolvedOptions));\n }\n };\n\n let builtinValidation = useMemo(() => getValidationResult(\n value,\n minValue,\n maxValue,\n isDateUnavailable,\n formatOpts\n ), [value, minValue, maxValue, isDateUnavailable, formatOpts]);\n\n let validation = useFormValidationState({\n ...props,\n value: value as MappedDateValue<T> | null,\n builtinValidation\n });\n\n let isValueInvalid = validation.displayValidation.isInvalid;\n let validationState: ValidationState | null = props.validationState || (isValueInvalid ? 'invalid' : null);\n\n return {\n ...validation,\n value: calendarValue,\n dateValue,\n calendar,\n setValue,\n segments,\n dateFormatter,\n validationState,\n isInvalid: isValueInvalid,\n granularity,\n maxGranularity: props.maxGranularity ?? 'year',\n isDisabled,\n isReadOnly,\n isRequired,\n increment(part) {\n adjustSegment(part, 1);\n },\n decrement(part) {\n adjustSegment(part, -1);\n },\n incrementPage(part) {\n adjustSegment(part, PAGE_STEP[part] || 1);\n },\n decrementPage(part) {\n adjustSegment(part, -(PAGE_STEP[part] || 1));\n },\n setSegment(part, v: string | number) {\n markValid(part);\n setValue(setSegment(displayValue, part, v, resolvedOptions));\n },\n confirmPlaceholder() {\n if (props.isDisabled || props.isReadOnly) {\n return;\n }\n\n // Confirm the placeholder if only the day period is not filled in.\n let validKeys = Object.keys(validSegments);\n let allKeys = Object.keys(allSegments);\n if (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod) {\n validSegments = {...allSegments};\n setValidSegments(validSegments);\n setValue(displayValue.copy());\n }\n },\n clearSegment(part) {\n delete validSegments[part];\n clearedSegment.current = part;\n setValidSegments({...validSegments});\n\n let placeholder = createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone);\n let value = displayValue;\n\n // Reset day period to default without changing the hour.\n if (part === 'dayPeriod' && 'hour' in displayValue && 'hour' in placeholder) {\n let isPM = displayValue.hour >= 12;\n let shouldBePM = placeholder.hour >= 12;\n if (isPM && !shouldBePM) {\n value = displayValue.set({hour: displayValue.hour - 12});\n } else if (!isPM && shouldBePM) {\n value = displayValue.set({hour: displayValue.hour + 12});\n }\n } else if (part in displayValue) {\n value = displayValue.set({[part]: placeholder[part]});\n }\n\n setDate(null);\n setValue(value);\n },\n formatValue(fieldOptions: FieldOptions) {\n if (!calendarValue) {\n return '';\n }\n\n let formatOptions = getFormatOptions(fieldOptions, formatOpts);\n let formatter = new DateFormatter(locale, formatOptions);\n return formatter.format(dateValue);\n },\n getDateFormatter(locale, formatOptions: FormatterOptions) {\n let newOptions = {...formatOpts, ...formatOptions};\n let newFormatOptions = getFormatOptions({}, newOptions);\n return new DateFormatter(locale, newFormatOptions);\n }\n };\n}\n\nfunction getSegmentLimits(date: DateValue, type: string, options: Intl.ResolvedDateTimeFormatOptions) {\n switch (type) {\n case 'era': {\n let eras = date.calendar.getEras();\n return {\n value: eras.indexOf(date.era),\n minValue: 0,\n maxValue: eras.length - 1\n };\n }\n case 'year':\n return {\n value: date.year,\n minValue: 1,\n maxValue: date.calendar.getYearsInEra(date)\n };\n case 'month':\n return {\n value: date.month,\n minValue: getMinimumMonthInYear(date),\n maxValue: date.calendar.getMonthsInYear(date)\n };\n case 'day':\n return {\n value: date.day,\n minValue: getMinimumDayInMonth(date),\n maxValue: date.calendar.getDaysInMonth(date)\n };\n }\n\n if ('hour' in date) {\n switch (type) {\n case 'dayPeriod':\n return {\n value: date.hour >= 12 ? 12 : 0,\n minValue: 0,\n maxValue: 12\n };\n case 'hour':\n if (options.hour12) {\n let isPM = date.hour >= 12;\n return {\n value: date.hour,\n minValue: isPM ? 12 : 0,\n maxValue: isPM ? 23 : 11\n };\n }\n\n return {\n value: date.hour,\n minValue: 0,\n maxValue: 23\n };\n case 'minute':\n return {\n value: date.minute,\n minValue: 0,\n maxValue: 59\n };\n case 'second':\n return {\n value: date.second,\n minValue: 0,\n maxValue: 59\n };\n }\n }\n\n return {};\n}\n\nfunction addSegment(value: DateValue, part: string, amount: number, options: Intl.ResolvedDateTimeFormatOptions) {\n switch (part) {\n case 'era':\n case 'year':\n case 'month':\n case 'day':\n return value.cycle(part, amount, {round: part === 'year'});\n }\n\n if ('hour' in value) {\n switch (part) {\n case 'dayPeriod': {\n let hours = value.hour;\n let isPM = hours >= 12;\n return value.set({hour: isPM ? hours - 12 : hours + 12});\n }\n case 'hour':\n case 'minute':\n case 'second':\n return value.cycle(part, amount, {\n round: part !== 'hour',\n hourCycle: options.hour12 ? 12 : 24\n });\n }\n }\n\n throw new Error('Unknown segment: ' + part);\n}\n\nfunction setSegment(value: DateValue, part: string, segmentValue: number | string, options: Intl.ResolvedDateTimeFormatOptions) {\n switch (part) {\n case 'day':\n case 'month':\n case 'year':\n case 'era':\n return value.set({[part]: segmentValue});\n }\n\n if ('hour' in value && typeof segmentValue === 'number') {\n switch (part) {\n case 'dayPeriod': {\n let hours = value.hour;\n let wasPM = hours >= 12;\n let isPM = segmentValue >= 12;\n if (isPM === wasPM) {\n return value;\n }\n return value.set({hour: wasPM ? hours - 12 : hours + 12});\n }\n case 'hour':\n // In 12 hour time, ensure that AM/PM does not change\n if (options.hour12) {\n let hours = value.hour;\n let wasPM = hours >= 12;\n if (!wasPM && segmentValue === 12) {\n segmentValue = 0;\n }\n if (wasPM && segmentValue < 12) {\n segmentValue += 12;\n }\n }\n // fallthrough\n case 'minute':\n case 'second':\n return value.set({[part]: segmentValue});\n }\n }\n\n throw new Error('Unknown segment: ' + part);\n}\n"],"names":[],"version":3,"file":"useDateFieldState.module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AA0FD,MAAM,0CAAoB;IACxB,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,KAAK;AACP;AAEA,MAAM,kCAAY;IAChB,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,QAAQ;IACR,QAAQ;AACV;AAEA,mDAAmD;AACnD,MAAM,qCAAe;IACnB,WAAW;AACb;AAwBO,SAAS,0CAAmD,KAA+B;IAChG,IAAI,UACF,MAAM,kBACN,cAAc,gBACd,YAAY,cACZ,aAAa,mBACb,aAAa,mBACb,aAAa,iBACb,QAAQ,YACR,QAAQ,qBACR,iBAA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AAqD;YACrD,IAAI,QAAQ,MAAM,EAAE;gBAClB,IAAI,QAAQ,MAAM,IAAI;gBACtB,IAAI,QAAQ,SAAS;gBACrB,IAAI,CAAC,SAAS,iBAAiB,IAC7B,eAAe;gBAEjB,IAAI,SAAS,eAAe,IAC1B,gBAAgB;YAEpB;QACA,cAAc;QAChB,KAAK;QACL,KAAK;YACH,OAAO,MAAM,GAAG,CAAC;gBAAC,CAAC,KAAK,EAAE;YAAY;IAC1C;IAGF,MAAM,IAAI,MAAM,sBAAsB;AACxC","sources":["packages/@react-stately/datepicker/src/useDateFieldState.ts"],"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 {Calendar, DateFormatter, getMinimumDayInMonth, getMinimumMonthInYear, GregorianCalendar, toCalendar} from '@internationalized/date';\nimport {convertValue, createPlaceholderDate, FieldOptions, FormatterOptions, getFormatOptions, getValidationResult, useDefaultProps} from './utils';\nimport {DatePickerProps, DateValue, Granularity, MappedDateValue} from '@react-types/datepicker';\nimport {FormValidationState, useFormValidationState} from '@react-stately/form';\nimport {getPlaceholder} from './placeholders';\nimport {useControlledState} from '@react-stately/utils';\nimport {useEffect, useMemo, useRef, useState} from 'react';\nimport {ValidationState} from '@react-types/shared';\n\nexport type SegmentType = 'era' | 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'dayPeriod' | 'literal' | 'timeZoneName';\nexport interface DateSegment {\n /** The type of segment. */\n type: SegmentType,\n /** The formatted text for the segment. */\n text: string,\n /** The numeric value for the segment, if applicable. */\n value?: number,\n /** The minimum numeric value for the segment, if applicable. */\n minValue?: number,\n /** The maximum numeric value for the segment, if applicable. */\n maxValue?: number,\n /** Whether the value is a placeholder. */\n isPlaceholder: boolean,\n /** A placeholder string for the segment. */\n placeholder: string,\n /** Whether the segment is editable. */\n isEditable: boolean\n}\n\nexport interface DateFieldState extends FormValidationState {\n /** The current field value. */\n value: DateValue | null,\n /** The current value, converted to a native JavaScript `Date` object. */\n dateValue: Date,\n /** The calendar system currently in use. */\n calendar: Calendar,\n /** Sets the field's value. */\n setValue(value: DateValue | null): void,\n /** A list of segments for the current value. */\n segments: DateSegment[],\n /** A date formatter configured for the current locale and format. */\n dateFormatter: DateFormatter,\n /**\n * The current validation state of the date field, based on the `validationState`, `minValue`, and `maxValue` props.\n * @deprecated Use `isInvalid` instead.\n */\n validationState: ValidationState | null,\n /** Whether the date field is invalid, based on the `isInvalid`, `minValue`, and `maxValue` props. */\n isInvalid: boolean,\n /** The granularity for the field, based on the `granularity` prop and current value. */\n granularity: Granularity,\n /** The maximum date or time unit that is displayed in the field. */\n maxGranularity: 'year' | 'month' | Granularity,\n /** Whether the field is disabled. */\n isDisabled: boolean,\n /** Whether the field is read only. */\n isReadOnly: boolean,\n /** Whether the field is required. */\n isRequired: boolean,\n /** Increments the given segment. Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */\n increment(type: SegmentType): void,\n /** Decrements the given segment. Upon reaching the minimum or maximum value, the value wraps around to the opposite limit. */\n decrement(type: SegmentType): void,\n /**\n * Increments the given segment by a larger amount, rounding it to the nearest increment.\n * The amount to increment by depends on the field, for example 15 minutes, 7 days, and 5 years.\n * Upon reaching the minimum or maximum value, the value wraps around to the opposite limit.\n */\n incrementPage(type: SegmentType): void,\n /**\n * Decrements the given segment by a larger amount, rounding it to the nearest increment.\n * The amount to decrement by depends on the field, for example 15 minutes, 7 days, and 5 years.\n * Upon reaching the minimum or maximum value, the value wraps around to the opposite limit.\n */\n decrementPage(type: SegmentType): void,\n /** Sets the value of the given segment. */\n setSegment(type: 'era', value: string): void,\n setSegment(type: SegmentType, value: number): void,\n /** Updates the remaining unfilled segments with the placeholder value. */\n confirmPlaceholder(): void,\n /** Clears the value of the given segment, reverting it to the placeholder. */\n clearSegment(type: SegmentType): void,\n /** Formats the current date value using the given options. */\n formatValue(fieldOptions: FieldOptions): string,\n /** Gets a formatter based on state's props. */\n getDateFormatter(locale: string, formatOptions: FormatterOptions): DateFormatter\n}\n\nconst EDITABLE_SEGMENTS = {\n year: true,\n month: true,\n day: true,\n hour: true,\n minute: true,\n second: true,\n dayPeriod: true,\n era: true\n};\n\nconst PAGE_STEP = {\n year: 5,\n month: 2,\n day: 7,\n hour: 2,\n minute: 15,\n second: 15\n};\n\n// Node seems to convert everything to lowercase...\nconst TYPE_MAPPING = {\n dayperiod: 'dayPeriod'\n};\n\nexport interface DateFieldStateOptions<T extends DateValue = DateValue> extends DatePickerProps<T> {\n /**\n * The maximum unit to display in the date field.\n * @default 'year'\n */\n maxGranularity?: 'year' | 'month' | Granularity,\n /** The locale to display and edit the value according to. */\n locale: string,\n /**\n * A function that creates a [Calendar](../internationalized/date/Calendar.html)\n * object for a given calendar identifier. Such a function may be imported from the\n * `@internationalized/date` package, or manually implemented to include support for\n * only certain calendars.\n */\n createCalendar: (name: string) => Calendar\n}\n\n/**\n * Provides state management for a date field component.\n * A date field allows users to enter and edit date and time values using a keyboard.\n * Each part of a date value is displayed in an individually editable segment.\n */\nexport function useDateFieldState<T extends DateValue = DateValue>(props: DateFieldStateOptions<T>): DateFieldState {\n let {\n locale,\n createCalendar,\n hideTimeZone,\n isDisabled = false,\n isReadOnly = false,\n isRequired = false,\n minValue,\n maxValue,\n isDateUnavailable\n } = props;\n\n let v: DateValue | null = props.value || props.defaultValue || props.placeholderValue || null;\n let [granularity, defaultTimeZone] = useDefaultProps(v, props.granularity);\n let timeZone = defaultTimeZone || 'UTC';\n\n // props.granularity must actually exist in the value if one is provided.\n if (v && !(granularity in v)) {\n throw new Error('Invalid granularity ' + granularity + ' for value ' + v.toString());\n }\n\n let defaultFormatter = useMemo(() => new DateFormatter(locale), [locale]);\n let calendar = useMemo(() => createCalendar(defaultFormatter.resolvedOptions().calendar), [createCalendar, defaultFormatter]);\n\n let [value, setDate] = useControlledState<DateValue | null, MappedDateValue<T> | null>(\n props.value,\n props.defaultValue ?? null,\n props.onChange\n );\n\n let calendarValue = useMemo(() => convertValue(value, calendar) ?? null, [value, calendar]);\n\n // We keep track of the placeholder date separately in state so that onChange is not called\n // until all segments are set. If the value === null (not undefined), then assume the component\n // is controlled, so use the placeholder as the value until all segments are entered so it doesn't\n // change from uncontrolled to controlled and emit a warning.\n let [placeholderDate, setPlaceholderDate] = useState(\n () => createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone)\n );\n\n let val = calendarValue || placeholderDate;\n let showEra = calendar.identifier === 'gregory' && val.era === 'BC';\n let formatOpts = useMemo(() => ({\n granularity,\n maxGranularity: props.maxGranularity ?? 'year',\n timeZone: defaultTimeZone,\n hideTimeZone,\n hourCycle: props.hourCycle,\n showEra,\n shouldForceLeadingZeros: props.shouldForceLeadingZeros\n }), [props.maxGranularity, granularity, props.hourCycle, props.shouldForceLeadingZeros, defaultTimeZone, hideTimeZone, showEra]);\n let opts = useMemo(() => getFormatOptions({}, formatOpts), [formatOpts]);\n\n let dateFormatter = useMemo(() => new DateFormatter(locale, opts), [locale, opts]);\n let resolvedOptions = useMemo(() => dateFormatter.resolvedOptions(), [dateFormatter]);\n\n // Determine how many editable segments there are for validation purposes.\n // The result is cached for performance.\n let allSegments: Partial<typeof EDITABLE_SEGMENTS> = useMemo(() =>\n dateFormatter.formatToParts(new Date())\n .filter(seg => EDITABLE_SEGMENTS[seg.type])\n .reduce((p, seg) => (p[seg.type] = true, p), {})\n , [dateFormatter]);\n\n let [validSegments, setValidSegments] = useState<Partial<typeof EDITABLE_SEGMENTS>>(\n () => props.value || props.defaultValue ? {...allSegments} : {}\n );\n\n let clearedSegment = useRef<string | null>(null);\n\n // Reset placeholder when calendar changes\n let lastCalendarIdentifier = useRef(calendar.identifier);\n useEffect(() => {\n if (calendar.identifier !== lastCalendarIdentifier.current) {\n lastCalendarIdentifier.current = calendar.identifier;\n setPlaceholderDate(placeholder =>\n Object.keys(validSegments).length > 0\n ? toCalendar(placeholder, calendar)\n : createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone)\n );\n }\n }, [calendar, granularity, validSegments, defaultTimeZone, props.placeholderValue]);\n\n // If there is a value prop, and some segments were previously placeholders, mark them all as valid.\n if (value && Object.keys(validSegments).length < Object.keys(allSegments).length) {\n validSegments = {...allSegments};\n setValidSegments(validSegments);\n }\n\n // If the value is set to null and all segments are valid, reset the placeholder.\n if (value == null && Object.keys(validSegments).length === Object.keys(allSegments).length) {\n validSegments = {};\n setValidSegments(validSegments);\n setPlaceholderDate(createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone));\n }\n\n // If all segments are valid, use the date from state, otherwise use the placeholder date.\n let displayValue = calendarValue && Object.keys(validSegments).length >= Object.keys(allSegments).length ? calendarValue : placeholderDate;\n let setValue = (newValue: DateValue) => {\n if (props.isDisabled || props.isReadOnly) {\n return;\n }\n let validKeys = Object.keys(validSegments);\n let allKeys = Object.keys(allSegments);\n\n // if all the segments are completed or a timefield with everything but am/pm set the time, also ignore when am/pm cleared\n if (newValue == null) {\n setDate(null);\n setPlaceholderDate(createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone));\n setValidSegments({});\n } else if (validKeys.length >= allKeys.length || (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod && clearedSegment.current !== 'dayPeriod')) {\n // The display calendar should not have any effect on the emitted value.\n // Emit dates in the same calendar as the original value, if any, otherwise gregorian.\n newValue = toCalendar(newValue, v?.calendar || new GregorianCalendar());\n setDate(newValue);\n } else {\n setPlaceholderDate(newValue);\n }\n clearedSegment.current = null;\n };\n\n let dateValue = useMemo(() => displayValue.toDate(timeZone), [displayValue, timeZone]);\n let segments = useMemo(() => \n processSegments(dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity), \n [dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity]);\n\n // When the era field appears, mark it valid if the year field is already valid.\n // If the era field disappears, remove it from the valid segments.\n if (allSegments.era && validSegments.year && !validSegments.era) {\n validSegments.era = true;\n setValidSegments({...validSegments});\n } else if (!allSegments.era && validSegments.era) {\n delete validSegments.era;\n setValidSegments({...validSegments});\n }\n\n let markValid = (part: Intl.DateTimeFormatPartTypes) => {\n validSegments[part] = true;\n if (part === 'year' && allSegments.era) {\n validSegments.era = true;\n }\n setValidSegments({...validSegments});\n };\n\n let adjustSegment = (type: Intl.DateTimeFormatPartTypes, amount: number) => {\n if (!validSegments[type]) {\n markValid(type);\n let validKeys = Object.keys(validSegments);\n let allKeys = Object.keys(allSegments);\n if (validKeys.length >= allKeys.length || (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod)) {\n setValue(displayValue);\n }\n } else {\n setValue(addSegment(displayValue, type, amount, resolvedOptions));\n }\n };\n\n let builtinValidation = useMemo(() => getValidationResult(\n value,\n minValue,\n maxValue,\n isDateUnavailable,\n formatOpts\n ), [value, minValue, maxValue, isDateUnavailable, formatOpts]);\n\n let validation = useFormValidationState({\n ...props,\n value: value as MappedDateValue<T> | null,\n builtinValidation\n });\n\n let isValueInvalid = validation.displayValidation.isInvalid;\n let validationState: ValidationState | null = props.validationState || (isValueInvalid ? 'invalid' : null);\n\n return {\n ...validation,\n value: calendarValue,\n dateValue,\n calendar,\n setValue,\n segments,\n dateFormatter,\n validationState,\n isInvalid: isValueInvalid,\n granularity,\n maxGranularity: props.maxGranularity ?? 'year',\n isDisabled,\n isReadOnly,\n isRequired,\n increment(part) {\n adjustSegment(part, 1);\n },\n decrement(part) {\n adjustSegment(part, -1);\n },\n incrementPage(part) {\n adjustSegment(part, PAGE_STEP[part] || 1);\n },\n decrementPage(part) {\n adjustSegment(part, -(PAGE_STEP[part] || 1));\n },\n setSegment(part, v: string | number) {\n markValid(part);\n setValue(setSegment(displayValue, part, v, resolvedOptions));\n },\n confirmPlaceholder() {\n if (props.isDisabled || props.isReadOnly) {\n return;\n }\n\n // Confirm the placeholder if only the day period is not filled in.\n let validKeys = Object.keys(validSegments);\n let allKeys = Object.keys(allSegments);\n if (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod) {\n validSegments = {...allSegments};\n setValidSegments(validSegments);\n setValue(displayValue.copy());\n }\n },\n clearSegment(part) {\n delete validSegments[part];\n clearedSegment.current = part;\n setValidSegments({...validSegments});\n\n let placeholder = createPlaceholderDate(props.placeholderValue, granularity, calendar, defaultTimeZone);\n let value = displayValue;\n\n // Reset day period to default without changing the hour.\n if (part === 'dayPeriod' && 'hour' in displayValue && 'hour' in placeholder) {\n let isPM = displayValue.hour >= 12;\n let shouldBePM = placeholder.hour >= 12;\n if (isPM && !shouldBePM) {\n value = displayValue.set({hour: displayValue.hour - 12});\n } else if (!isPM && shouldBePM) {\n value = displayValue.set({hour: displayValue.hour + 12});\n }\n } else if (part === 'hour' && 'hour' in displayValue && displayValue.hour >= 12 && validSegments.dayPeriod) {\n value = displayValue.set({hour: placeholder['hour'] + 12});\n } else if (part in displayValue) {\n value = displayValue.set({[part]: placeholder[part]});\n }\n\n setDate(null);\n setValue(value);\n },\n formatValue(fieldOptions: FieldOptions) {\n if (!calendarValue) {\n return '';\n }\n\n let formatOptions = getFormatOptions(fieldOptions, formatOpts);\n let formatter = new DateFormatter(locale, formatOptions);\n return formatter.format(dateValue);\n },\n getDateFormatter(locale, formatOptions: FormatterOptions) {\n let newOptions = {...formatOpts, ...formatOptions};\n let newFormatOptions = getFormatOptions({}, newOptions);\n return new DateFormatter(locale, newFormatOptions);\n }\n };\n}\n\nfunction processSegments(dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity) : DateSegment[] {\n let timeValue = ['hour', 'minute', 'second'];\n let segments = dateFormatter.formatToParts(dateValue);\n let processedSegments: DateSegment[] = [];\n for (let segment of segments) {\n let isEditable = EDITABLE_SEGMENTS[segment.type];\n if (segment.type === 'era' && calendar.getEras().length === 1) {\n isEditable = false;\n }\n\n let isPlaceholder = EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type];\n let placeholder = EDITABLE_SEGMENTS[segment.type] ? getPlaceholder(segment.type, segment.value, locale) : null;\n\n let dateSegment = {\n type: TYPE_MAPPING[segment.type] || segment.type,\n text: isPlaceholder ? placeholder : segment.value,\n ...getSegmentLimits(displayValue, segment.type, resolvedOptions),\n isPlaceholder,\n placeholder,\n isEditable\n } as DateSegment;\n\n // There is an issue in RTL languages where time fields render (minute:hour) instead of (hour:minute).\n // To force an LTR direction on the time field since, we wrap the time segments in LRI (left-to-right) isolate unicode. See https://www.w3.org/International/questions/qa-bidi-unicode-controls.\n // These unicode characters will be added to the array of processed segments as literals and will mark the start and end of the embedded direction change. \n if (segment.type === 'hour') {\n // This marks the start of the embedded direction change. \n processedSegments.push({\n type: 'literal',\n text: '\\u2066',\n ...getSegmentLimits(displayValue, 'literal', resolvedOptions),\n isPlaceholder: false,\n placeholder: '',\n isEditable: false\n });\n processedSegments.push(dateSegment);\n // This marks the end of the embedded direction change in the case that the granularity it set to \"hour\".\n if (segment.type === granularity) {\n processedSegments.push({\n type: 'literal',\n text: '\\u2069',\n ...getSegmentLimits(displayValue, 'literal', resolvedOptions),\n isPlaceholder: false,\n placeholder: '',\n isEditable: false\n });\n }\n } else if (timeValue.includes(segment.type) && segment.type === granularity) {\n processedSegments.push(dateSegment);\n // This marks the end of the embedded direction change.\n processedSegments.push({\n type: 'literal',\n text: '\\u2069',\n ...getSegmentLimits(displayValue, 'literal', resolvedOptions),\n isPlaceholder: false,\n placeholder: '',\n isEditable: false\n });\n } else {\n // We only want to \"wrap\" the unicode around segments that are hour, minute, or second. If they aren't, just process as normal. \n processedSegments.push(dateSegment);\n }\n }\n\n return processedSegments;\n}\n\nfunction getSegmentLimits(date: DateValue, type: string, options: Intl.ResolvedDateTimeFormatOptions) {\n switch (type) {\n case 'era': {\n let eras = date.calendar.getEras();\n return {\n value: eras.indexOf(date.era),\n minValue: 0,\n maxValue: eras.length - 1\n };\n }\n case 'year':\n return {\n value: date.year,\n minValue: 1,\n maxValue: date.calendar.getYearsInEra(date)\n };\n case 'month':\n return {\n value: date.month,\n minValue: getMinimumMonthInYear(date),\n maxValue: date.calendar.getMonthsInYear(date)\n };\n case 'day':\n return {\n value: date.day,\n minValue: getMinimumDayInMonth(date),\n maxValue: date.calendar.getDaysInMonth(date)\n };\n }\n\n if ('hour' in date) {\n switch (type) {\n case 'dayPeriod':\n return {\n value: date.hour >= 12 ? 12 : 0,\n minValue: 0,\n maxValue: 12\n };\n case 'hour':\n if (options.hour12) {\n let isPM = date.hour >= 12;\n return {\n value: date.hour,\n minValue: isPM ? 12 : 0,\n maxValue: isPM ? 23 : 11\n };\n }\n\n return {\n value: date.hour,\n minValue: 0,\n maxValue: 23\n };\n case 'minute':\n return {\n value: date.minute,\n minValue: 0,\n maxValue: 59\n };\n case 'second':\n return {\n value: date.second,\n minValue: 0,\n maxValue: 59\n };\n }\n }\n\n return {};\n}\n\nfunction addSegment(value: DateValue, part: string, amount: number, options: Intl.ResolvedDateTimeFormatOptions) {\n switch (part) {\n case 'era':\n case 'year':\n case 'month':\n case 'day':\n return value.cycle(part, amount, {round: part === 'year'});\n }\n\n if ('hour' in value) {\n switch (part) {\n case 'dayPeriod': {\n let hours = value.hour;\n let isPM = hours >= 12;\n return value.set({hour: isPM ? hours - 12 : hours + 12});\n }\n case 'hour':\n case 'minute':\n case 'second':\n return value.cycle(part, amount, {\n round: part !== 'hour',\n hourCycle: options.hour12 ? 12 : 24\n });\n }\n }\n\n throw new Error('Unknown segment: ' + part);\n}\n\nfunction setSegment(value: DateValue, part: string, segmentValue: number | string, options: Intl.ResolvedDateTimeFormatOptions) {\n switch (part) {\n case 'day':\n case 'month':\n case 'year':\n case 'era':\n return value.set({[part]: segmentValue});\n }\n\n if ('hour' in value && typeof segmentValue === 'number') {\n switch (part) {\n case 'dayPeriod': {\n let hours = value.hour;\n let wasPM = hours >= 12;\n let isPM = segmentValue >= 12;\n if (isPM === wasPM) {\n return value;\n }\n return value.set({hour: wasPM ? hours - 12 : hours + 12});\n }\n case 'hour':\n // In 12 hour time, ensure that AM/PM does not change\n if (options.hour12) {\n let hours = value.hour;\n let wasPM = hours >= 12;\n if (!wasPM && segmentValue === 12) {\n segmentValue = 0;\n }\n if (wasPM && segmentValue < 12) {\n segmentValue += 12;\n }\n }\n // fallthrough\n case 'minute':\n case 'second':\n return value.set({[part]: segmentValue});\n }\n }\n\n throw new Error('Unknown segment: ' + part);\n}\n"],"names":[],"version":3,"file":"useDateFieldState.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-stately/datepicker",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@internationalized/date": "^3.7.0",
|
|
26
26
|
"@internationalized/string": "^3.2.5",
|
|
27
|
-
"@react-stately/form": "^3.1.
|
|
28
|
-
"@react-stately/overlays": "^3.6.
|
|
27
|
+
"@react-stately/form": "^3.1.2",
|
|
28
|
+
"@react-stately/overlays": "^3.6.14",
|
|
29
29
|
"@react-stately/utils": "^3.10.5",
|
|
30
|
-
"@react-types/datepicker": "^3.
|
|
31
|
-
"@react-types/shared": "^3.
|
|
30
|
+
"@react-types/datepicker": "^3.11.0",
|
|
31
|
+
"@react-types/shared": "^3.28.0",
|
|
32
32
|
"@swc/helpers": "^0.5.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "4d3c72c94eea2d72eb3a0e7d56000c6ef7e39726"
|
|
41
41
|
}
|
package/src/placeholders.ts
CHANGED
|
@@ -57,7 +57,7 @@ const placeholders = new LocalizedStringDictionary({
|
|
|
57
57
|
ia: {year: 'aaaa', month: 'mm', day: 'dd'},
|
|
58
58
|
id: {year: 'tttt', month: 'bb', day: 'hh'},
|
|
59
59
|
it: {year: 'aaaa', month: 'mm', day: 'gg'},
|
|
60
|
-
ja: {year: '
|
|
60
|
+
ja: {year: '年', month: '月', day: '日'},
|
|
61
61
|
ka: {year: 'წწწწ', month: 'თთ', day: 'რრ'},
|
|
62
62
|
kk: {year: 'жжжж', month: 'аа', day: 'кк'},
|
|
63
63
|
kn: {year: 'ವವವವ', month: 'ಮಿಮೀ', day: 'ದಿದಿ'},
|
package/src/useDateFieldState.ts
CHANGED
|
@@ -268,26 +268,9 @@ export function useDateFieldState<T extends DateValue = DateValue>(props: DateFi
|
|
|
268
268
|
};
|
|
269
269
|
|
|
270
270
|
let dateValue = useMemo(() => displayValue.toDate(timeZone), [displayValue, timeZone]);
|
|
271
|
-
let segments = useMemo(() =>
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
let isEditable = EDITABLE_SEGMENTS[segment.type];
|
|
275
|
-
if (segment.type === 'era' && calendar.getEras().length === 1) {
|
|
276
|
-
isEditable = false;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
let isPlaceholder = EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type];
|
|
280
|
-
let placeholder = EDITABLE_SEGMENTS[segment.type] ? getPlaceholder(segment.type, segment.value, locale) : null;
|
|
281
|
-
return {
|
|
282
|
-
type: TYPE_MAPPING[segment.type] || segment.type,
|
|
283
|
-
text: isPlaceholder ? placeholder : segment.value,
|
|
284
|
-
...getSegmentLimits(displayValue, segment.type, resolvedOptions),
|
|
285
|
-
isPlaceholder,
|
|
286
|
-
placeholder,
|
|
287
|
-
isEditable
|
|
288
|
-
} as DateSegment;
|
|
289
|
-
})
|
|
290
|
-
, [dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale]);
|
|
271
|
+
let segments = useMemo(() =>
|
|
272
|
+
processSegments(dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity),
|
|
273
|
+
[dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity]);
|
|
291
274
|
|
|
292
275
|
// When the era field appears, mark it valid if the year field is already valid.
|
|
293
276
|
// If the era field disappears, remove it from the valid segments.
|
|
@@ -399,6 +382,8 @@ export function useDateFieldState<T extends DateValue = DateValue>(props: DateFi
|
|
|
399
382
|
} else if (!isPM && shouldBePM) {
|
|
400
383
|
value = displayValue.set({hour: displayValue.hour + 12});
|
|
401
384
|
}
|
|
385
|
+
} else if (part === 'hour' && 'hour' in displayValue && displayValue.hour >= 12 && validSegments.dayPeriod) {
|
|
386
|
+
value = displayValue.set({hour: placeholder['hour'] + 12});
|
|
402
387
|
} else if (part in displayValue) {
|
|
403
388
|
value = displayValue.set({[part]: placeholder[part]});
|
|
404
389
|
}
|
|
@@ -423,6 +408,73 @@ export function useDateFieldState<T extends DateValue = DateValue>(props: DateFi
|
|
|
423
408
|
};
|
|
424
409
|
}
|
|
425
410
|
|
|
411
|
+
function processSegments(dateValue, validSegments, dateFormatter, resolvedOptions, displayValue, calendar, locale, granularity) : DateSegment[] {
|
|
412
|
+
let timeValue = ['hour', 'minute', 'second'];
|
|
413
|
+
let segments = dateFormatter.formatToParts(dateValue);
|
|
414
|
+
let processedSegments: DateSegment[] = [];
|
|
415
|
+
for (let segment of segments) {
|
|
416
|
+
let isEditable = EDITABLE_SEGMENTS[segment.type];
|
|
417
|
+
if (segment.type === 'era' && calendar.getEras().length === 1) {
|
|
418
|
+
isEditable = false;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
let isPlaceholder = EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type];
|
|
422
|
+
let placeholder = EDITABLE_SEGMENTS[segment.type] ? getPlaceholder(segment.type, segment.value, locale) : null;
|
|
423
|
+
|
|
424
|
+
let dateSegment = {
|
|
425
|
+
type: TYPE_MAPPING[segment.type] || segment.type,
|
|
426
|
+
text: isPlaceholder ? placeholder : segment.value,
|
|
427
|
+
...getSegmentLimits(displayValue, segment.type, resolvedOptions),
|
|
428
|
+
isPlaceholder,
|
|
429
|
+
placeholder,
|
|
430
|
+
isEditable
|
|
431
|
+
} as DateSegment;
|
|
432
|
+
|
|
433
|
+
// There is an issue in RTL languages where time fields render (minute:hour) instead of (hour:minute).
|
|
434
|
+
// To force an LTR direction on the time field since, we wrap the time segments in LRI (left-to-right) isolate unicode. See https://www.w3.org/International/questions/qa-bidi-unicode-controls.
|
|
435
|
+
// These unicode characters will be added to the array of processed segments as literals and will mark the start and end of the embedded direction change.
|
|
436
|
+
if (segment.type === 'hour') {
|
|
437
|
+
// This marks the start of the embedded direction change.
|
|
438
|
+
processedSegments.push({
|
|
439
|
+
type: 'literal',
|
|
440
|
+
text: '\u2066',
|
|
441
|
+
...getSegmentLimits(displayValue, 'literal', resolvedOptions),
|
|
442
|
+
isPlaceholder: false,
|
|
443
|
+
placeholder: '',
|
|
444
|
+
isEditable: false
|
|
445
|
+
});
|
|
446
|
+
processedSegments.push(dateSegment);
|
|
447
|
+
// This marks the end of the embedded direction change in the case that the granularity it set to "hour".
|
|
448
|
+
if (segment.type === granularity) {
|
|
449
|
+
processedSegments.push({
|
|
450
|
+
type: 'literal',
|
|
451
|
+
text: '\u2069',
|
|
452
|
+
...getSegmentLimits(displayValue, 'literal', resolvedOptions),
|
|
453
|
+
isPlaceholder: false,
|
|
454
|
+
placeholder: '',
|
|
455
|
+
isEditable: false
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
} else if (timeValue.includes(segment.type) && segment.type === granularity) {
|
|
459
|
+
processedSegments.push(dateSegment);
|
|
460
|
+
// This marks the end of the embedded direction change.
|
|
461
|
+
processedSegments.push({
|
|
462
|
+
type: 'literal',
|
|
463
|
+
text: '\u2069',
|
|
464
|
+
...getSegmentLimits(displayValue, 'literal', resolvedOptions),
|
|
465
|
+
isPlaceholder: false,
|
|
466
|
+
placeholder: '',
|
|
467
|
+
isEditable: false
|
|
468
|
+
});
|
|
469
|
+
} else {
|
|
470
|
+
// We only want to "wrap" the unicode around segments that are hour, minute, or second. If they aren't, just process as normal.
|
|
471
|
+
processedSegments.push(dateSegment);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
return processedSegments;
|
|
476
|
+
}
|
|
477
|
+
|
|
426
478
|
function getSegmentLimits(date: DateValue, type: string, options: Intl.ResolvedDateTimeFormatOptions) {
|
|
427
479
|
switch (type) {
|
|
428
480
|
case 'era': {
|