jfs-components 0.0.42 → 0.0.44
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/lib/commonjs/components/Button/Button.js +15 -1
- package/lib/commonjs/components/Checkbox/Checkbox.js +208 -0
- package/lib/commonjs/components/MoneyValue/MoneyValue.js +81 -49
- package/lib/commonjs/components/NoteInput/NoteInput.js +120 -0
- package/lib/commonjs/components/NoteInput/index.js +13 -0
- package/lib/commonjs/components/Numpad/Numpad.js +108 -0
- package/lib/commonjs/components/StatusHero/StatusHero.js +148 -0
- package/lib/commonjs/components/Tabs/TabItem.js +79 -0
- package/lib/commonjs/components/Tabs/Tabs.js +88 -0
- package/lib/commonjs/components/Toast/Toast.js +93 -0
- package/lib/commonjs/components/Toast/ToastProvider.js +61 -0
- package/lib/commonjs/components/Toast/useToast.js +61 -0
- package/lib/commonjs/components/index.js +81 -0
- package/lib/commonjs/design-tokens/JFS Variables-variables-full.json +1 -1
- package/lib/commonjs/icons/registry.js +1 -1
- package/lib/module/components/Button/Button.js +14 -1
- package/lib/module/components/Checkbox/Checkbox.js +205 -0
- package/lib/module/components/MoneyValue/MoneyValue.js +81 -49
- package/lib/module/components/NoteInput/NoteInput.js +115 -0
- package/lib/module/components/NoteInput/index.js +3 -0
- package/lib/module/components/Numpad/Numpad.js +103 -0
- package/lib/module/components/StatusHero/StatusHero.js +142 -0
- package/lib/module/components/Tabs/TabItem.js +74 -0
- package/lib/module/components/Tabs/Tabs.js +78 -0
- package/lib/module/components/Toast/Toast.js +88 -0
- package/lib/module/components/Toast/ToastProvider.js +55 -0
- package/lib/module/components/Toast/useToast.js +54 -0
- package/lib/module/components/index.js +10 -1
- package/lib/module/design-tokens/JFS Variables-variables-full.json +1 -1
- package/lib/module/icons/registry.js +1 -1
- package/lib/typescript/src/components/Button/Button.d.ts +6 -1
- package/lib/typescript/src/components/Checkbox/Checkbox.d.ts +30 -0
- package/lib/typescript/src/components/MoneyValue/MoneyValue.d.ts +18 -26
- package/lib/typescript/src/components/NoteInput/NoteInput.d.ts +23 -0
- package/lib/typescript/src/components/NoteInput/index.d.ts +3 -0
- package/lib/typescript/src/components/Numpad/Numpad.d.ts +35 -0
- package/lib/typescript/src/components/StatusHero/StatusHero.d.ts +47 -0
- package/lib/typescript/src/components/Tabs/TabItem.d.ts +29 -0
- package/lib/typescript/src/components/Tabs/Tabs.d.ts +44 -0
- package/lib/typescript/src/components/Toast/Toast.d.ts +14 -0
- package/lib/typescript/src/components/Toast/ToastProvider.d.ts +11 -0
- package/lib/typescript/src/components/Toast/useToast.d.ts +24 -0
- package/lib/typescript/src/components/index.d.ts +9 -0
- package/lib/typescript/src/icons/registry.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/Button/Button.tsx +14 -1
- package/src/components/Checkbox/Checkbox.tsx +238 -0
- package/src/components/MoneyValue/MoneyValue.tsx +134 -79
- package/src/components/NoteInput/NoteInput.tsx +146 -0
- package/src/components/NoteInput/index.ts +2 -0
- package/src/components/Numpad/Numpad.tsx +162 -0
- package/src/components/StatusHero/StatusHero.tsx +156 -0
- package/src/components/Tabs/TabItem.tsx +96 -0
- package/src/components/Tabs/Tabs.tsx +105 -0
- package/src/components/Toast/Toast.tsx +105 -0
- package/src/components/Toast/ToastProvider.tsx +75 -0
- package/src/components/Toast/useToast.ts +80 -0
- package/src/components/index.ts +9 -0
- package/src/design-tokens/JFS Variables-variables-full.json +1 -1
- package/src/icons/registry.ts +1 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { useCallback, useSyncExternalStore } from 'react'
|
|
2
|
+
|
|
3
|
+
export type ToastPlacement = 'top' | 'bottom'
|
|
4
|
+
|
|
5
|
+
export interface ToastOptions {
|
|
6
|
+
title: string
|
|
7
|
+
timeout?: number
|
|
8
|
+
onClose?: () => void
|
|
9
|
+
modes?: Record<string, any>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ToastEntry {
|
|
13
|
+
id: string
|
|
14
|
+
title: string
|
|
15
|
+
timeout: number
|
|
16
|
+
onClose?: (() => void) | undefined
|
|
17
|
+
modes?: Record<string, any> | undefined
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type Listener = () => void
|
|
21
|
+
|
|
22
|
+
let idCounter = 0
|
|
23
|
+
let toasts: ToastEntry[] = []
|
|
24
|
+
const listeners = new Set<Listener>()
|
|
25
|
+
|
|
26
|
+
function emit() {
|
|
27
|
+
for (const listener of listeners) {
|
|
28
|
+
listener()
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function getSnapshot(): ToastEntry[] {
|
|
33
|
+
return toasts
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function subscribe(listener: Listener): () => void {
|
|
37
|
+
listeners.add(listener)
|
|
38
|
+
return () => {
|
|
39
|
+
listeners.delete(listener)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function addToast(options: ToastOptions): string {
|
|
44
|
+
const id = `toast-${++idCounter}`
|
|
45
|
+
const entry: ToastEntry = {
|
|
46
|
+
id,
|
|
47
|
+
title: options.title,
|
|
48
|
+
timeout: options.timeout ?? 4000,
|
|
49
|
+
onClose: options.onClose,
|
|
50
|
+
modes: options.modes,
|
|
51
|
+
}
|
|
52
|
+
toasts = [...toasts, entry]
|
|
53
|
+
emit()
|
|
54
|
+
return id
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function closeToast(id: string): void {
|
|
58
|
+
const entry = toasts.find((t) => t.id === id)
|
|
59
|
+
toasts = toasts.filter((t) => t.id !== id)
|
|
60
|
+
emit()
|
|
61
|
+
entry?.onClose?.()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function closeAll(): void {
|
|
65
|
+
const prev = toasts
|
|
66
|
+
toasts = []
|
|
67
|
+
emit()
|
|
68
|
+
prev.forEach((t) => t.onClose?.())
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function useToast() {
|
|
72
|
+
const queue = useSyncExternalStore(subscribe, getSnapshot, getSnapshot)
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
toasts: queue,
|
|
76
|
+
addToast: useCallback(addToast, []),
|
|
77
|
+
closeToast: useCallback(closeToast, []),
|
|
78
|
+
closeAll: useCallback(closeAll, []),
|
|
79
|
+
}
|
|
80
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ export { default as BottomNav } from './BottomNav/BottomNav';
|
|
|
7
7
|
export { default as BottomNavItem } from './BottomNavItem/BottomNavItem';
|
|
8
8
|
export { default as Button, type ButtonProps } from './Button/Button';
|
|
9
9
|
export { default as Card } from './Card/Card';
|
|
10
|
+
export { default as Checkbox, type CheckboxProps } from './Checkbox/Checkbox';
|
|
10
11
|
export { default as CardFeedback } from './CardFeedback/CardFeedback';
|
|
11
12
|
export { default as Disclaimer } from './Disclaimer/Disclaimer';
|
|
12
13
|
export { default as Divider, type DividerProps, type DividerDirection } from './Divider/Divider';
|
|
@@ -25,7 +26,9 @@ export { default as ListItem } from './ListItem/ListItem';
|
|
|
25
26
|
export { default as MediaCard } from './MediaCard/MediaCard';
|
|
26
27
|
export { default as MerchantProfile, type MerchantProfileProps } from './MerchantProfile/MerchantProfile';
|
|
27
28
|
export { default as MoneyValue } from './MoneyValue/MoneyValue';
|
|
29
|
+
export { default as NoteInput } from './NoteInput/NoteInput';
|
|
28
30
|
export { default as NavArrow } from './NavArrow/NavArrow';
|
|
31
|
+
export { default as Numpad, type NumpadProps, type NumpadKeyValue } from './Numpad/Numpad';
|
|
29
32
|
export { default as PageTitle } from './PageTitle/PageTitle';
|
|
30
33
|
export { default as Screen, type ScreenProps } from './Screen/Screen';
|
|
31
34
|
export { default as Section } from './Section/Section';
|
|
@@ -33,6 +36,7 @@ export { default as Stepper } from './Stepper/Stepper';
|
|
|
33
36
|
export { Step } from './Stepper/Step';
|
|
34
37
|
export { StepLabel } from './Stepper/StepLabel';
|
|
35
38
|
export { default as TextInput } from './TextInput/TextInput';
|
|
39
|
+
export { default as StatusHero, type StatusHeroProps } from './StatusHero/StatusHero';
|
|
36
40
|
export { default as ThreadHero, type ThreadHeroProps } from './ThreadHero/ThreadHero';
|
|
37
41
|
export { Tooltip } from './Tooltip/Tooltip';
|
|
38
42
|
|
|
@@ -51,3 +55,8 @@ export { default as InputSearch, type InputSearchProps } from './InputSearch/Inp
|
|
|
51
55
|
export { default as SupportText, type SupportTextProps } from './SupportText/SupportText';
|
|
52
56
|
export { default as SupportTextIcon, type SupportTextIconProps } from './SupportText/SupportTextIcon';
|
|
53
57
|
export { default as RadioButton, type RadioButtonProps } from './RadioButton/RadioButton';
|
|
58
|
+
export { default as Tabs, type TabsProps } from './Tabs/Tabs';
|
|
59
|
+
export { default as TabItem, type TabItemProps } from './Tabs/TabItem';
|
|
60
|
+
export { default as Toast, type ToastProps } from './Toast/Toast';
|
|
61
|
+
export { default as ToastProvider, type ToastProviderProps } from './Toast/ToastProvider';
|
|
62
|
+
export { useToast, addToast, closeToast, closeAll, type ToastOptions, type ToastEntry, type ToastPlacement } from './Toast/useToast';
|