@platned/ui 0.6.0 → 0.6.1

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
@@ -254,6 +254,7 @@ __export(src_exports, {
254
254
  WidgetTitle: () => WidgetTitle,
255
255
  cn: () => cn,
256
256
  countryOptions: () => countryOptions,
257
+ currentZoneName: () => currentZoneName,
257
258
  getScoreTone: () => getScoreTone,
258
259
  paginationRange: () => paginationRange,
259
260
  resolveChartColor: () => resolveChartColor,
@@ -1893,7 +1894,7 @@ var SelectControl = (0, import_react16.forwardRef)(
1893
1894
  "aria-required": field["aria-required"],
1894
1895
  "aria-invalid": field["aria-invalid"],
1895
1896
  style: { ...floatingStyles, width: "var(--panel-anchor-width)" },
1896
- className: (0, import_clsx14.default)("z-dropdown", OVERLAY_PANEL, OVERLAY_PANEL_SCROLL),
1897
+ className: (0, import_clsx14.default)("z-popover", OVERLAY_PANEL, OVERLAY_PANEL_SCROLL),
1897
1898
  ...roving.containerProps,
1898
1899
  onKeyDown: (event) => {
1899
1900
  roving.containerProps.onKeyDown(event);
@@ -3066,7 +3067,7 @@ function Combobox({
3066
3067
  role: "listbox",
3067
3068
  "aria-label": label,
3068
3069
  style: { ...floatingStyles, width: "var(--panel-anchor-width)" },
3069
- className: (0, import_clsx25.default)("z-dropdown", OVERLAY_PANEL, OVERLAY_PANEL_SCROLL),
3070
+ className: (0, import_clsx25.default)("z-popover", OVERLAY_PANEL, OVERLAY_PANEL_SCROLL),
3070
3071
  children: [
3071
3072
  matches.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "px-2.5 py-2 text-body-xs text-default-secondary", children: emptyMessage }),
3072
3073
  matches.map((option, index) => {
@@ -3180,7 +3181,13 @@ function CountrySelect({
3180
3181
  emptyMessage = "No countries match",
3181
3182
  ...props
3182
3183
  }) {
3183
- const options = (0, import_react23.useMemo)(() => countryOptions(countries, locale), [countries, locale]);
3184
+ const keep = [props.value, props.defaultValue].filter((v) => !!v);
3185
+ const keepKey = keep.join("|");
3186
+ const options = (0, import_react23.useMemo)(() => {
3187
+ const list = countryOptions(countries, locale);
3188
+ const missing = keep.filter((v) => !list.some((o) => o.value === v));
3189
+ return [...countryOptions(missing, locale), ...list];
3190
+ }, [countries, locale, keepKey]);
3184
3191
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3185
3192
  Combobox,
3186
3193
  {
@@ -3199,6 +3206,19 @@ function CountrySelect({
3199
3206
  // src/components/forms/time-zone-select.tsx
3200
3207
  var import_react24 = require("react");
3201
3208
  var import_jsx_runtime26 = require("react/jsx-runtime");
3209
+ var RENAMED = {
3210
+ "America/Godthab": "America/Nuuk",
3211
+ "Asia/Calcutta": "Asia/Kolkata",
3212
+ "Asia/Katmandu": "Asia/Kathmandu",
3213
+ "Asia/Rangoon": "Asia/Yangon",
3214
+ "Asia/Saigon": "Asia/Ho_Chi_Minh",
3215
+ "Atlantic/Faeroe": "Atlantic/Faroe",
3216
+ "Europe/Kiev": "Europe/Kyiv",
3217
+ "Pacific/Enderbury": "Pacific/Kanton",
3218
+ "Pacific/Ponape": "Pacific/Pohnpei",
3219
+ "Pacific/Truk": "Pacific/Chuuk"
3220
+ };
3221
+ var currentZoneName = (zone) => RENAMED[zone] ?? zone;
3202
3222
  function supportedTimeZones() {
3203
3223
  const intl = Intl;
3204
3224
  try {
@@ -3221,11 +3241,12 @@ function timeZoneOffset(timeZone, at = /* @__PURE__ */ new Date()) {
3221
3241
  }
3222
3242
  }
3223
3243
  function timeZoneOptions(zones = supportedTimeZones(), at = /* @__PURE__ */ new Date()) {
3224
- return zones.map((zone) => ({ zone, offset: timeZoneOffset(zone, at) })).sort((a, b) => a.offset.minutes - b.offset.minutes || a.zone.localeCompare(b.zone)).map(({ zone, offset: offset2 }) => ({
3225
- value: zone,
3226
- label: `(UTC${offset2.label}) ${zone.replace(/_/g, " ")}`
3227
- }));
3244
+ return Array.from(new Set(zones.map(currentZoneName))).map((zone) => ({ zone, minutes: timeZoneOffset(zone, at).minutes })).sort((a, b) => a.minutes - b.minutes || a.zone.localeCompare(b.zone)).map(({ zone }) => zoneOption(zone, at));
3228
3245
  }
3246
+ var zoneOption = (zone, at) => ({
3247
+ value: zone,
3248
+ label: `(UTC${timeZoneOffset(zone, at).label}) ${zone.replace(/_/g, " ")}`
3249
+ });
3229
3250
  function TimeZoneSelect({
3230
3251
  timeZones,
3231
3252
  at,
@@ -3234,10 +3255,14 @@ function TimeZoneSelect({
3234
3255
  ...props
3235
3256
  }) {
3236
3257
  const atTime = at?.getTime();
3237
- const options = (0, import_react24.useMemo)(
3238
- () => timeZoneOptions(timeZones, atTime === void 0 ? void 0 : new Date(atTime)),
3239
- [timeZones, atTime]
3240
- );
3258
+ const keep = [props.value, props.defaultValue].filter((v) => !!v);
3259
+ const keepKey = keep.join("|");
3260
+ const options = (0, import_react24.useMemo)(() => {
3261
+ const when = atTime === void 0 ? /* @__PURE__ */ new Date() : new Date(atTime);
3262
+ const list = timeZoneOptions(timeZones, when);
3263
+ const missing = keep.filter((v) => !list.some((o) => o.value === v));
3264
+ return [...missing.map((v) => zoneOption(v, when)), ...list];
3265
+ }, [timeZones, atTime, keepKey]);
3241
3266
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3242
3267
  Combobox,
3243
3268
  {
@@ -5525,7 +5550,7 @@ function MenubarContent({ children, className, ...rest }) {
5525
5550
  "aria-orientation": "vertical",
5526
5551
  "aria-labelledby": menu.triggerId,
5527
5552
  style: floatingStyles,
5528
- className: (0, import_clsx48.default)("z-dropdown", MENU_PANEL_CLASSES, className),
5553
+ className: (0, import_clsx48.default)("z-popover", MENU_PANEL_CLASSES, className),
5529
5554
  ...menu.roving.containerProps,
5530
5555
  onKeyDown: (event) => {
5531
5556
  menu.roving.containerProps.onKeyDown(event);
@@ -5915,7 +5940,7 @@ function DropdownMenuContent({
5915
5940
  "aria-orientation": "vertical",
5916
5941
  "aria-labelledby": menu.triggerId,
5917
5942
  style: floatingStyles,
5918
- className: (0, import_clsx51.default)("z-dropdown", MENU_PANEL_CLASSES, className),
5943
+ className: (0, import_clsx51.default)("z-popover", MENU_PANEL_CLASSES, className),
5919
5944
  ...menu.roving.containerProps,
5920
5945
  onKeyDown: (event) => {
5921
5946
  menu.roving.containerProps.onKeyDown(event);
@@ -9756,6 +9781,7 @@ function AuroraBackdrop() {
9756
9781
  WidgetTitle,
9757
9782
  cn,
9758
9783
  countryOptions,
9784
+ currentZoneName,
9759
9785
  getScoreTone,
9760
9786
  paginationRange,
9761
9787
  resolveChartColor,