@croquiscom/pds 0.16.0 → 0.18.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.
@@ -0,0 +1,61 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { NotificationComponentProps } from '../notification';
3
+ import { ToastComponentProps } from '../toast';
4
+ export declare const MessagePosition: {
5
+ readonly TOP_RIGHT: "top-right";
6
+ readonly TOP_CENTER: "top-center";
7
+ readonly BOTTOM_RIGHT: "bottom-right";
8
+ readonly BOTTOM_CENTER: "bottom-center";
9
+ readonly CENTER: "center";
10
+ };
11
+ export declare type MessagePosition = typeof MessagePosition[keyof typeof MessagePosition];
12
+ export interface MessageContainerProps {
13
+ /**
14
+ * @desc 메세지 노출 위치
15
+ * @default top-center
16
+ */
17
+ position: MessagePosition;
18
+ /**
19
+ * @desc position 기준으로 커스텀 위치, center일 경우 적용되지 않습니다
20
+ */
21
+ offset_x: number;
22
+ /**
23
+ * @desc position 기준으로 커스텀 위치, center일 경우 적용되지 않습니다.
24
+ */
25
+ offset_y: number;
26
+ /**
27
+ * @desc 최대 노출 메세지 갯수
28
+ * @default 6
29
+ */
30
+ max_count?: number;
31
+ }
32
+ declare type MessageContainerKey = `${MessagePosition}_${number}_${number}`;
33
+ declare type MessageComponentTypes = ToastComponentProps | NotificationComponentProps;
34
+ export declare type MessageOptions<T extends MessageComponentTypes> = Omit<T, 'destroy' | 'position'> & Partial<MessageContainerProps>;
35
+ export declare class MessageManager<T extends MessageComponentTypes> {
36
+ private container;
37
+ private component;
38
+ private default_max_count;
39
+ private default_offset;
40
+ private default_position;
41
+ private container_keys;
42
+ private messages;
43
+ constructor({ component, container_id, default_max_count, default_offset, default_position, }: {
44
+ component: FunctionComponent<T>;
45
+ container_id: string;
46
+ default_max_count?: number;
47
+ default_offset?: number;
48
+ default_position?: MessagePosition;
49
+ });
50
+ static generateContainerKey({ position, offset_x, offset_y }: MessageContainerProps): MessageContainerKey;
51
+ static getContainerPropsByKey(key: MessageContainerKey): MessageContainerProps;
52
+ private generateMessageId;
53
+ private findContainerKeyById;
54
+ private addContainerKey;
55
+ private removeContainerKey;
56
+ private getOffset;
57
+ private render;
58
+ show({ id, position, offset_x, offset_y, max_count, ...options }: MessageOptions<T>): void;
59
+ destroy(id: string, key?: MessageContainerKey): void;
60
+ }
61
+ export {};
@@ -0,0 +1 @@
1
+ export * from './MessageManager';
@@ -0,0 +1,2 @@
1
+ import { MessageContainerProps } from './MessageManager';
2
+ export declare function getContainerStyle({ position, offset_x, offset_y }: MessageContainerProps): import("@emotion/utils").SerializedStyles;
@@ -0,0 +1,23 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { MessageManager, MessagePosition } from '../message';
3
+ export declare type NotificationType = 'info' | 'success' | 'error' | 'warning';
4
+ export interface NotificationComponentProps {
5
+ id?: string;
6
+ /** @default info */
7
+ type?: NotificationType;
8
+ title: string;
9
+ content: ReactNode;
10
+ confirmText?: string;
11
+ cancelText?: string;
12
+ linkText?: string;
13
+ /** @default false */
14
+ closeButton?: boolean;
15
+ onConfirm?: () => void;
16
+ onCancel?: () => void;
17
+ onClose?: () => void;
18
+ onClickLink?: () => void;
19
+ destroy: () => void;
20
+ position: MessagePosition;
21
+ }
22
+ export declare const NotificationComponent: React.FC<NotificationComponentProps>;
23
+ export declare const Notification: MessageManager<NotificationComponentProps>;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { ComponentStory, ComponentMeta } from '@storybook/react';
3
+ import { NotificationComponent, NotificationComponentProps } from './Notification';
4
+ declare const _default: ComponentMeta<React.FC<NotificationComponentProps>>;
5
+ export default _default;
6
+ export declare const Base: any;
7
+ export declare const Type: any;
8
+ export declare const HandleEvent: ComponentStory<typeof NotificationComponent>;
@@ -0,0 +1 @@
1
+ export * from './Notification';
@@ -0,0 +1,4 @@
1
+ import { NotificationType } from './Notification';
2
+ import { MessagePosition } from '../message';
3
+ export declare const notification_type_css: Record<NotificationType, string>;
4
+ export declare const notification_hide_animation: (position: MessagePosition) => import("@emotion/serialize").Keyframes;
@@ -6,7 +6,7 @@ interface RadioItem<RadioValue> {
6
6
  value: RadioValue;
7
7
  disabled?: boolean;
8
8
  }
