@wix/form-public 0.158.0 → 0.159.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 +101 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +27 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +101 -51
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -25673,6 +25673,96 @@ var useExperiments = () => {
|
|
|
25673
25673
|
isExperimentEnabled: (spec) => experiments[spec] === true || experiments[spec] === "true" || false
|
|
25674
25674
|
};
|
|
25675
25675
|
};
|
|
25676
|
+
|
|
25677
|
+
// ../form-fields/dist/esm/date-localization/local-date.js
|
|
25678
|
+
function startOfDay(date) {
|
|
25679
|
+
const result2 = new Date(date);
|
|
25680
|
+
result2.setHours(0, 0, 0, 0);
|
|
25681
|
+
return result2;
|
|
25682
|
+
}
|
|
25683
|
+
|
|
25684
|
+
// ../form-fields/dist/esm/field-settings/settings-shared/availability/availability.js
|
|
25685
|
+
var DEFAULT_AVAILABILITY = {
|
|
25686
|
+
daysOfWeek: [0, 1, 2, 3, 4, 5, 6]
|
|
25687
|
+
};
|
|
25688
|
+
function isDateAvailable(date, availability) {
|
|
25689
|
+
const d = date instanceof Date ? date : new Date(date);
|
|
25690
|
+
if (availability.daysOfWeek) {
|
|
25691
|
+
const dayOfWeek = d.getDay();
|
|
25692
|
+
if (!availability.daysOfWeek.includes(dayOfWeek)) {
|
|
25693
|
+
return false;
|
|
25694
|
+
}
|
|
25695
|
+
}
|
|
25696
|
+
if (availability.availableDateRanges && availability.availableDateRanges.length > 0) {
|
|
25697
|
+
const isInAvailableRange = availability.availableDateRanges.some((range) => isDateInRange(d, range));
|
|
25698
|
+
if (!isInAvailableRange) {
|
|
25699
|
+
return false;
|
|
25700
|
+
}
|
|
25701
|
+
}
|
|
25702
|
+
if (availability.unavailableDateRanges && availability.unavailableDateRanges.length > 0) {
|
|
25703
|
+
const isInUnavailableRange = availability.unavailableDateRanges.some((range) => isDateInRange(d, range));
|
|
25704
|
+
if (isInUnavailableRange) {
|
|
25705
|
+
return false;
|
|
25706
|
+
}
|
|
25707
|
+
}
|
|
25708
|
+
return true;
|
|
25709
|
+
}
|
|
25710
|
+
function isDateInRange(date, range) {
|
|
25711
|
+
const checkDate = startOfDay(date);
|
|
25712
|
+
const startDate = startOfDay(new Date(range.start));
|
|
25713
|
+
const endDate = startOfDay(new Date(range.end));
|
|
25714
|
+
return checkDate >= startDate && checkDate <= endDate;
|
|
25715
|
+
}
|
|
25716
|
+
|
|
25717
|
+
// ../form-fields/dist/esm/date-localization/get-first-day-of-the-week.js
|
|
25718
|
+
var DEFAULT_FIRST_DAY = 1;
|
|
25719
|
+
function getFirstDayOfTheWeek(locale) {
|
|
25720
|
+
try {
|
|
25721
|
+
const intlLocale = new Intl.Locale(locale);
|
|
25722
|
+
if (intlLocale.getWeekInfo) {
|
|
25723
|
+
const weekInfo = intlLocale.getWeekInfo();
|
|
25724
|
+
const firstDay = weekInfo.firstDay;
|
|
25725
|
+
if (firstDay !== void 0) {
|
|
25726
|
+
return firstDay === 7 ? 0 : firstDay;
|
|
25727
|
+
}
|
|
25728
|
+
}
|
|
25729
|
+
return getFirstDayManual(locale);
|
|
25730
|
+
} catch {
|
|
25731
|
+
return getFirstDayManual(locale);
|
|
25732
|
+
}
|
|
25733
|
+
}
|
|
25734
|
+
var REGIONS_STARTING_SATURDAY = ["AF", "BH", "DJ", "DZ", "EG", "IQ", "IR", "JO", "KW", "LY", "OM", "QA", "SD", "SY"];
|
|
25735
|
+
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"];
|
|
25736
|
+
var LANGUAGES_STARTING_SATURDAY = ["ar"];
|
|
25737
|
+
var LANGUAGES_STARTING_SUNDAY = ["en", "he", "hi", "id", "ja", "ko", "pt", "tl", "th"];
|
|
25738
|
+
function getFirstDayManual(locale) {
|
|
25739
|
+
try {
|
|
25740
|
+
var _intlLocale$language, _intlLocale$region;
|
|
25741
|
+
const intlLocale = new Intl.Locale(locale);
|
|
25742
|
+
const language = (_intlLocale$language = intlLocale.language) == null ? void 0 : _intlLocale$language.toLowerCase();
|
|
25743
|
+
const region = (_intlLocale$region = intlLocale.region) == null ? void 0 : _intlLocale$region.toUpperCase();
|
|
25744
|
+
if (region) {
|
|
25745
|
+
if (REGIONS_STARTING_SUNDAY.includes(region)) {
|
|
25746
|
+
return 0;
|
|
25747
|
+
}
|
|
25748
|
+
if (REGIONS_STARTING_SATURDAY.includes(region)) {
|
|
25749
|
+
return 6;
|
|
25750
|
+
}
|
|
25751
|
+
return DEFAULT_FIRST_DAY;
|
|
25752
|
+
}
|
|
25753
|
+
if (language) {
|
|
25754
|
+
if (LANGUAGES_STARTING_SUNDAY.includes(language)) {
|
|
25755
|
+
return 0;
|
|
25756
|
+
}
|
|
25757
|
+
if (LANGUAGES_STARTING_SATURDAY.includes(language)) {
|
|
25758
|
+
return 6;
|
|
25759
|
+
}
|
|
25760
|
+
}
|
|
25761
|
+
return DEFAULT_FIRST_DAY;
|
|
25762
|
+
} catch {
|
|
25763
|
+
return DEFAULT_FIRST_DAY;
|
|
25764
|
+
}
|
|
25765
|
+
}
|
|
25676
25766
|
var HttpClientContext = /* @__PURE__ */ React42.createContext(void 0);
|
|
25677
25767
|
var FormContext = /* @__PURE__ */ React42.createContext(void 0);
|
|
25678
25768
|
function useForm() {
|
|
@@ -34449,56 +34539,6 @@ var $35ea8db9cb2ccb90$export$ca871e8dbb80966f = class _$35ea8db9cb2ccb90$export$
|
|
|
34449
34539
|
}
|
|
34450
34540
|
};
|
|
34451
34541
|
|
|
34452
|
-
// ../form-fields/dist/esm/date-localization/get-first-day-of-the-week.js
|
|
34453
|
-
var DEFAULT_FIRST_DAY = 1;
|
|
34454
|
-
function getFirstDayOfTheWeek(locale) {
|
|
34455
|
-
try {
|
|
34456
|
-
const intlLocale = new Intl.Locale(locale);
|
|
34457
|
-
if (intlLocale.getWeekInfo) {
|
|
34458
|
-
const weekInfo = intlLocale.getWeekInfo();
|
|
34459
|
-
const firstDay = weekInfo.firstDay;
|
|
34460
|
-
if (firstDay !== void 0) {
|
|
34461
|
-
return firstDay === 7 ? 0 : firstDay;
|
|
34462
|
-
}
|
|
34463
|
-
}
|
|
34464
|
-
return getFirstDayManual(locale);
|
|
34465
|
-
} catch {
|
|
34466
|
-
return getFirstDayManual(locale);
|
|
34467
|
-
}
|
|
34468
|
-
}
|
|
34469
|
-
var REGIONS_STARTING_SATURDAY = ["AF", "BH", "DJ", "DZ", "EG", "IQ", "IR", "JO", "KW", "LY", "OM", "QA", "SD", "SY"];
|
|
34470
|
-
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"];
|
|
34471
|
-
var LANGUAGES_STARTING_SATURDAY = ["ar"];
|
|
34472
|
-
var LANGUAGES_STARTING_SUNDAY = ["en", "he", "hi", "id", "ja", "ko", "pt", "tl", "th"];
|
|
34473
|
-
function getFirstDayManual(locale) {
|
|
34474
|
-
try {
|
|
34475
|
-
var _intlLocale$language, _intlLocale$region;
|
|
34476
|
-
const intlLocale = new Intl.Locale(locale);
|
|
34477
|
-
const language = (_intlLocale$language = intlLocale.language) == null ? void 0 : _intlLocale$language.toLowerCase();
|
|
34478
|
-
const region = (_intlLocale$region = intlLocale.region) == null ? void 0 : _intlLocale$region.toUpperCase();
|
|
34479
|
-
if (region) {
|
|
34480
|
-
if (REGIONS_STARTING_SUNDAY.includes(region)) {
|
|
34481
|
-
return 0;
|
|
34482
|
-
}
|
|
34483
|
-
if (REGIONS_STARTING_SATURDAY.includes(region)) {
|
|
34484
|
-
return 6;
|
|
34485
|
-
}
|
|
34486
|
-
return DEFAULT_FIRST_DAY;
|
|
34487
|
-
}
|
|
34488
|
-
if (language) {
|
|
34489
|
-
if (LANGUAGES_STARTING_SUNDAY.includes(language)) {
|
|
34490
|
-
return 0;
|
|
34491
|
-
}
|
|
34492
|
-
if (LANGUAGES_STARTING_SATURDAY.includes(language)) {
|
|
34493
|
-
return 6;
|
|
34494
|
-
}
|
|
34495
|
-
}
|
|
34496
|
-
return DEFAULT_FIRST_DAY;
|
|
34497
|
-
} catch {
|
|
34498
|
-
return DEFAULT_FIRST_DAY;
|
|
34499
|
-
}
|
|
34500
|
-
}
|
|
34501
|
-
|
|
34502
34542
|
// ../form-fields/dist/esm/ui/date-picker-field/date-picker-field-headless.js
|
|
34503
34543
|
var DatePicker = (_ref) => {
|
|
34504
34544
|
let {
|
|
@@ -34608,12 +34648,22 @@ var Calendar = (_ref5) => {
|
|
|
34608
34648
|
const {
|
|
34609
34649
|
regionalFormat
|
|
34610
34650
|
} = useConfig();
|
|
34651
|
+
const {
|
|
34652
|
+
availability
|
|
34653
|
+
} = useFieldPropsV2();
|
|
34611
34654
|
const firstDayOfWeek = React42.useMemo(() => getFirstDayOfTheWeek(regionalFormat), [regionalFormat]);
|
|
34655
|
+
const isDateUnavailable = React42.useMemo(() => {
|
|
34656
|
+
return (date) => {
|
|
34657
|
+
const jsDate = date.toDate("UTC");
|
|
34658
|
+
return !isDateAvailable(jsDate, availability || DEFAULT_AVAILABILITY);
|
|
34659
|
+
};
|
|
34660
|
+
}, [availability]);
|
|
34612
34661
|
const dayElement = findChildOfType(children, Calendar.Day) ?? /* @__PURE__ */ React42__namespace.default.createElement(Calendar.Day, null);
|
|
34613
34662
|
return /* @__PURE__ */ React42__namespace.default.createElement(reactAriaComponents.Popover, {
|
|
34614
34663
|
className
|
|
34615
34664
|
}, /* @__PURE__ */ React42__namespace.default.createElement(reactAriaComponents.Dialog, null, /* @__PURE__ */ React42__namespace.default.createElement(reactAriaComponents.Calendar, {
|
|
34616
|
-
firstDayOfWeek: convertFirstDayOfWeek(firstDayOfWeek)
|
|
34665
|
+
firstDayOfWeek: convertFirstDayOfWeek(firstDayOfWeek),
|
|
34666
|
+
isDateUnavailable
|
|
34617
34667
|
}, /* @__PURE__ */ React42__namespace.default.createElement("header", null, /* @__PURE__ */ React42__namespace.default.createElement(reactAriaComponents.Button, {
|
|
34618
34668
|
slot: "previous"
|
|
34619
34669
|
}, "\u2039"), /* @__PURE__ */ React42__namespace.default.createElement(reactAriaComponents.Heading, null), /* @__PURE__ */ React42__namespace.default.createElement(reactAriaComponents.Button, {
|