@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.js CHANGED
@@ -25549,13 +25549,6 @@ var normalizeDecimalSeparator = function(value) {
25549
25549
  }
25550
25550
  return value.replace(",", ".");
25551
25551
  };
25552
-
25553
- // ../form-fields/dist/esm/field-settings/settings-shared/first-day-of-week-constants.js
25554
- var FIRST_DAY_OF_WEEK = /* @__PURE__ */ (function(FIRST_DAY_OF_WEEK2) {
25555
- FIRST_DAY_OF_WEEK2["SUNDAY"] = "SUNDAY";
25556
- FIRST_DAY_OF_WEEK2["MONDAY"] = "MONDAY";
25557
- return FIRST_DAY_OF_WEEK2;
25558
- })({});
25559
25552
  var ExperimentsContext = /* @__PURE__ */ createContext(void 0);
25560
25553
  var useExperiments = () => {
25561
25554
  const experiments = useContext(ExperimentsContext) || {};
@@ -34218,6 +34211,56 @@ var $35ea8db9cb2ccb90$export$ca871e8dbb80966f = class _$35ea8db9cb2ccb90$export$
34218
34211
  }
34219
34212
  };
34220
34213
 
34214
+ // ../form-fields/dist/esm/date-localization/get-first-day-of-the-week.js
34215
+ var DEFAULT_FIRST_DAY = 1;
34216
+ function getFirstDayOfTheWeek(locale) {
34217
+ try {
34218
+ const intlLocale = new Intl.Locale(locale);
34219
+ if (intlLocale.getWeekInfo) {
34220
+ const weekInfo = intlLocale.getWeekInfo();
34221
+ const firstDay = weekInfo.firstDay;
34222
+ if (firstDay !== void 0) {
34223
+ return firstDay === 7 ? 0 : firstDay;
34224
+ }
34225
+ }
34226
+ return getFirstDayManual(locale);
34227
+ } catch {
34228
+ return getFirstDayManual(locale);
34229
+ }
34230
+ }
34231
+ var REGIONS_STARTING_SATURDAY = ["AF", "BH", "DJ", "DZ", "EG", "IQ", "IR", "JO", "KW", "LY", "OM", "QA", "SD", "SY"];
34232
+ 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"];
34233
+ var LANGUAGES_STARTING_SATURDAY = ["ar"];
34234
+ var LANGUAGES_STARTING_SUNDAY = ["en", "he", "hi", "id", "ja", "ko", "pt", "tl", "th"];
34235
+ function getFirstDayManual(locale) {
34236
+ try {
34237
+ var _intlLocale$language, _intlLocale$region;
34238
+ const intlLocale = new Intl.Locale(locale);
34239
+ const language = (_intlLocale$language = intlLocale.language) == null ? void 0 : _intlLocale$language.toLowerCase();
34240
+ const region = (_intlLocale$region = intlLocale.region) == null ? void 0 : _intlLocale$region.toUpperCase();
34241
+ if (region) {
34242
+ if (REGIONS_STARTING_SUNDAY.includes(region)) {
34243
+ return 0;
34244
+ }
34245
+ if (REGIONS_STARTING_SATURDAY.includes(region)) {
34246
+ return 6;
34247
+ }
34248
+ return DEFAULT_FIRST_DAY;
34249
+ }
34250
+ if (language) {
34251
+ if (LANGUAGES_STARTING_SUNDAY.includes(language)) {
34252
+ return 0;
34253
+ }
34254
+ if (LANGUAGES_STARTING_SATURDAY.includes(language)) {
34255
+ return 6;
34256
+ }
34257
+ }
34258
+ return DEFAULT_FIRST_DAY;
34259
+ } catch {
34260
+ return DEFAULT_FIRST_DAY;
34261
+ }
34262
+ }
34263
+
34221
34264
  // ../form-fields/dist/esm/ui/date-picker-field/date-picker-field-headless.js
34222
34265
  var DatePicker = (_ref) => {
34223
34266
  let {
@@ -34325,8 +34368,9 @@ var Calendar = (_ref5) => {
34325
34368
  className
34326
34369
  } = _ref5;
34327
34370
  const {
34328
- firstDayOfWeek
34329
- } = useFieldPropsV2();
34371
+ regionalFormat
34372
+ } = useConfig();
34373
+ const firstDayOfWeek = useMemo(() => getFirstDayOfTheWeek(regionalFormat), [regionalFormat]);
34330
34374
  const dayElement = findChildOfType(children, Calendar.Day) ?? /* @__PURE__ */ React42__default.createElement(Calendar.Day, null);
34331
34375
  return /* @__PURE__ */ React42__default.createElement(Popover, {
34332
34376
  className
@@ -34381,10 +34425,8 @@ function dateValueToString(date) {
34381
34425
  return `${year}-${month}-${day}`;
34382
34426
  }
34383
34427
  function convertFirstDayOfWeek(firstDayOfWeek) {
34384
- if (!firstDayOfWeek) {
34385
- return void 0;
34386
- }
34387
- return firstDayOfWeek === FIRST_DAY_OF_WEEK.SUNDAY ? "sun" : "mon";
34428
+ const days = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
34429
+ return days[firstDayOfWeek] || "mon";
34388
34430
  }
34389
34431
 
34390
34432
  // ../form-fields/dist/esm/ui/date-time-field/date-time-field-headless.js