9
- export interface RadioGroupProps<RadioValue> {
9
+ export interface RadioGroupProps<RadioValue> extends Omit<React.HTMLAttributes<HTMLDivElement>, 'defaultValue' | 'value' | 'onChange'> {
10
10
  className?: string;
11
11
  defaultValue?: RadioValue;
12
12
  value?: RadioValue;
@@ -1,4 +1,5 @@
1
1
  import React, { ReactNode } from 'react';
2
+ import { MessageManager } from '../message';
2
3
  export declare type ToastSize = 'large' | 'medium';
3
4
  export declare type ToastVariant = 'info' | 'success' | 'error';
4
5
  export interface ToastComponentProps {
@@ -21,3 +22,4 @@ export interface ToastComponentProps {
21
22
  destroy: () => void;
22
23
  }
23
24
  export declare const ToastComponent: React.FC<ToastComponentProps>;
25
+ export declare const Toast: MessageManager<ToastComponentProps>;
@@ -1,7 +1,9 @@
1
1
  import React from 'react';
2
- import { ComponentMeta } from '@storybook/react';
3
- declare const _default: ComponentMeta<React.FC<import("./Toast").ToastComponentProps>>;
2
+ import { ComponentMeta, ComponentStory } from '@storybook/react';
3
+ import { ToastComponent, ToastComponentProps } from './Toast';
4
+ declare const _default: ComponentMeta<React.FC<ToastComponentProps>>;
4
5
  export default _default;
5
6
  export declare const Base: any;
6
7
  export declare const Variant: any;
7
8
  export declare const Position: any;
9
+ export declare const HandleDestroy: ComponentStory<typeof ToastComponent>;
@@ -1 +1 @@
1
- export * from './ToastManager';
1
+ export * from './Toast';
@@ -1,6 +1,4 @@
1
1
  import { ToastSize } from './Toast';
2
- import { ToastContainerProps } from './ToastManager';
3
2
  export declare const toast_size_css: Record<ToastSize, string>;
4
3
  export declare const toast_show_animation: import("@emotion/serialize").Keyframes;
5
4
  export declare const toast_hide_animation: import("@emotion/serialize").Keyframes;
6
- export declare function getContainerStyle({ position, offset_x, offset_y }: ToastContainerProps): import("@emotion/utils").SerializedStyles;
@@ -0,0 +1,3 @@
1
+ export declare type Optional<T> = {
2
+ [K in keyof T]?: T[K];
3
+ };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export declare function composeEvent<T extends (...args: any[]) => void>(...funcs: (T | null | undefined)[]): T;
3
+ export declare function composeRef<T>(...refs: (React.Ref<T> | null | undefined)[]): React.RefCallback<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@croquiscom/pds",
3
- "version": "0.16.0",
3
+ "version": "0.18.0",
4
4
  "description": "Design system for Zigzag's Partner Center",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.es.js",
@@ -43,6 +43,7 @@
43
43
  "@rollup/plugin-commonjs": "^19.0.0",
44
44
  "@rollup/plugin-node-resolve": "^13.0.0",
45
45
  "@rollup/plugin-url": "^6.0.0",
46
+ "@storybook/addon-a11y": "^6.5.12",
46
47
  "@storybook/addon-actions": "^6.5.9",
47
48
  "@storybook/addon-docs": "^6.5.9",
48
49
  "@storybook/addon-essentials": "^6.5.9",
@@ -1,50 +0,0 @@
1
- import { ToastComponentProps } from './Toast';
2
- export declare const ToastPosition: {
3
- readonly TOP_RIGHT: "top-right";
4
- readonly TOP_CENTER: "top-center";
5
- readonly BOTTOM_RIGHT: "bottom-right";
6
- readonly BOTTOM_CENTER: "bottom-center";
7
- readonly CENTER: "center";
8
- };
9
- export declare type ToastPosition = typeof ToastPosition[keyof typeof ToastPosition];
10
- export interface ToastContainerProps {
11
- /**
12
- * @desc 토스트 노출 위치
13
- * @default top-center
14
- */
15
- position: ToastPosition;
16
- /**
17
- * @desc position 기준으로 커스텀 위치, center일 경우 적용되지 않습니다
18
- */
19
- offset_x: number;
20
- /**
21
- * @desc position 기준으로 커스텀 위치, center일 경우 적용되지 않습니다.
22
- */
23
- offset_y: number;
24
- /**
25
- * @desc 최대 노출 토스트 갯수
26
- * @default 6
27
- */
28
- max_count?: number;
29
- }
30
- export interface ToastOptions extends Omit<ToastComponentProps, 'destroy'>, Partial<ToastContainerProps> {
31
- }
32
- declare type ToastContainerKey = `${ToastPosition}_${number}_${number}`;
33
- declare class ToastManager {
34
- private container;
35
- private container_keys;
36
- private toasts;
37
- constructor();
38
- static generateContainerKey({ position, offset_x, offset_y }: ToastContainerProps): ToastContainerKey;
39
- static getContainerPropsByKey(key: ToastContainerKey): ToastContainerProps;
40
- private generateToastId;
41
- private findContainerKeyById;
42
- private addContainerKey;
43
- private removeContainerKey;
44
- private getOffset;
45
- private render;
46
- show({ id, position, offset_x, offset_y, max_count, ...options }: ToastOptions): void;
47
- destroy(id: string, key?: ToastContainerKey): void;
48
- }
49
- export declare const Toast: ToastManager;
50
- export {};