@wix/form-public 0.151.0 → 0.152.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/index.cjs CHANGED
@@ -25575,13 +25575,6 @@ var normalizeDecimalSeparator = function(value) {
25575
25575
  }
25576
25576
  return value.replace(",", ".");
25577
25577
  };
25578
-
25579
- // ../form-fields/dist/esm/field-settings/settings-shared/first-day-of-week-constants.js
25580
- var FIRST_DAY_OF_WEEK = /* @__PURE__ */ (function(FIRST_DAY_OF_WEEK2) {
25581
- FIRST_DAY_OF_WEEK2["SUNDAY"] = "SUNDAY";
25582
- FIRST_DAY_OF_WEEK2["MONDAY"] = "MONDAY";
25583
- return FIRST_DAY_OF_WEEK2;
25584
- })({});
25585
25578
  var ExperimentsContext = /* @__PURE__ */ React42.createContext(void 0);
25586
25579
  var useExperiments = () => {
25587
25580
  const experiments = React42.useContext(ExperimentsContext) || {};
@@ -34244,6 +34237,56 @@ var $35ea8db9cb2ccb90$export$ca871e8dbb80966f = class _$35ea8db9cb2ccb90$export$
34244
34237
  }
34245
34238
  };
34246
34239
 
34240
+ // ../form-fields/dist/esm/date-localization/get-first-day-of-the-week.js
34241
+ var DEFAULT_FIRST_DAY = 1;
34242
+ function getFirstDayOfTheWeek(locale) {
34243
+ try {
34244
+ const intlLocale = new Intl.Locale(locale);
34245
+ if (intlLocale.getWeekInfo) {
34246
+ const weekInfo = intlLocale.getWeekInfo();
34247
+ const firstDay = weekInfo.firstDay;
34248
+ if (firstDay !== void 0) {
34249
+ return firstDay === 7 ? 0 : firstDay;
34250
+ }
34251
+ }
34252
+ return getFirstDayManual(locale);
34253
+ } catch {
34254
+ return getFirstDayManual(locale);
34255
+ }
34256
+ }
34257
+ var REGIONS_STARTING_SATURDAY = ["AF", "BH", "DJ", "DZ", "EG", "IQ", "IR", "JO", "KW", "LY", "OM", "QA", "SD", "SY"];
34258
+ var REGIONS_STARTING_SUNDAY = ["AG", "AS", "BD", "BR", "BS", "BT", "BW", "BZ", "CA", "CO", "DM", "DO", "ET", "GT", "GU", "HK", "HN", "ID", "IL", "IN", "IS", "JM", "JP", "KE", "KH", "KR", "LA", "MH", "MM", "MO", "MT", "MX", "MZ", "NI", "NP", "PA", "PE", "PH", "PK", "PR", "PT", "PY", "SA", "SG", "SV", "TH", "TT", "TW", "UM", "US", "VE", "VI", "WS", "YE", "ZA", "ZW"];
34259
+ var LANGUAGES_STARTING_SATURDAY = ["ar"];
34260
+ var LANGUAGES_STARTING_SUNDAY = ["en", "he", "hi", "id", "ja", "ko", "pt", "tl", "th"];
34261
+ function getFirstDayManual(locale) {
34262
+ try {
34263
+ var _intlLocale$language, _intlLocale$region;
34264
+ const intlLocale = new Intl.Locale(locale);
34265
+ const language = (_intlLocale$language = intlLocale.language) == null ? void 0 : _intlLocale$language.toLowerCase();
34266
+ const region = (_intlLocale$region = intlLocale.region) == null ? void 0 : _intlLocale$region.toUpperCase();
34267
+ if (region) {
34268
+ if (REGIONS_STARTING_SUNDAY.includes(region)) {
34269
+ return 0;
34270
+ }
34271
+ if (REGIONS_STARTING_SATURDAY.includes(region)) {
34272
+ return 6;
34273
+ }
34274
+ return DEFAULT_FIRST_DAY;
34275
+ }
34276
+ if (language) {
34277
+ if (LANGUAGES_STARTING_SUNDAY.includes(language)) {
34278
+ return 0;
34279
+ }
34280
+ if (LANGUAGES_STARTING_SATURDAY.includes(language)) {
34281
+ return 6;
34282
+ }
34283
+ }
34284
+ return DEFAULT_FIRST_DAY;
34285
+ } catch {
34286
+ return DEFAULT_FIRST_DAY;
34287
+ }
34288
+ }
34289
+
34247
34290
  // ../form-fields/dist/esm/ui/date-picker-field/date-picker-field-headless.js
34248
34291
  var DatePicker = (_ref) => {
34249
34292
  let {
@@ -34351,8 +34394,9 @@ var Calendar = (_ref5) => {
34351
34394
  className
34352
34395
  } = _ref5;
34353
34396
  const {
34354
- firstDayOfWeek
34355
- } = useFieldPropsV2();
34397
+ regionalFormat
34398
+ } = useConfig();
34399
+ const firstDayOfWeek = React42.useMemo(() => getFirstDayOfTheWeek(regionalFormat), [regionalFormat]);
34356
34400
  const dayElement = findChildOfType(children, Calendar.Day) ?? /* @__PURE__ */ React42__namespace.default.createElement(Calendar.Day, null);
34357
34401
  return /* @__PURE__ */ React42__namespace.default.createElement(reactAriaComponents.Popover, {
34358
34402
  className
@@ -34407,10 +34451,8 @@ function dateValueToString(date) {
34407
34451
  return `${year}-${month}-${day}`;
34408
34452
  }
34409
34453
  function convertFirstDayOfWeek(firstDayOfWeek) {
34410
- if (!firstDayOfWeek) {
34411
- return void 0;
34412
- }
34413
- return firstDayOfWeek === FIRST_DAY_OF_WEEK.SUNDAY ? "sun" : "mon";
34454
+ const days = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
34455
+ return days[firstDayOfWeek] || "mon";
34414
34456
  }
34415
34457
 
34416
34458
  // ../form-fields/dist/esm/ui/date-time-field/date-time-field-headless.js