@devslab/dds-solid 0.29.1 → 0.30.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/README.ko.md CHANGED
@@ -26,6 +26,48 @@ DDS가 공개 API와 시각 토큰을 소유한다. 기존 import와 콜백 값
26
26
  포인터·포커스 상호작용 중과 브라우저 페이지가 비활성일 때는 알림 타이머가
27
27
  멈춘다. duration이 0 이하이면 명시적으로 닫을 때까지 유지한다.
28
28
 
29
+ ## 비동기 Toast와 액션
30
+
31
+ `ToastProvider` 안의 `useToast()`는 `show`, `loading`, `update`, `promise`,
32
+ `dismiss`, `clear`를 반환한다. ID와 수명 상태는 provider마다 독립적이다.
33
+ `loading` tone은 수정하거나 닫을 때까지 유지한다. 스피너는 장식이므로 진행
34
+ 내용을 설명하는 메시지를 전달한다.
35
+
36
+ ```tsx
37
+ const toast = useToast();
38
+ const id = toast.loading({ message: "변경 사항 저장 중" });
39
+ toast.update(id, { message: "변경 사항 저장됨", tone: "success" });
40
+
41
+ const task = toast.promise(() => saveChanges(), {
42
+ loading: { message: "변경 사항 저장 중" },
43
+ success: { message: "변경 사항 저장됨" },
44
+ error: { message: "변경 사항을 저장하지 못했습니다" },
45
+ });
46
+ // 같은 ID를 즉시 사용할 수 있고, await는 원래 작업의 결과·오류를 전달한다.
47
+ const saved = await task;
48
+
49
+ toast.show({
50
+ message: "변경 사항 저장됨",
51
+ action: { label: "변경 사항 보기", onClick: () => openChanges(saved) },
52
+ });
53
+ ```
54
+
55
+ `update(id, patch)`는 생략한 필드를 유지하고 기존 알림을 수정한다. 선택적
56
+ 필드에 명시적으로 `undefined`를 전달하면 기본값으로 되돌리고, `action: null`은
57
+ 액션을 제거한다. 없거나 만료·닫힌 ID는 무시한다. 액션은 네이티브 버튼이며
58
+ 알림을 먼저 닫고 콜백을 한 번 실행한다. 주변 폼은 제출하지 않는다.
59
+
60
+ `promise`는 Promise 또는 한 번 실행할 함수를 받으며 동기 예외도 rejection으로
61
+ 전달한다. `success`와 `error`는 입력 객체나 결과·원래 오류를 받는 동기 함수다.
62
+ 완료 입력은 loading 입력에 병합하며 완료 tone의 기본값은 success/danger이고,
63
+ loading 이후에는 provider의 일반 유지 시간을 사용한다.
64
+ 반환형은 `Promise<T> & { readonly id: string }`이다. 다른 Promise와 동일하게
65
+ rejection을 처리한다. dismiss·clear·닫기·액션 실행·수동 update·provider 해제는
66
+ 대기 중인 알림 갱신을 무효화한다. 원래 작업 결과는 호출자에게 전달되지만 완료
67
+ 메시지 함수는 호출하지 않고 알림도 다시 만들지 않는다. 완료 메시지 함수에서
68
+ 예외가 발생하면 현재 알림을 닫고 원래 작업의 결과·오류를 보존한다. 액션과
69
+ Promise는 재시도·취소·업무 성공 판정을 추가하지 않는다.
70
+
29
71
  ## Button loading
30
72
 
31
73
  `loading`은 버튼의 크기와 접근 가능한 이름을 바꾸지 않는다. 라벨은 지우지 않고 숨기며
package/README.md CHANGED
@@ -25,6 +25,51 @@ same. See [the migration guide](../../docs/ark-migration.md) for integration det
25
25
  pointer/focus interaction and when the browser page is idle. A non-positive duration
26
26
  keeps the toast until dismissed.
27
27
 
28
+ ## Async Toast and actions
29
+
30
+ Inside `ToastProvider`, `useToast()` returns `show`, `loading`, `update`,
31
+ `promise`, `dismiss` and `clear`. All IDs and lifecycle state belong to that
32
+ provider. A `loading` tone persists until it is updated or dismissed; its spinner
33
+ is decorative, so supply a message that describes the work.
34
+
35
+ ```tsx
36
+ const toast = useToast();
37
+ const id = toast.loading({ message: "Saving changes" });
38
+ toast.update(id, { message: "Changes saved", tone: "success" });
39
+
40
+ const task = toast.promise(() => saveChanges(), {
41
+ loading: { message: "Saving changes" },
42
+ success: { message: "Changes saved" },
43
+ error: { message: "Could not save changes" },
44
+ });
45
+ // The same ID is available immediately; awaiting preserves the operation's result/error.
46
+ const saved = await task;
47
+
48
+ toast.show({
49
+ message: "Changes saved",
50
+ action: { label: "View changes", onClick: () => openChanges(saved) },
51
+ });
52
+ ```
53
+
54
+ `update(id, patch)` keeps omitted fields and changes the toast in place. An
55
+ explicit `undefined` resets an optional field to its default; `action: null`
56
+ removes the action. Unknown, expired and dismissed IDs are ignored. An action is
57
+ a native button: it dismisses the toast before invoking its callback once and
58
+ does not submit a surrounding form.
59
+
60
+ `promise` accepts a promise or a once-only factory, including synchronous throws.
61
+ Its `success` and `error` inputs can also be synchronous functions receiving the
62
+ result or original error. It merges terminal input into the loading input,
63
+ defaults terminal tones to success/danger, and uses the provider's normal
64
+ duration after loading. It returns `Promise<T> & { readonly id: string }`.
65
+ Handle rejected operations as you would any other promise. Dismissing, clearing,
66
+ closing, activating an action, manually updating or disposing the provider
67
+ supersedes the pending notification; settlement still reaches the caller but
68
+ does not run its terminal message factory or recreate the notification. If a
69
+ terminal message factory throws, the current notification is dismissed and the
70
+ original operation outcome is preserved. Actions and promises introduce no
71
+ retry, cancellation or inference of business success.
72
+
28
73
  ## Button loading
29
74
 
30
75
  `loading` keeps the button's size and accessible name: the label is hidden, not removed, and the
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@ export { createPendingAction, type PendingAction, type PendingActionRunOptions }
8
8
  export { createStatusPill } from "./status-pill";
9
9
  export type { StatusTone } from "./status-pill";
10
10
  export { Tab, TabList, TabPanel, Tabs, type TabPanelProps, type TabProps, type TabsProps } from "./tabs";
11
- export { ToastProvider, useToast, type ToastApi, type ToastInput, type ToastProviderProps, type ToastTone } from "./toast";
11
+ export { ToastProvider, useToast, type ToastAction, type ToastApi, type ToastInput, type ToastLoadingInput, type ToastPromise, type ToastPromiseOptions, type ToastProviderProps, type ToastRecord, type ToastTone, type ToastUpdate } from "./toast";
12
12
  export { Tooltip, type TooltipProps, type TooltipTriggerProps } from "./tooltip";
13
13
  export { DatePicker, type DatePickerProps } from "./date-picker";
14
14
  export { TimePicker, type TimePickerProps, type TimeMessages } from "./time-picker";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mapp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