@vritti/quantum-ui 0.6.5 → 0.6.7

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.
Files changed (91) hide show
  1. package/dist/CurrencyFieldFilter.js +1 -1
  2. package/dist/CurrencySelector.js.map +1 -1
  3. package/dist/DateRangePicker.js +1 -1
  4. package/dist/DateTimePicker.js +1 -1
  5. package/dist/DropdownMenu.js +64 -33
  6. package/dist/DropdownMenu.js.map +1 -1
  7. package/dist/ISOCountrySelect.js.map +1 -1
  8. package/dist/LocaleSelector.js.map +1 -1
  9. package/dist/QuantityField.js +190 -0
  10. package/dist/QuantityField.js.map +1 -0
  11. package/dist/Select.js.map +1 -1
  12. package/dist/SelectFilter.js +1 -1
  13. package/dist/Sidebar.js +1 -1
  14. package/dist/SingleSelect.js +3 -2
  15. package/dist/SingleSelect.js.map +1 -1
  16. package/dist/Spinner.js +1 -7
  17. package/dist/Spinner.js.map +1 -1
  18. package/dist/Spinner2.js +10 -0
  19. package/dist/Spinner2.js.map +1 -0
  20. package/dist/SwitchFilter.js +80 -0
  21. package/dist/SwitchFilter.js.map +1 -0
  22. package/dist/TimezoneSelector.js.map +1 -1
  23. package/dist/ValueFilter.js +1 -1
  24. package/dist/assets/quantum-ui.css +49 -0
  25. package/dist/calendar2.js +1 -1
  26. package/dist/components/DateFilter.js +1 -1
  27. package/dist/components/FormattedDate.js +1 -1
  28. package/dist/components/QuantityField.js +2 -0
  29. package/dist/components/QuantityField.js.map +1 -0
  30. package/dist/components/Select.js.map +1 -1
  31. package/dist/components/Switch.js +1 -0
  32. package/dist/components/Switch.js.map +1 -1
  33. package/dist/contextAnchor.js +3 -2
  34. package/dist/contextAnchor.js.map +1 -1
  35. package/dist/dropdown-menu.js +1 -1
  36. package/dist/index.js +3 -1
  37. package/dist/index.js.map +1 -1
  38. package/dist/index6.js +90 -382
  39. package/dist/index6.js.map +1 -1
  40. package/dist/index7.js +382 -90
  41. package/dist/index7.js.map +1 -1
  42. package/dist/lib/components/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  43. package/dist/lib/components/DropdownMenu/types.d.ts +1 -0
  44. package/dist/lib/components/DropdownMenu/types.d.ts.map +1 -1
  45. package/dist/lib/components/QuantityField/QuantityField.d.ts +22 -0
  46. package/dist/lib/components/QuantityField/QuantityField.d.ts.map +1 -0
  47. package/dist/lib/components/QuantityField/index.d.ts +3 -0
  48. package/dist/lib/components/QuantityField/index.d.ts.map +1 -0
  49. package/dist/lib/components/QuantityField/quantity.d.ts +13 -0
  50. package/dist/lib/components/QuantityField/quantity.d.ts.map +1 -0
  51. package/dist/lib/components/Select/Select.d.ts +11 -3
  52. package/dist/lib/components/Select/Select.d.ts.map +1 -1
  53. package/dist/lib/components/Select/components/SingleSelect/SingleSelect.d.ts +10 -3
  54. package/dist/lib/components/Select/components/SingleSelect/SingleSelect.d.ts.map +1 -1
  55. package/dist/lib/components/Select/contextAnchor.d.ts +3 -0
  56. package/dist/lib/components/Select/contextAnchor.d.ts.map +1 -1
  57. package/dist/lib/components/Select/index.d.ts +1 -1
  58. package/dist/lib/components/Select/index.d.ts.map +1 -1
  59. package/dist/lib/components/Switch/SwitchFilter.d.ts +21 -0
  60. package/dist/lib/components/Switch/SwitchFilter.d.ts.map +1 -0
  61. package/dist/lib/components/Switch/index.d.ts +2 -0
  62. package/dist/lib/components/Switch/index.d.ts.map +1 -1
  63. package/dist/lib/components/index.d.ts +1 -0
  64. package/dist/lib/components/index.d.ts.map +1 -1
  65. package/dist/lib/hooks/useFormatters.d.ts +2 -1
  66. package/dist/lib/hooks/useFormatters.d.ts.map +1 -1
  67. package/dist/lib/selects/currency/CurrencySelector.d.ts +3 -4
  68. package/dist/lib/selects/currency/CurrencySelector.d.ts.map +1 -1
  69. package/dist/lib/selects/iso-country/ISOCountrySelect.d.ts +1 -1
  70. package/dist/lib/selects/iso-country/ISOCountrySelect.d.ts.map +1 -1
  71. package/dist/lib/selects/locale/LocaleSelector.d.ts +2 -1
  72. package/dist/lib/selects/locale/LocaleSelector.d.ts.map +1 -1
  73. package/dist/lib/selects/timezone/TimezoneSelector.d.ts +2 -1
  74. package/dist/lib/selects/timezone/TimezoneSelector.d.ts.map +1 -1
  75. package/dist/lib/types/catalog-resolver.d.ts +3 -7
  76. package/dist/lib/types/catalog-resolver.d.ts.map +1 -1
  77. package/dist/lib/utils/format.d.ts +13 -0
  78. package/dist/lib/utils/format.d.ts.map +1 -1
  79. package/dist/timezone.js +2 -2
  80. package/dist/types/catalog-resolver.js.map +1 -1
  81. package/dist/useContextState.js +1 -1
  82. package/dist/useDataTable.js +1 -1
  83. package/dist/useFormatters.js +2 -1
  84. package/dist/useFormatters.js.map +1 -1
  85. package/dist/useWorkspaceCurrency.js +1 -1
  86. package/dist/utils/axios.js +1 -1
  87. package/dist/utils/currency.js +1 -1
  88. package/dist/utils/format.js +17 -2
  89. package/dist/utils/format.js.map +1 -1
  90. package/dist/utils/timezone.js +2 -2
  91. package/package.json +5 -1
