@blocklet/labels 1.5.214 → 1.6.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,14 @@
1
+ /// <reference types="react" />
2
+ import { type BoxProps } from '@mui/material';
3
+ interface GithubLabelPickerProps {
4
+ value: string[];
5
+ onChange: (value: string[]) => void;
6
+ title?: string;
7
+ noLabelsText?: string;
8
+ buttonSx?: BoxProps['sx'];
9
+ actions?: React.ReactNode;
10
+ trigger?: React.ReactNode;
11
+ multiple?: boolean;
12
+ }
13
+ export declare function GithubLabelPicker({ value, onChange, title, noLabelsText, buttonSx, actions, trigger, multiple, }: GithubLabelPickerProps): import("react/jsx-runtime").JSX.Element | null;
14
+ export {};
@@ -1,16 +1,59 @@
1
1
  import { LabelTreeNode } from './tree';
2
- import { LabelsResponse } from '../types';
2
+ import type { CreateLabel, LabelPayload, LabelsResponse } from '../types';
3
3
  interface InitialState {
4
4
  loading: boolean;
5
5
  data?: LabelsResponse;
6
+ createLabel: CreateLabel;
6
7
  }
7
8
  export declare const LabelsContainer: import("unstated-next").Container<{
9
+ flattenedLabels: LabelTreeNode[];
8
10
  popularLabels: LabelTreeNode[];
9
11
  counts: Record<string, number>;
10
12
  getLabelsByIds: (ids: string[]) => LabelTreeNode[];
11
13
  getLabelName: (id: string) => string;
12
- getRelatedLabels: (id: string) => import("./tree").TreeNode<import("./tree").Label>[];
13
- getRecommended: (id: string) => import("./tree").TreeNode<import("./tree").Label>[];
14
+ getRelatedLabels: (id: string) => import("./tree").TreeNode<{
15
+ id: string;
16
+ name: string;
17
+ icon?: string | undefined;
18
+ color: string;
19
+ translation?: {
20
+ [locale: string]: string;
21
+ } | undefined;
22
+ _normalizeTranslation(translation: string | {
23
+ [locale: string]: string;
24
+ }): any;
25
+ getName(locale: string): string;
26
+ }>[];
27
+ getRecommended: (id: string) => import("./tree").TreeNode<{
28
+ id: string;
29
+ name: string;
30
+ icon?: string | undefined;
31
+ color: string;
32
+ translation?: {
33
+ [locale: string]: string;
34
+ } | undefined;
35
+ _normalizeTranslation(translation: string | {
36
+ [locale: string]: string;
37
+ }): any;
38
+ getName(locale: string): string;
39
+ }>[];
40
+ createLabel: (name: string) => Promise<{
41
+ id: string;
42
+ name: string;
43
+ icon?: string | undefined;
44
+ color: string;
45
+ translation?: {
46
+ [locale: string]: string;
47
+ } | undefined;
48
+ _normalizeTranslation(translation: string | {
49
+ [locale: string]: string;
50
+ }): any;
51
+ getName(locale: string): string;
52
+ }>;
53
+ addLabelNode: (payload: LabelPayload) => void;
54
+ updateLabelNode: (id: string, payload: LabelPayload) => void;
55
+ removeLabelNode: (id: string) => void;
56
+ getFullLabelName: (id: string) => string;
14
57
  loading: boolean;
15
58
  tree: LabelTreeNode;
16
59
  stats: {
@@ -0,0 +1,6 @@
1
+ interface LabelsInputProps {
2
+ value: string[];
3
+ onChange: (value: string[]) => void;
4
+ }
5
+ export declare function LabelsInput({ value, onChange, ...rest }: LabelsInputProps): import("react/jsx-runtime").JSX.Element | null;
6
+ export {};
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { type SxProps } from '@mui/material';
3
+ import { LabelTreeNode } from './tree';
4
+ interface LabelsProps {
5
+ labels: string[] | undefined | null;
6
+ sx?: SxProps;
7
+ renderLabel?: (label: LabelTreeNode) => JSX.Element;
8
+ }
9
+ export declare function Labels2({ labels, sx, renderLabel }: LabelsProps): import("react/jsx-runtime").JSX.Element | null;
10
+ export {};
@@ -1,3 +1,4 @@
1
+ import type { BaseLabel } from '../types';
1
2
  export declare class TreeNode<T> {
2
3
  data: T;
3
4
  parent?: TreeNode<T>;
@@ -7,14 +8,16 @@ export declare class TreeNode<T> {
7
8
  parent?: TreeNode<T>;
8
9
  children?: TreeNode<T>[];
9
10
  });
10
- setParent(node: TreeNode<T>): void;
11
+ setParent(node: TreeNode<T> | undefined): void;
11
12
  add(...nodes: TreeNode<T>[]): void;
13
+ removeChild(node: TreeNode<T>): void;
12
14
  isLeaf(node: TreeNode<T>): boolean;
13
15
  getAllParents(includeSelf?: boolean): TreeNode<T>[];
14
16
  getAllSiblings(): TreeNode<T>[];
15
17
  flatten(includeRoot?: boolean): TreeNode<T>[];
18
+ clone(): TreeNode<T>;
16
19
  }
17
- export declare class Label {
20
+ declare class Label {
18
21
  id: string;
19
22
  name: string;
20
23
  icon?: string;
@@ -22,13 +25,20 @@ export declare class Label {
22
25
  translation?: {
23
26
  [locale: string]: string;
24
27
  };
25
- constructor(data: any);
28
+ constructor(data: BaseLabel & {
29
+ translation?: any;
30
+ });
26
31
  _normalizeTranslation(translation: string | {
27
32
  [locale: string]: string;
28
33
  }): any;
29
34
  getName(locale: string): string;
30
35
  }
31
36
  export declare class LabelTreeNode extends TreeNode<Label> {
37
+ static Label: typeof Label;
38
+ getName(locale: string): string;
39
+ isSystemLabel(): boolean;
40
+ getFullName(locale?: string): string;
32
41
  }
33
42
  export declare const initLabelTree: (data: any[]) => LabelTreeNode;
34
43
  export declare const createEmptyLabelTree: () => LabelTreeNode;
44
+ export {};
package/dist/types.d.ts CHANGED
@@ -1,15 +1,30 @@
1
+ export interface BaseLabel {
2
+ id: string;
3
+ name: string;
4
+ icon?: string;
5
+ color?: string;
6
+ }
7
+ export interface LabelPayload extends BaseLabel {
8
+ translation?: string;
9
+ parentId?: string;
10
+ }
1
11
  export interface LabelsResponse {
2
- labels: {
3
- id: string;
4
- name: string;
5
- icon?: string;
6
- color: string;
7
- translation?: string;
8
- parentId?: string;
9
- }[];
12
+ labels: LabelPayload[];
10
13
  stats: {
11
14
  id: string;
12
15
  count: number;
13
16
  }[];
14
17
  }
15
18
  export type FetchLabels = () => Promise<LabelsResponse>;
19
+ export interface CreateOrUpdateLabelPayload extends Omit<BaseLabel, 'id'> {
20
+ id?: string;
21
+ parentId?: string;
22
+ translation?: {
23
+ [locale: string]: string;
24
+ };
25
+ }
26
+ export type CreateLabel = (payload: CreateOrUpdateLabelPayload) => Promise<LabelPayload>;
27
+ export type UpdateLabel = (payload: CreateOrUpdateLabelPayload & {
28
+ id: string;
29
+ }) => Promise<LabelPayload>;
30
+ export type DeleteLabel = (id: string) => Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/labels",
3
- "version": "1.5.214",
3
+ "version": "1.6.0",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -28,7 +28,7 @@
28
28
  "access": "public"
29
29
  },
30
30
  "dependencies": {
31
- "@blocklet/translation-input": "1.5.214",
31
+ "@blocklet/translation-input": "1.6.0",
32
32
  "@emotion/css": "^11.10.5",
33
33
  "@emotion/react": "^11.10.5",
34
34
  "@emotion/styled": "^11.10.5",
@@ -80,5 +80,5 @@
80
80
  "resolutions": {
81
81
  "react": "^18.2.0"
82
82
  },
83
- "gitHead": "d53fbe7504dc573ab634e3615af62d4294bdc453"
83
+ "gitHead": "35acd7ea5b0a170b74ab8f69b744f6833445fdec"
84
84
  }
@@ -1,8 +0,0 @@
1
- import { ComponentMeta } from '@storybook/react';
2
- import LabelManager from './label-manager';
3
- declare const _default: ComponentMeta<typeof LabelManager>;
4
- export default _default;
5
- export declare const Basic: {
6
- (): import("react/jsx-runtime").JSX.Element;
7
- storyName: string;
8
- };
@@ -1,5 +0,0 @@
1
- import { ComponentStory, ComponentMeta } from '@storybook/react';
2
- import LabelPicker from './label-picker';
3
- declare const _default: ComponentMeta<typeof LabelPicker>;
4
- export default _default;
5
- export declare const Basic: ComponentStory<typeof LabelPicker>;
@@ -1,8 +0,0 @@
1
- import { ComponentMeta } from '@storybook/react';
2
- import LabelTree from './label-tree';
3
- declare const _default: ComponentMeta<typeof LabelTree>;
4
- export default _default;
5
- export declare const Basic: {
6
- (): import("react/jsx-runtime").JSX.Element;
7
- storyName: string;
8
- };
@@ -1,9 +0,0 @@
1
- import { Label } from './types';
2
- interface LabelDeleteDialogProps {
3
- open: boolean;
4
- onClose: () => void;
5
- label: Label;
6
- onSubmit: () => void;
7
- }
8
- export default function LabelDeleteDialog({ open, label, onSubmit, onClose, ...rest }: LabelDeleteDialogProps): import("react/jsx-runtime").JSX.Element;
9
- export {};
@@ -1,9 +0,0 @@
1
- import type { Label } from './types';
2
- interface LabelFormDialogProps {
3
- open: boolean;
4
- onClose: () => void;
5
- initialLabel: Label | null;
6
- onSubmit: (payload: Label) => void;
7
- }
8
- export default function LabelFormDialog({ open, initialLabel, onSubmit, onClose, ...rest }: LabelFormDialogProps): import("react/jsx-runtime").JSX.Element;
9
- export {};
@@ -1,12 +0,0 @@
1
- import { Label, LabelDto } from './types';
2
- interface API {
3
- createLabel: (label: LabelDto) => Promise<void>;
4
- updateLabel: (label: LabelDto) => Promise<void>;
5
- deleteLabel: (id: string) => Promise<void>;
6
- }
7
- interface LabelManagerProps {
8
- data: Label[];
9
- api: API;
10
- }
11
- export default function LabelManager({ data, api, ...rest }: LabelManagerProps): import("react/jsx-runtime").JSX.Element;
12
- export {};