stp-ui-kit 0.1.0 → 2.0.1
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.md +40 -200
- package/dist/src/components/form/index.d.ts +0 -1
- package/dist/src/components/layout/index.d.ts +0 -1
- package/dist/src/components/navigation/index.d.ts +0 -1
- package/dist/src/global.d.ts +4 -0
- package/dist/stp-ui-kit.es.js +1966 -2223
- package/dist/stp-ui-kit.es.js.map +1 -1
- package/dist/style.css +1 -1
- package/docs/components/README.md +0 -3
- package/docs/components/form/Calendar.md +0 -1
- package/docs/components/form/Checkbox.md +0 -1
- package/docs/components/form/InlineError.md +0 -1
- package/docs/components/form/Input.md +0 -1
- package/docs/components/form/RadioButton.md +0 -1
- package/docs/components/form/Select.md +0 -1
- package/docs/components/form/TextArea.md +0 -1
- package/docs/components/navigation/Collapse.md +0 -1
- package/docs/components/navigation/NavigationItem.md +1 -2
- package/package.json +10 -4
- package/src/global.d.ts +4 -0
- package/styles/_variables.scss +1 -0
- package/styles/main.scss +1 -0
- package/dist/src/components/form/FormItem/FormItem.d.ts +0 -21
- package/dist/src/components/form/FormItem/FormItemContext.d.ts +0 -6
- package/dist/src/components/layout/Banner/Banner.d.ts +0 -11
- package/dist/src/components/layout/Banner/Banner.stories.d.ts +0 -6
- package/dist/src/components/layout/Banner/utils/utils.d.ts +0 -1
- package/dist/src/components/navigation/CourseCollapse/CourseCollapse.d.ts +0 -14
- package/docs/components/form/FormItem.md +0 -216
- package/docs/components/navigation/CourseCollapse.md +0 -103
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { default as React, PropsWithChildren, ReactNode } from 'react';
|
|
2
|
-
interface FormItemProps {
|
|
3
|
-
children: ReactNode;
|
|
4
|
-
error?: boolean;
|
|
5
|
-
disabled?: boolean;
|
|
6
|
-
readOnly?: boolean;
|
|
7
|
-
}
|
|
8
|
-
declare const FormItem: {
|
|
9
|
-
({ children, error, disabled, readOnly }: FormItemProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
Label: ({ children, required }: LabelProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLElement>>;
|
|
12
|
-
Message: ({ children }: PropsWithChildren) => import("react/jsx-runtime").JSX.Element | null;
|
|
13
|
-
};
|
|
14
|
-
interface LabelProps extends PropsWithChildren {
|
|
15
|
-
required?: boolean;
|
|
16
|
-
}
|
|
17
|
-
interface InputProps extends React.ComponentPropsWithoutRef<"input"> {
|
|
18
|
-
as?: React.ElementType;
|
|
19
|
-
className?: string;
|
|
20
|
-
}
|
|
21
|
-
export { FormItem };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export type FormItemState = "default" | "error" | "disabled" | "readOnly";
|
|
2
|
-
export interface FormItemContextValue {
|
|
3
|
-
state: FormItemState;
|
|
4
|
-
}
|
|
5
|
-
export declare const FormItemContext: import('react').Context<FormItemContextValue>;
|
|
6
|
-
export declare const useFormItem: () => FormItemContextValue;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
interface BannerProps {
|
|
2
|
-
color: string;
|
|
3
|
-
title: string;
|
|
4
|
-
bgPattern: string;
|
|
5
|
-
bgPatternFinished?: string;
|
|
6
|
-
buttonColor: string;
|
|
7
|
-
deadline: string;
|
|
8
|
-
onClick: () => void;
|
|
9
|
-
}
|
|
10
|
-
export declare const Banner: ({ color, title, bgPattern, deadline, bgPatternFinished, buttonColor, onClick, }: BannerProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const formatDeadline: (date: string | Date) => string;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface CourseNavItem {
|
|
2
|
-
id: string;
|
|
3
|
-
name: string;
|
|
4
|
-
icon?: React.ReactNode;
|
|
5
|
-
completed?: boolean;
|
|
6
|
-
children?: CourseNavItem[];
|
|
7
|
-
disabled?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export interface CourseCollapseProps {
|
|
10
|
-
activeItemId: string;
|
|
11
|
-
onChange: (item: CourseNavItem) => void;
|
|
12
|
-
item: CourseNavItem;
|
|
13
|
-
}
|
|
14
|
-
export declare const CourseCollapse: ({ activeItemId, onChange, item, }: CourseCollapseProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
# FormItem
|
|
2
|
-
|
|
3
|
-
> Category: Form
|
|
4
|
-
|
|
5
|
-
> ⚠️ **DEPRECATED** - This component is deprecated and should not be used in new code. Use individual form components (Input, Select, Checkbox, etc.) which include built-in label, error, and helper text support.
|
|
6
|
-
|
|
7
|
-
[Figma Design](<!-- FormItem is deprecated, no Figma link available -->)
|
|
8
|
-
|
|
9
|
-
## Description
|
|
10
|
-
|
|
11
|
-
FormItem is a compound component pattern that provides a wrapper for form fields with shared state management via Context API. It consists of four sub-components: `FormItem` (root), `FormItem.Label`, `FormItem.Input`, and `FormItem.Message`. The component manages form state (default, error, disabled, readOnly) and propagates it to child components automatically.
|
|
12
|
-
|
|
13
|
-
**Deprecation Notice:** This component has been superseded by standalone form components (Input, Select, Checkbox, RadioButton, TextArea) which provide label, error, and helper text props directly without needing a wrapper component.
|
|
14
|
-
|
|
15
|
-
## Import
|
|
16
|
-
|
|
17
|
-
```tsx
|
|
18
|
-
import { FormItem } from "stp-ui-kit";
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Props
|
|
22
|
-
|
|
23
|
-
### FormItem (Root Component)
|
|
24
|
-
|
|
25
|
-
| Prop | Type | Default | Required | Description |
|
|
26
|
-
| -------- | ----------- | ----------- | -------- | -------------------------------------------------- |
|
|
27
|
-
| children | `ReactNode` | - | Yes | Child components (Label, Input, Message) |
|
|
28
|
-
| error | `boolean` | `false` | No | When `true`, sets error state for child components |
|
|
29
|
-
| disabled | `boolean` | `false` | No | When `true`, disables the input |
|
|
30
|
-
| readOnly | `boolean` | `false` | No | When `true`, makes the input read-only |
|
|
31
|
-
|
|
32
|
-
### FormItem.Label
|
|
33
|
-
|
|
34
|
-
| Prop | Type | Default | Required | Description |
|
|
35
|
-
| -------- | ----------- | ------- | -------- | -------------------------------------- |
|
|
36
|
-
| children | `ReactNode` | - | Yes | Label text content |
|
|
37
|
-
| required | `boolean` | `false` | No | When `true`, shows red asterisk (\*) |
|
|
38
|
-
|
|
39
|
-
### FormItem.Input
|
|
40
|
-
|
|
41
|
-
Extends `React.ComponentPropsWithoutRef<"input">` and forwards ref to the underlying element.
|
|
42
|
-
|
|
43
|
-
| Prop | Type | Default | Required | Description |
|
|
44
|
-
| --------- | ------------------- | --------- | -------- | -------------------------------------------------------------- |
|
|
45
|
-
| as | `React.ElementType` | `"input"` | No | Render as a different element (e.g., `"textarea"`, `"select"`) |
|
|
46
|
-
| className | `string` | - | No | Additional CSS class names |
|
|
47
|
-
| ...props | `InputHTMLAttributes` | - | No | All standard input attributes |
|
|
48
|
-
|
|
49
|
-
### FormItem.Message
|
|
50
|
-
|
|
51
|
-
| Prop | Type | Default | Required | Description |
|
|
52
|
-
| -------- | ----------- | ------- | -------- | ------------------------------------------- |
|
|
53
|
-
| children | `ReactNode` | - | No | Message text (error or helper text) |
|
|
54
|
-
|
|
55
|
-
## Variants
|
|
56
|
-
|
|
57
|
-
The component has four internal states managed via Context:
|
|
58
|
-
|
|
59
|
-
- **default**: Normal state with no special styling
|
|
60
|
-
- **error**: Red border on input, red error icon and text in message
|
|
61
|
-
- **disabled**: Grayed out, input disabled
|
|
62
|
-
- **readOnly**: Read-only styling, input cannot be modified
|
|
63
|
-
|
|
64
|
-
## Code Examples
|
|
65
|
-
|
|
66
|
-
### Basic form field
|
|
67
|
-
|
|
68
|
-
```tsx
|
|
69
|
-
<FormItem>
|
|
70
|
-
<FormItem.Label>Email</FormItem.Label>
|
|
71
|
-
<FormItem.Input type='email' placeholder='Enter your email' />
|
|
72
|
-
</FormItem>
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### Required field with error
|
|
76
|
-
|
|
77
|
-
```tsx
|
|
78
|
-
<FormItem error={!!errors.username}>
|
|
79
|
-
<FormItem.Label required>Username</FormItem.Label>
|
|
80
|
-
<FormItem.Input
|
|
81
|
-
type='text'
|
|
82
|
-
value={username}
|
|
83
|
-
onChange={(e) => setUsername(e.target.value)}
|
|
84
|
-
/>
|
|
85
|
-
<FormItem.Message>{errors.username || "Choose a unique username"}</FormItem.Message>
|
|
86
|
-
</FormItem>
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### Disabled field
|
|
90
|
-
|
|
91
|
-
```tsx
|
|
92
|
-
<FormItem disabled>
|
|
93
|
-
<FormItem.Label>Account Type</FormItem.Label>
|
|
94
|
-
<FormItem.Input value='Premium' readOnly />
|
|
95
|
-
<FormItem.Message>Contact support to change your account type</FormItem.Message>
|
|
96
|
-
</FormItem>
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
### Using `as` prop for textarea
|
|
100
|
-
|
|
101
|
-
```tsx
|
|
102
|
-
<FormItem>
|
|
103
|
-
<FormItem.Label>Description</FormItem.Label>
|
|
104
|
-
<FormItem.Input
|
|
105
|
-
as='textarea'
|
|
106
|
-
rows={4}
|
|
107
|
-
placeholder='Enter description...'
|
|
108
|
-
/>
|
|
109
|
-
</FormItem>
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
## Figma Property Mapping
|
|
113
|
-
|
|
114
|
-
When implementing from Figma designs, map the component properties as follows:
|
|
115
|
-
|
|
116
|
-
| Figma Property | Component Prop | Value Mapping | Notes |
|
|
117
|
-
|----------------|----------------|---------------|-------|
|
|
118
|
-
| **Label** text | `FormItem.Label` | Text → `<FormItem.Label>Text</FormItem.Label>` | Label content |
|
|
119
|
-
| **Required** boolean | `required` | `true` → `<FormItem.Label required>` | Required indicator (*) |
|
|
120
|
-
| **Error** boolean | `error` | `true` → `<FormItem error={true}>` | Error state |
|
|
121
|
-
| **Disabled** boolean | `disabled` | `true` → `<FormItem disabled={true}>` | Disabled state |
|
|
122
|
-
| **Read Only** boolean | `readOnly` | `true` → `<FormItem readOnly={true}>` | Read-only state |
|
|
123
|
-
| **Message** text | `FormItem.Message` | Text → `<FormItem.Message>Text</FormItem.Message>` | Helper/error text |
|
|
124
|
-
| **Input Type** | `type` | Text → `<FormItem.Input type="text" />` | Input type |
|
|
125
|
-
| *(Not in Figma)* | `as` | N/A | Render as different element |
|
|
126
|
-
| *(Not in Figma)* | `value/onChange` | N/A | Controlled input props |
|
|
127
|
-
|
|
128
|
-
### Example Figma → Code
|
|
129
|
-
|
|
130
|
-
**Figma settings:** Label="Email", Required=true, Error=false, Message="We'll never share your email"
|
|
131
|
-
|
|
132
|
-
```tsx
|
|
133
|
-
<FormItem>
|
|
134
|
-
<FormItem.Label required>Email</FormItem.Label>
|
|
135
|
-
<FormItem.Input
|
|
136
|
-
type="email"
|
|
137
|
-
value={email}
|
|
138
|
-
onChange={(e) => setEmail(e.target.value)}
|
|
139
|
-
/>
|
|
140
|
-
<FormItem.Message>We'll never share your email</FormItem.Message>
|
|
141
|
-
</FormItem>
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
**Migration to modern components:**
|
|
145
|
-
|
|
146
|
-
```tsx
|
|
147
|
-
// ❌ Deprecated: Using FormItem
|
|
148
|
-
<FormItem error={!!errors.email}>
|
|
149
|
-
<FormItem.Label required>Email</FormItem.Label>
|
|
150
|
-
<FormItem.Input type="email" value={email} onChange={handleChange} />
|
|
151
|
-
<FormItem.Message>{errors.email}</FormItem.Message>
|
|
152
|
-
</FormItem>
|
|
153
|
-
|
|
154
|
-
// ✅ Recommended: Using Input component
|
|
155
|
-
<Input
|
|
156
|
-
label="Email"
|
|
157
|
-
type="email"
|
|
158
|
-
required
|
|
159
|
-
value={email}
|
|
160
|
-
onChange={handleChange}
|
|
161
|
-
error={errors.email}
|
|
162
|
-
/>
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
## Design Tokens
|
|
166
|
-
|
|
167
|
-
| Element | Token | Value | Usage |
|
|
168
|
-
|---------|-------|-------|-------|
|
|
169
|
-
| **FormItem Container** | | | |
|
|
170
|
-
| Display | `flex` | - | Vertical layout |
|
|
171
|
-
| Flex Direction | `column` | - | Stacked children |
|
|
172
|
-
| Gap | `$spacing-100` | `4px` | Space between label/input/message |
|
|
173
|
-
| **Label** | | | |
|
|
174
|
-
| Color | `$text-primary-default` | `#000000` | Label text |
|
|
175
|
-
| Font Size | `$font-size-sm` | `14px` | Label size |
|
|
176
|
-
| Font Weight | `$font-weight-medium` | `500` | Medium weight |
|
|
177
|
-
| Margin Bottom | `$spacing-100` | `4px` | Space below label |
|
|
178
|
-
| Disabled Color | `$text-disabled` | `#D1D5DB` | Disabled label |
|
|
179
|
-
| Read-only Color | `$text-secondary-default` | `#6B7280` | Read-only label |
|
|
180
|
-
| **Required Mark** | | | |
|
|
181
|
-
| Color | `$text-critical-default` | `#DC2626` | Red asterisk |
|
|
182
|
-
| Margin Left | `$spacing-50` | `2px` | Space before asterisk |
|
|
183
|
-
| **Input** | | | |
|
|
184
|
-
| Background | `$fill-surface-default` | `#FFFFFF` | Input background |
|
|
185
|
-
| Border | `$border-primary-default` | `#E0E0E0` | Default border |
|
|
186
|
-
| Border Radius | `$border-radius-md` | `8px` | Input corners |
|
|
187
|
-
| Padding | `$spacing-200 $spacing-300` | `8px 12px` | Input padding |
|
|
188
|
-
| Font Size | `$font-size-md` | `16px` | Input text size |
|
|
189
|
-
| Color | `$text-primary-default` | `#000000` | Input text |
|
|
190
|
-
| **Input States** | | | |
|
|
191
|
-
| Focus Border | `$border-focus` | `#0066CC` | Focused state |
|
|
192
|
-
| Error Border | `$border-critical-default` | `#DC2626` | Error state |
|
|
193
|
-
| Disabled Background | `$fill-disabled` | `#F9FAFB` | Disabled input |
|
|
194
|
-
| Disabled Text | `$text-disabled` | `#D1D5DB` | Disabled text |
|
|
195
|
-
| Read-only Background | `$fill-secondary-default` | `#F3F4F6` | Read-only background |
|
|
196
|
-
| **Message** | | | |
|
|
197
|
-
| Color (default) | `$text-secondary-default` | `#6B7280` | Helper text |
|
|
198
|
-
| Color (error) | `$text-critical-default` | `#DC2626` | Error message |
|
|
199
|
-
| Font Size | `$font-size-xs` | `12px` | Message size |
|
|
200
|
-
| Gap | `$spacing-100` | `4px` | Space between icon and text |
|
|
201
|
-
| **Error Icon** | | | |
|
|
202
|
-
| Color | `$icon-critical` | `#DC2626` | Error icon |
|
|
203
|
-
| Size | `16px` | - | Icon dimensions |
|
|
204
|
-
|
|
205
|
-
## Related Components
|
|
206
|
-
|
|
207
|
-
- **Input** -- Modern replacement for text inputs with built-in label, error, and helper text.
|
|
208
|
-
- **TextArea** -- Modern replacement for multi-line text inputs.
|
|
209
|
-
- **Checkbox** -- Modern replacement for checkbox inputs.
|
|
210
|
-
- **RadioButton** -- Modern replacement for radio inputs.
|
|
211
|
-
- **Select** -- Modern replacement for select dropdowns.
|
|
212
|
-
- **InlineError** -- Error message component used by modern form components.
|
|
213
|
-
|
|
214
|
-
## Source
|
|
215
|
-
|
|
216
|
-
`src/components/form/FormItem/FormItem.tsx`
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
# CourseCollapse
|
|
2
|
-
|
|
3
|
-
> Category: Navigation
|
|
4
|
-
|
|
5
|
-
[Figma Design](<!-- Figma URL -->)
|
|
6
|
-
|
|
7
|
-
## Description
|
|
8
|
-
|
|
9
|
-
A specialized collapsible navigation component designed for course content navigation. It extends the behavior of `Collapse` with additional support for completion and disabled states on child items. Each child item displays a contextual secondary icon: a lock icon when disabled, a checkmark icon when completed, or an unlocked icon when available but not yet completed.
|
|
10
|
-
|
|
11
|
-
## Import
|
|
12
|
-
|
|
13
|
-
```tsx
|
|
14
|
-
import { CourseCollapse } from "stp-ui-kit";
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Props
|
|
18
|
-
|
|
19
|
-
| Prop | Type | Default | Required | Description |
|
|
20
|
-
|------|------|---------|----------|-------------|
|
|
21
|
-
| activeItemId | `string` | - | Yes | The `id` of the currently active/selected navigation item. Used to highlight the active child and determine initial open state. |
|
|
22
|
-
| onChange | `(item: CourseNavItem) => void` | - | Yes | Callback invoked when a navigation item (parent or child) is clicked. Receives the clicked `CourseNavItem` object. |
|
|
23
|
-
| item | `CourseNavItem` | - | Yes | The course navigation item data for the parent node, including its optional children. |
|
|
24
|
-
|
|
25
|
-
### CourseNavItem Type
|
|
26
|
-
|
|
27
|
-
```tsx
|
|
28
|
-
interface CourseNavItem {
|
|
29
|
-
id: string;
|
|
30
|
-
name: string;
|
|
31
|
-
icon?: React.ReactNode;
|
|
32
|
-
completed?: boolean;
|
|
33
|
-
children?: CourseNavItem[];
|
|
34
|
-
disabled?: boolean;
|
|
35
|
-
}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Code Examples
|
|
39
|
-
|
|
40
|
-
**Basic course navigation:**
|
|
41
|
-
|
|
42
|
-
```tsx
|
|
43
|
-
const courseModule: CourseNavItem = {
|
|
44
|
-
id: "module-1",
|
|
45
|
-
name: "Introduction to React",
|
|
46
|
-
icon: <BookIcon />,
|
|
47
|
-
children: [
|
|
48
|
-
{ id: "lesson-1", name: "What is React?", completed: true },
|
|
49
|
-
{ id: "lesson-2", name: "JSX Basics", completed: true },
|
|
50
|
-
{ id: "lesson-3", name: "Components", completed: false },
|
|
51
|
-
{ id: "lesson-4", name: "Advanced Patterns", disabled: true },
|
|
52
|
-
],
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
<CourseCollapse
|
|
56
|
-
activeItemId="lesson-3"
|
|
57
|
-
onChange={(item) => navigate(`/course/${item.id}`)}
|
|
58
|
-
item={courseModule}
|
|
59
|
-
/>
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
**Multiple course modules:**
|
|
63
|
-
|
|
64
|
-
```tsx
|
|
65
|
-
const modules: CourseNavItem[] = [
|
|
66
|
-
{
|
|
67
|
-
id: "mod-1",
|
|
68
|
-
name: "Getting Started",
|
|
69
|
-
icon: <StartIcon />,
|
|
70
|
-
children: [
|
|
71
|
-
{ id: "1-1", name: "Setup", completed: true },
|
|
72
|
-
{ id: "1-2", name: "First App", completed: false },
|
|
73
|
-
],
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
id: "mod-2",
|
|
77
|
-
name: "Advanced Topics",
|
|
78
|
-
icon: <AdvancedIcon />,
|
|
79
|
-
children: [
|
|
80
|
-
{ id: "2-1", name: "State Management", disabled: true },
|
|
81
|
-
{ id: "2-2", name: "Performance", disabled: true },
|
|
82
|
-
],
|
|
83
|
-
},
|
|
84
|
-
];
|
|
85
|
-
|
|
86
|
-
{modules.map((mod) => (
|
|
87
|
-
<CourseCollapse
|
|
88
|
-
key={mod.id}
|
|
89
|
-
activeItemId={currentLessonId}
|
|
90
|
-
onChange={(item) => setCurrentLessonId(item.id)}
|
|
91
|
-
item={mod}
|
|
92
|
-
/>
|
|
93
|
-
))}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## Related Components
|
|
97
|
-
|
|
98
|
-
- Collapse
|
|
99
|
-
- NavigationItem
|
|
100
|
-
|
|
101
|
-
## Source
|
|
102
|
-
|
|
103
|
-
`src/components/navigation/CourseCollapse/CourseCollapse.tsx`
|