@@ -1 +1 @@
1
- {"version":3,"file":"format.js","sources":["../../lib/utils/format.ts"],"sourcesContent":["// Pure value-formatting helpers (no hooks) returning { primary, secondary? } for DetailField, DataTable cells, etc.\nimport { tz } from '@date-fns/tz';\nimport type { Locale } from 'date-fns';\nimport { format, isValid, parseISO } from 'date-fns';\nimport type React from 'react';\nimport Decimal from './decimal';\nimport { formatCurrencyMajor } from './money';\nimport { getUserTimeZone } from './timezone';\n\nexport type CurrencyAmount = { currency: string; value: string };\n\nexport type FormattedValue = { primary: React.ReactNode; secondary?: string };\n\nconst DATE_ONLY_PATTERN = /^\\d{4}-\\d{2}-\\d{2}$/;\n\nconst formatWithTimeZone = (date: Date, dateFormat: string, timeZone: string, locale?: Locale) =>\n format(date, dateFormat, locale ? { in: tz(timeZone), locale } : { in: tz(timeZone) });\n\nconst parseDateOnly = (value: string): Date => parseISO(DATE_ONLY_PATTERN.test(value) ? `${value}T00:00:00Z` : value);\n\nexport const formatString = (value: React.ReactNode): FormattedValue => {\n if (value == null) return { primary: '—' };\n // Treat empty/whitespace strings as \"no value\", but let JSX/element values pass through untouched.\n if (typeof value === 'string' && value.trim() === '') return { primary: '—' };\n return { primary: value };\n};\n\n// One Intl.NumberFormat per locale and options, reused: building one costs far more than formatting with it, and a\n// table formats the same few shapes on every row\nconst numberFormatters = new Map<string, Intl.NumberFormat>();\nfunction numberFormatter(localeTag: string, options?: Intl.NumberFormatOptions): Intl.NumberFormat {\n const key = `${localeTag}|${JSON.stringify(options ?? {})}`;\n const cached = numberFormatters.get(key);\n if (cached) return cached;\n const formatter = new Intl.NumberFormat(localeTag, options);\n numberFormatters.set(key, formatter);\n return formatter;\n}\n\nexport interface FormatNumberOptions {\n localeTag: string;\n fractionDigits?: number;\n}\n\nexport const formatNumber = (\n value: number | string | null | undefined,\n options: FormatNumberOptions,\n): FormattedValue => {\n if (value == null) return { primary: '—' };\n const num = typeof value === 'number' ? value : Number(value);\n if (!Number.isFinite(num)) return { primary: '—' };\n const formatter = numberFormatter(\n options.localeTag,\n options.fractionDigits != null\n ? { minimumFractionDigits: options.fractionDigits, maximumFractionDigits: options.fractionDigits }\n : undefined,\n );\n return { primary: formatter.format(num) };\n};\n\nexport interface FormatPercentOptions {\n localeTag: string;\n maximumFractionDigits?: number;\n}\n\n// Formats a percentage given on a 0–100 scale (42.5 → \"42.5%\"), one decimal at most unless told otherwise\nexport const formatPercent = (\n value: number | string | null | undefined,\n options: FormatPercentOptions,\n): FormattedValue => {\n if (value == null) return { primary: '—' };\n const num = typeof value === 'number' ? value : Number(value);\n if (!Number.isFinite(num)) return { primary: '—' };\n const formatter = numberFormatter(options.localeTag, {\n style: 'percent',\n maximumFractionDigits: options.maximumFractionDigits ?? 1,\n });\n return { primary: formatter.format(new Decimal(num).div(100).toNumber()) };\n};\n\nexport interface FormatCurrencyOptions {\n workspaceCurrency?: string | null;\n exchangeRate?: number | null;\n}\n\nexport const formatCurrency = (\n value: CurrencyAmount | null | undefined,\n options: FormatCurrencyOptions = {},\n): FormattedValue => {\n if (value == null) return { primary: '—' };\n const { currency, value: amountStr } = value;\n const amount = Number(amountStr);\n if (!Number.isFinite(amount)) return { primary: '—' };\n const primary = formatCurrencyMajor(amount, currency);\n\n const { workspaceCurrency, exchangeRate } = options;\n if (exchangeRate != null && Number.isFinite(exchangeRate) && workspaceCurrency && workspaceCurrency !== currency) {\n const workspaceAmount = new Decimal(amountStr).times(exchangeRate).toNumber();\n if (Number.isFinite(workspaceAmount)) {\n return { primary, secondary: `(${formatCurrencyMajor(workspaceAmount, workspaceCurrency)})` };\n }\n }\n return { primary };\n};\n\nexport interface FormatDateOptions {\n locale?: Locale;\n}\n\nexport const formatDate = (value: string | null | undefined, options: FormatDateOptions = {}): FormattedValue => {\n if (value == null) return { primary: '—' };\n const parsed = DATE_ONLY_PATTERN.test(value) ? parseDateOnly(value) : parseISO(value);\n if (!isValid(parsed)) return { primary: '—' };\n // Render date-only values in UTC so the displayed day matches the stored YYYY-MM-DD.\n return { primary: formatWithTimeZone(parsed, 'P', 'UTC', options.locale) };\n};\n\nexport interface FormatDateTimeOptions {\n locale?: Locale;\n workspaceTimeZone?: string | null;\n timeZoneOverride?: string;\n}\n\nexport const formatDateTime = (\n value: string | null | undefined,\n options: FormatDateTimeOptions = {},\n): FormattedValue => {\n if (value == null) return { primary: '—' };\n const parsed = parseISO(value);\n if (!isValid(parsed)) return { primary: '—' };\n\n const primaryTz = options.timeZoneOverride ?? options.workspaceTimeZone ?? null;\n if (!primaryTz) {\n return { primary: format(parsed, 'Pp', options.locale ? { locale: options.locale } : undefined) };\n }\n const primary = `${formatWithTimeZone(parsed, 'Pp', primaryTz, options.locale)} (${primaryTz})`;\n const userTz = getUserTimeZone();\n if (!userTz || userTz === primaryTz) return { primary };\n return {\n primary,\n secondary: `Your time: ${formatWithTimeZone(parsed, 'Pp', userTz, options.locale)} (${userTz})`,\n };\n};\n"],"names":[],"mappings":";;;;;;;AAaA,MAAM,iBAAA,GAAoB,qBAAA;AAE1B,MAAM,kBA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,KAAK,KAAA,EAAO,OAAA,CAAQ,MAAM,CAAA,EAAE;AAC3E;AAQO,MAAM,cAAA,GAAiB,CAC5B,KAAA,EACA,OAAA,GAAiC,EAAC,KACf;AACnB,EAAA,IAAI,KAAA,IAAS,IAAA,EAAM,OAAO,EAAE,SAAS,GAAA,EAAI;AACzC,EAAA,MAAM,MAAA,GAAS,SAAS,KAAK,CAAA;AAC7B,EAAA,IAAI,CAAC,OAAA,CAAQ,MAAM,GAAG,OAAO,EAAE,SAAS,GAAA,EAAI;AAE5C,EAAA,MAAM,SAAA,GAAY,OAAA,CAAQ,gBAAA,IAAoB,OAAA,CAAQ,iBAAA,IAAqB,IAAA;AAC3E,EAAA,IAAI,CAAC,SAAA,EAAW;AACd,IAAA,OAAO,EAAE,OAAA,EAAS,MAAA,CAAO,MAAA,EAAQ,IAAA,EAAM,OAAA,CAAQ,MAAA,GAAS,EAAE,MAAA,EAAQ,OAAA,CAAQ,MAAA,EAAO,GAAI,MAAS,CAAA,EAAE;AAAA,EAClG;AACA,EAAA,MAAM,OAAA,GAAU,CAAA,EAAG,kBAAA,CAAmB,MAAA,EAAQ,IAAA,EAAM,WAAW,OAAA,CAAQ,MAAM,CAAC,CAAA,EAAA,EAAK,SAAS,CAAA,CAAA,CAAA;AAC5F,EAAA,MAAM,SAAS,eAAA,EAAgB;AAC/B,EAAA,IAAI,CAAC,MAAA,IAAU,MAAA,KAAW,SAAA,EAAW,OAAO,EAAE,OAAA,EAAQ;AACtD,EAAA,OAAO;AAAA,IACL,OAAA;AAAA,IACA,SAAA,EAAW,CAAA,WAAA,EAAc,kBAAA,CAAmB,MAAA,EAAQ,IAAA,EAAM,QAAQ,OAAA,CAAQ,MAAM,CAAC,CAAA,EAAA,EAAK,MAAM,CAAA,CAAA;AAAA,GAC9F;AACF;;;;"}
1
+ {"version":3,"file":"format.js","sources":["../../lib/utils/format.ts"],"sourcesContent":["// Pure value-formatting helpers (no hooks) returning { primary, secondary? } for DetailField, DataTable cells, etc.\nimport { tz } from '@date-fns/tz';\nimport type { Locale } from 'date-fns';\nimport { format, isValid, parseISO } from 'date-fns';\nimport type React from 'react';\nimport Decimal from './decimal';\nimport { formatCurrencyMajor } from './money';\nimport { getUserTimeZone } from './timezone';\n\nexport type CurrencyAmount = { currency: string; value: string };\n\nexport type FormattedValue = { primary: React.ReactNode; secondary?: string };\n\nconst DATE_ONLY_PATTERN = /^\\d{4}-\\d{2}-\\d{2}$/;\n\nconst formatWithTimeZone = (date: Date, dateFormat: string, timeZone: string, locale?: Locale) =>\n format(date, dateFormat, locale ? { in: tz(timeZone), locale } : { in: tz(timeZone) });\n\nconst parseDateOnly = (value: string): Date => parseISO(DATE_ONLY_PATTERN.test(value) ? `${value}T00:00:00Z` : value);\n\nexport const formatString = (value: React.ReactNode): FormattedValue => {\n if (value == null) return { primary: '—' };\n // Treat empty/whitespace strings as \"no value\", but let JSX/element values pass through untouched.\n if (typeof value === 'string' && value.trim() === '') return { primary: '—' };\n return { primary: value };\n};\n\n// One Intl.NumberFormat per locale and options, reused: building one costs far more than formatting with it, and a\n// table formats the same few shapes on every row\nconst numberFormatters = new Map<string, Intl.NumberFormat>();\nfunction numberFormatter(localeTag: string, options?: Intl.NumberFormatOptions): Intl.NumberFormat {\n const key = `${localeTag}|${JSON.stringify(options ?? {})}`;\n const cached = numberFormatters.get(key);\n if (cached) return cached;\n const formatter = new Intl.NumberFormat(localeTag, options);\n numberFormatters.set(key, formatter);\n return formatter;\n}\n\nexport interface FormatNumberOptions {\n localeTag: string;\n fractionDigits?: number;\n}\n\nexport const formatNumber = (\n value: number | string | null | undefined,\n options: FormatNumberOptions,\n): FormattedValue => {\n if (value == null) return { primary: '—' };\n const num = typeof value === 'number' ? value : Number(value);\n if (!Number.isFinite(num)) return { primary: '—' };\n const formatter = numberFormatter(\n options.localeTag,\n options.fractionDigits != null\n ? { minimumFractionDigits: options.fractionDigits, maximumFractionDigits: options.fractionDigits }\n : undefined,\n );\n return { primary: formatter.format(num) };\n};\n\nexport interface FormatPercentOptions {\n localeTag: string;\n maximumFractionDigits?: number;\n}\n\n// Formats a percentage given on a 0–100 scale (42.5 → \"42.5%\"), one decimal at most unless told otherwise\nexport const formatPercent = (\n value: number | string | null | undefined,\n options: FormatPercentOptions,\n): FormattedValue => {\n if (value == null) return { primary: '—' };\n const num = typeof value === 'number' ? value : Number(value);\n if (!Number.isFinite(num)) return { primary: '—' };\n const formatter = numberFormatter(options.localeTag, {\n style: 'percent',\n maximumFractionDigits: options.maximumFractionDigits ?? 1,\n });\n return { primary: formatter.format(new Decimal(num).div(100).toNumber()) };\n};\n\nexport type DisplayQuantity = {\n primaryUomQty: number;\n displayUomQty: number;\n wholeDisplayUomQty: number;\n remainderPrimaryUomQty: number;\n displayUomSymbol: string;\n primaryUomSymbol: string;\n isPack: boolean;\n};\n\nexport interface FormatQuantityOptions {\n localeTag: string;\n}\n\n// Formats an item quantity in its display unit: a pack unit as whole packs plus the primary units left over (\"234 strip\n// + 4 tab\"), any other unit as one figure (\"12.5 kg\"); the primary-unit total is the secondary whenever it differs\nexport const formatQuantity = (\n value: DisplayQuantity | null | undefined,\n options: FormatQuantityOptions,\n): FormattedValue => {\n if (value == null) return { primary: '—' };\n const number = numberFormatter(options.localeTag);\n const inPrimary = `${number.format(value.primaryUomQty)} ${value.primaryUomSymbol}`;\n if (value.displayUomSymbol === value.primaryUomSymbol) return { primary: inPrimary };\n if (!value.isPack) {\n return { primary: `${number.format(value.displayUomQty)} ${value.displayUomSymbol}`, secondary: inPrimary };\n }\n if (value.wholeDisplayUomQty === 0) return { primary: inPrimary };\n const packs = `${number.format(value.wholeDisplayUomQty)} ${value.displayUomSymbol}`;\n if (value.remainderPrimaryUomQty === 0) return { primary: packs, secondary: inPrimary };\n const sign = value.remainderPrimaryUomQty < 0 ? '−' : '+';\n const remainder = `${number.format(Math.abs(value.remainderPrimaryUomQty))} ${value.primaryUomSymbol}`;\n return { primary: `${packs} ${sign} ${remainder}`, secondary: inPrimary };\n};\n\nexport interface FormatCurrencyOptions {\n workspaceCurrency?: string | null;\n exchangeRate?: number | null;\n}\n\nexport const formatCurrency = (\n value: CurrencyAmount | null | undefined,\n options: FormatCurrencyOptions = {},\n): FormattedValue => {\n if (value == null) return { primary: '—' };\n const { currency, value: amountStr } = value;\n const amount = Number(amountStr);\n if (!Number.isFinite(amount)) return { primary: '—' };\n const primary = formatCurrencyMajor(amount, currency);\n\n const { workspaceCurrency, exchangeRate } = options;\n if (exchangeRate != null && Number.isFinite(exchangeRate) && workspaceCurrency && workspaceCurrency !== currency) {\n const workspaceAmount = new Decimal(amountStr).times(exchangeRate).toNumber();\n if (Number.isFinite(workspaceAmount)) {\n return { primary, secondary: `(${formatCurrencyMajor(workspaceAmount, workspaceCurrency)})` };\n }\n }\n return { primary };\n};\n\nexport interface FormatDateOptions {\n locale?: Locale;\n}\n\nexport const formatDate = (value: string | null | undefined, options: FormatDateOptions = {}): FormattedValue => {\n if (value == null) return { primary: '—' };\n const parsed = DATE_ONLY_PATTERN.test(value) ? parseDateOnly(value) : parseISO(value);\n if (!isValid(parsed)) return { primary: '—' };\n // Render date-only values in UTC so the displayed day matches the stored YYYY-MM-DD.\n return { primary: formatWithTimeZone(parsed, 'P', 'UTC', options.locale) };\n};\n\nexport interface FormatDateTimeOptions {\n locale?: Locale;\n workspaceTimeZone?: string | null;\n timeZoneOverride?: string;\n}\n\nexport const formatDateTime = (\n value: string | null | undefined,\n options: FormatDateTimeOptions = {},\n): FormattedValue => {\n if (value == null) return { primary: '—' };\n const parsed = parseISO(value);\n if (!isValid(parsed)) return { primary: '—' };\n\n const primaryTz = options.timeZoneOverride ?? options.workspaceTimeZone ?? null;\n if (!primaryTz) {\n return { primary: format(parsed, 'Pp', options.locale ? { locale: options.locale } : undefined) };\n }\n const primary = `${formatWithTimeZone(parsed, 'Pp', primaryTz, options.locale)} (${primaryTz})`;\n const userTz = getUserTimeZone();\n if (!userTz || userTz === primaryTz) return { primary };\n return {\n primary,\n secondary: `Your time: ${formatWithT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CAAA,WAAA,EAAc,kBAAA,CAAmB,MAAA,EAAQ,IAAA,EAAM,QAAQ,OAAA,CAAQ,MAAM,CAAC,CAAA,EAAA,EAAK,MAAM,CAAA,CAAA;AAAA,GAC9F;AACF;;;;"}
@@ -1,5 +1,5 @@
1
- import '../index6.js';
2
- export { g as getUserTimeZone, a as getWorkspaceTimeZone, i as isoTodayDate, r as resolveTimeZone, s as setUserTimeZone, b as setWorkspaceTimeZone, w as workspaceTimeZone } from '../timezone.js';
3
1
  import '../index7.js';
2
+ export { g as getUserTimeZone, a as getWorkspaceTimeZone, i as isoTodayDate, r as resolveTimeZone, s as setUserTimeZone, b as setWorkspaceTimeZone, w as workspaceTimeZone } from '../timezone.js';
3
+ import '../index6.js';
4
4
  import '../format.js';
5
5
  //# sourceMappingURL=timezone.js.map
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
- "version": "0.6.5",
8
+ "version": "0.6.7",
9
9
  "type": "module",
10
10
  "sideEffects": false,
11
11
  "repository": {
@@ -152,6 +152,10 @@
152
152
  "types": "./dist/lib/components/CurrencyField/index.d.ts",
153
153
  "import": "./dist/components/CurrencyField.js"
154
154
  },
155
+ "./QuantityField": {
156
+ "types": "./dist/lib/components/QuantityField/index.d.ts",
157
+ "import": "./dist/components/QuantityField.js"
158
+ },
155
159
  "./Progress": {
156
160
  "types": "./dist/lib/components/Progress/index.d.ts",
157
161
  "import": "./dist/components/Progress.js"