@iyulab/components 1.37.0 → 1.38.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/CHANGELOG.md +54 -0
- package/dist/components/UFloatingElement.d.ts +7 -3
- package/dist/components/UFloatingElement.js +1 -1
- package/dist/plugins/vite-plugin-react-wrapper.js +31 -11
- package/dist/react/UAlert.d.ts +3 -3
- package/dist/react/UAlert.js +1 -1
- package/dist/react/UAvatar.d.ts +1 -1
- package/dist/react/UAvatar.js +1 -1
- package/dist/react/UBadge.d.ts +1 -1
- package/dist/react/UBadge.js +1 -1
- package/dist/react/UBreadcrumb.d.ts +1 -1
- package/dist/react/UBreadcrumb.js +1 -1
- package/dist/react/UBreadcrumbItem.d.ts +2 -2
- package/dist/react/UBreadcrumbItem.js +1 -1
- package/dist/react/UButton.d.ts +1 -1
- package/dist/react/UButton.js +1 -1
- package/dist/react/UButtonGroup.d.ts +1 -1
- package/dist/react/UButtonGroup.js +1 -1
- package/dist/react/UCard.d.ts +1 -1
- package/dist/react/UCard.js +1 -1
- package/dist/react/UCarousel.d.ts +1 -1
- package/dist/react/UCarousel.js +1 -1
- package/dist/react/UCheckbox.d.ts +1 -1
- package/dist/react/UCheckbox.js +1 -1
- package/dist/react/UChip.d.ts +3 -3
- package/dist/react/UChip.js +1 -1
- package/dist/react/UCopyButton.d.ts +1 -1
- package/dist/react/UCopyButton.js +1 -1
- package/dist/react/UDatePicker.d.ts +1 -1
- package/dist/react/UDatePicker.js +1 -1
- package/dist/react/UDialog.d.ts +3 -3
- package/dist/react/UDialog.js +1 -1
- package/dist/react/UDivider.d.ts +1 -1
- package/dist/react/UDivider.js +1 -1
- package/dist/react/UDrawer.d.ts +3 -3
- package/dist/react/UDrawer.js +1 -1
- package/dist/react/UExpander.d.ts +3 -3
- package/dist/react/UExpander.js +1 -1
- package/dist/react/UField.d.ts +1 -1
- package/dist/react/UField.js +1 -1
- package/dist/react/UFileInput.d.ts +1 -1
- package/dist/react/UFileInput.js +1 -1
- package/dist/react/UForm.d.ts +1 -1
- package/dist/react/UForm.js +1 -1
- package/dist/react/UIcon.d.ts +1 -1
- package/dist/react/UIcon.js +1 -1
- package/dist/react/UIconButton.d.ts +1 -1
- package/dist/react/UIconButton.js +1 -1
- package/dist/react/UInput.d.ts +1 -1
- package/dist/react/UInput.js +1 -1
- package/dist/react/UMenu.d.ts +1 -1
- package/dist/react/UMenu.js +1 -1
- package/dist/react/UMenuItem.d.ts +2 -2
- package/dist/react/UMenuItem.js +1 -1
- package/dist/react/UOption.d.ts +1 -1
- package/dist/react/UOption.js +1 -1
- package/dist/react/UPanel.d.ts +1 -1
- package/dist/react/UPanel.js +1 -1
- package/dist/react/UPopover.d.ts +3 -3
- package/dist/react/UPopover.js +1 -1
- package/dist/react/UProgressBar.d.ts +1 -1
- package/dist/react/UProgressBar.js +1 -1
- package/dist/react/UProgressRing.d.ts +1 -1
- package/dist/react/UProgressRing.js +1 -1
- package/dist/react/URadio.d.ts +1 -1
- package/dist/react/URadio.js +1 -1
- package/dist/react/URating.d.ts +1 -1
- package/dist/react/URating.js +1 -1
- package/dist/react/USelect.d.ts +1 -1
- package/dist/react/USelect.js +1 -1
- package/dist/react/USkeleton.d.ts +1 -1
- package/dist/react/USkeleton.js +1 -1
- package/dist/react/USlider.d.ts +1 -1
- package/dist/react/USlider.js +1 -1
- package/dist/react/USpinner.d.ts +1 -1
- package/dist/react/USpinner.js +1 -1
- package/dist/react/USplitPanel.d.ts +2 -2
- package/dist/react/USplitPanel.js +1 -1
- package/dist/react/USwitch.d.ts +1 -1
- package/dist/react/USwitch.js +1 -1
- package/dist/react/UTab.d.ts +2 -2
- package/dist/react/UTab.js +1 -1
- package/dist/react/UTabPanel.d.ts +1 -1
- package/dist/react/UTabPanel.js +1 -1
- package/dist/react/UTag.d.ts +1 -1
- package/dist/react/UTag.js +1 -1
- package/dist/react/UText.d.ts +1 -1
- package/dist/react/UText.js +1 -1
- package/dist/react/UTextarea.d.ts +1 -1
- package/dist/react/UTextarea.js +1 -1
- package/dist/react/UTooltip.d.ts +3 -3
- package/dist/react/UTooltip.js +1 -1
- package/dist/react/UTree.d.ts +1 -1
- package/dist/react/UTree.js +1 -1
- package/dist/react/UTreeItem.d.ts +5 -5
- package/dist/react/UTreeItem.js +1 -1
- package/dist/utilities/Locale.d.ts +1 -1
- package/dist/utilities/Locale.js +13 -3
- package/dist/utilities/format.d.ts +7 -2
- package/dist/utilities/format.js +7 -2
- package/package.json +2 -1
- package/skills/iyulab-components/SKILL.md +1 -0
- package/skills/iyulab-components/references/components/popover.md +5 -1
- package/skills/iyulab-components/references/components/tooltip.md +5 -1
- package/skills/iyulab-components/references/utilities/browser-storage.md +5 -0
- package/skills/iyulab-components/references/utilities/elements.md +17 -0
- package/skills/iyulab-components/references/utilities/format.md +73 -0
- package/skills/iyulab-components/references/utilities/locale.md +5 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# format
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { formatNumber, formatCurrency, formatDate } from '@iyulab/components';
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Thin wrappers over `Intl.NumberFormat` / `Intl.DateTimeFormat` that default to the
|
|
8
|
+
library's active locale (`Locale.get()`), so numbers and dates rendered by your app match
|
|
9
|
+
the ones the components render themselves.
|
|
10
|
+
|
|
11
|
+
They add no formatting rules of their own — everything `Intl` accepts is passed straight
|
|
12
|
+
through. Reach for them instead of calling `Intl` directly when you want the active locale
|
|
13
|
+
applied without threading it through every call site.
|
|
14
|
+
|
|
15
|
+
## Functions
|
|
16
|
+
|
|
17
|
+
### `formatNumber(value, options?, locale?)`
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
formatNumber(1234.5); // active locale
|
|
21
|
+
formatNumber(0.42, { style: 'percent' }); // '42%'
|
|
22
|
+
formatNumber(1234.5, { maximumFractionDigits: 0 }, 'de-DE');
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`options` is `Intl.NumberFormatOptions`. `locale` overrides the active locale for this call
|
|
26
|
+
only.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
### `formatCurrency(value, currency, options?, locale?)`
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
formatCurrency(1234.5, 'USD'); // '$1,234.50' in an en locale
|
|
34
|
+
formatCurrency(1234.5, 'KRW');
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`currency` is **required and has no default** — which currency an amount is in is domain
|
|
38
|
+
knowledge this utility will not guess.
|
|
39
|
+
|
|
40
|
+
⚠ An invalid currency code throws `RangeError` rather than degrading (see the note under
|
|
41
|
+
`formatDate`). Pass a valid ISO 4217 code.
|
|
42
|
+
|
|
43
|
+
If `options` contains `currency` or `style`, those win over the `currency` argument.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
### `formatDate(value, options?, locale?)`
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
formatDate(new Date());
|
|
51
|
+
formatDate('2026-03-14', { dateStyle: 'long' });
|
|
52
|
+
formatDate(order.createdAt, { dateStyle: 'short', timeStyle: 'short' });
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Accepts a `Date` or an ISO `YYYY-MM-DD` string. **The string form is parsed as local time,
|
|
56
|
+
not UTC** — `'2026-03-14'` is midnight where the user is, so a date never shifts a day
|
|
57
|
+
across time zones the way `new Date('2026-03-14')` does.
|
|
58
|
+
|
|
59
|
+
A value that cannot be resolved to a real date — a malformed string, or an already-invalid
|
|
60
|
+
`Date` — returns `String(value)` instead of throwing. `Intl.DateTimeFormat.format()` throws
|
|
61
|
+
`RangeError` on an invalid date, and this runs inside render paths where an uncaught throw
|
|
62
|
+
blanks the whole component; showing the raw value is the lesser failure.
|
|
63
|
+
|
|
64
|
+
That degrade is **deliberately not symmetric** with `formatCurrency`: a date arrives as
|
|
65
|
+
data (an API, a user, a stale cache), so a bad one is an expected runtime state; a currency
|
|
66
|
+
code is written at the call site, so a bad one is a bug worth surfacing.
|
|
67
|
+
|
|
68
|
+
## Locale
|
|
69
|
+
|
|
70
|
+
All three read `Locale.get()` when `locale` is omitted, so they follow whatever
|
|
71
|
+
[`Locale`](./locale.md) resolved — `<html lang>` first, then the browser language. Pass
|
|
72
|
+
`locale` explicitly only when one value must be formatted differently from the rest of the
|
|
73
|
+
page (a currency shown in its home locale, for example).
|
|
@@ -10,7 +10,11 @@ Locale registry utility for library-generated validation messages.
|
|
|
10
10
|
|
|
11
11
|
Built in: `en`, `ko`, `ja`, `zh-CN`, `zh-TW`, `es`, `fr`, `de`, `pt-BR`, `vi`, `th`, `id`, `ru`, `ar`.
|
|
12
12
|
|
|
13
|
-
Initial locale is auto-detected from `
|
|
13
|
+
Initial locale is auto-detected from `document.documentElement.lang` first, then
|
|
14
|
+
`navigator.language`, with English fallback. `<html lang>` wins because it is the author's
|
|
15
|
+
declaration of the document's language and is what assistive technology uses to pick
|
|
16
|
+
pronunciation rules (WCAG 3.1.1 / 3.1.2); the browser language is the user-preference
|
|
17
|
+
fallback for when no such declaration exists. Call `Locale.set()` to override either.
|
|
14
18
|
|
|
15
19
|
## API
|
|
16
20
|
|