stp-ui-kit 0.0.77 → 0.0.79
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 +117 -57
- package/dist/components/display/OptionList/OptionList.d.ts +0 -1
- package/dist/components/form/Calendar/Calendar.d.ts +36 -0
- package/dist/components/form/Calendar/CalendarDay/CalendarDay.d.ts +13 -0
- package/dist/components/form/Calendar/CalendarDayHeader/CalendarDayHeader.d.ts +2 -0
- package/dist/components/form/Calendar/CalendarMonth/CalendarMonth.d.ts +21 -0
- package/dist/components/form/Calendar/dateUtils.d.ts +15 -0
- package/dist/components/form/FormItem/FormItemContext.d.ts +0 -1
- package/dist/components/form/RadioButton/RadioButton.d.ts +0 -1
- package/dist/components/form/index.d.ts +4 -0
- package/dist/components/navigation/Collapse/Collapse.d.ts +0 -1
- package/dist/components/navigation/CourseCollapse/CourseCollapse.d.ts +0 -1
- package/dist/lib/dayjs.d.ts +3 -0
- package/dist/lib/useIsMobile.d.ts +1 -0
- package/dist/stp-ui-kit.es.js +2168 -2647
- package/dist/stp-ui-kit.es.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +52 -18
- package/dist/stp-ui-kit.cjs.js +0 -66
- package/dist/stp-ui-kit.cjs.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,93 +1,153 @@
|
|
|
1
|
-
# stp-ui-kit
|
|
1
|
+
# 🎨 stp-ui-kit
|
|
2
2
|
|
|
3
|
+
A custom UI Kit developed for the Smartestprep platform.
|
|
4
|
+
It provides a set of reusable, styled, and tested UI components to ensure consistent design and faster development across projects.
|
|
3
5
|
|
|
6
|
+
---
|
|
4
7
|
|
|
5
|
-
##
|
|
8
|
+
## 📦 Installation
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
```bash
|
|
11
|
+
npm install stp-ui-kit
|
|
12
|
+
# or
|
|
13
|
+
yarn add stp-ui-kit
|
|
14
|
+
# or
|
|
15
|
+
bun add stp-ui-kit
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
---
|
|
8
19
|
|
|
9
|
-
|
|
20
|
+
## 🚀 Usage
|
|
10
21
|
|
|
11
|
-
|
|
22
|
+
Import styles and components directly into your React project:
|
|
12
23
|
|
|
13
|
-
|
|
14
|
-
|
|
24
|
+
```tsx
|
|
25
|
+
import { Button } from "stp-ui-kit";
|
|
26
|
+
import "stp-ui-kit/dist/styles/index.css";
|
|
15
27
|
|
|
28
|
+
export default function App() {
|
|
29
|
+
return <Button variant='primary'>Click Me</Button>;
|
|
30
|
+
}
|
|
16
31
|
```
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 📂 Project Structure
|
|
36
|
+
|
|
37
|
+
```plaintext
|
|
38
|
+
src/
|
|
39
|
+
├─ assets/ # custom icons and static assets
|
|
40
|
+
├─ components/ # UI components
|
|
41
|
+
│ ├─ data/
|
|
42
|
+
│ ├─ display/
|
|
43
|
+
│ ├─ feedback/
|
|
44
|
+
│ ├─ form/
|
|
45
|
+
│ ├─ layout/
|
|
46
|
+
│ ├─ navigation/
|
|
47
|
+
│ └─ ui/
|
|
48
|
+
├─ lib/ # helpers, utils
|
|
49
|
+
├─ styles/ # global styles, tokens, variables
|
|
50
|
+
│ ├─ _variables.scss
|
|
51
|
+
│ ├─ main.scss
|
|
52
|
+
│ └─ tokens.ts
|
|
53
|
+
├─ App.tsx # playground / dev entry
|
|
54
|
+
└─ index.ts # main export file
|
|
21
55
|
```
|
|
22
56
|
|
|
23
|
-
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 🛠 Tech Stack
|
|
60
|
+
|
|
61
|
+
- React 18+ / 19+ – core UI framework
|
|
62
|
+
- TypeScript – strongly typed components
|
|
63
|
+
- TailwindCSS 4 + SCSS – styling and design tokens
|
|
64
|
+
- Lucide-react – icon library
|
|
65
|
+
- React Hook Form – form handling integration
|
|
66
|
+
- Storybook 8 – interactive component documentation
|
|
67
|
+
- Vite – development & build tooling
|
|
24
68
|
|
|
25
|
-
|
|
69
|
+
---
|
|
26
70
|
|
|
27
|
-
##
|
|
71
|
+
## 📖 Documentation
|
|
28
72
|
|
|
29
|
-
|
|
30
|
-
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
|
31
|
-
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
|
32
|
-
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
|
33
|
-
- [ ] [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/)
|
|
73
|
+
Run Storybook to explore and test components interactively:
|
|
34
74
|
|
|
35
|
-
|
|
75
|
+
```bash
|
|
76
|
+
npm run storybook
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Build the static Storybook docs:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
npm run build-storybook
|
|
83
|
+
```
|
|
36
84
|
|
|
37
|
-
|
|
85
|
+
---
|
|
38
86
|
|
|
39
|
-
|
|
40
|
-
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
|
41
|
-
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
|
42
|
-
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
|
43
|
-
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
|
87
|
+
## 🧑💻 Development
|
|
44
88
|
|
|
45
|
-
|
|
89
|
+
- Start in dev mode
|
|
46
90
|
|
|
47
|
-
|
|
91
|
+
```bash
|
|
92
|
+
npm run dev
|
|
93
|
+
```
|
|
48
94
|
|
|
49
|
-
|
|
95
|
+
- Build library
|
|
50
96
|
|
|
51
|
-
|
|
97
|
+
```bash
|
|
98
|
+
npm run build
|
|
99
|
+
```
|
|
52
100
|
|
|
53
|
-
|
|
101
|
+
- Lint & format
|
|
54
102
|
|
|
55
|
-
|
|
56
|
-
|
|
103
|
+
```bash
|
|
104
|
+
npm run lint
|
|
105
|
+
npm run format
|
|
106
|
+
```
|
|
57
107
|
|
|
58
|
-
|
|
59
|
-
|
|
108
|
+
- Generate tokens
|
|
109
|
+
```bash
|
|
110
|
+
npm run generate-tokens
|
|
111
|
+
```
|
|
60
112
|
|
|
61
|
-
|
|
62
|
-
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
113
|
+
---
|
|
63
114
|
|
|
64
|
-
|
|
65
|
-
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
115
|
+
# 🔑 Principles
|
|
66
116
|
|
|
67
|
-
|
|
68
|
-
|
|
117
|
+
- Fully typed components (.ts / .tsx only)
|
|
118
|
+
- Consistent design system powered by tokens according to Figma designs
|
|
119
|
+
- Use named exports only (`export const`)
|
|
120
|
+
- Remove unused/deprecated components over time
|
|
121
|
+
- Do not add new dependencies unless absolutely necessary (to avoid making the project heavy)
|
|
69
122
|
|
|
70
|
-
|
|
71
|
-
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
123
|
+
### 📦 Project Releases
|
|
72
124
|
|
|
73
|
-
|
|
74
|
-
|
|
125
|
+
- Always upgrade the version in `package.json` before publishing
|
|
126
|
+
- Do **not** run `npm publish` for every minor change
|
|
127
|
+
- Always run `npm run build` before publishing
|
|
128
|
+
- All changes must be commited into repository
|
|
75
129
|
|
|
76
|
-
|
|
77
|
-
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
130
|
+
### 🛠 Local Development
|
|
78
131
|
|
|
79
|
-
|
|
80
|
-
|
|
132
|
+
- When developing locally with other projects, use `npm link`
|
|
133
|
+
```bash
|
|
134
|
+
# inside stp-ui-kit
|
|
135
|
+
npm link
|
|
136
|
+
# inside your project
|
|
137
|
+
npm link stp-ui-kit
|
|
138
|
+
```
|
|
139
|
+
- After testing locally, publish the updated package if required
|
|
81
140
|
|
|
82
|
-
|
|
141
|
+
## 🤝 Contributing
|
|
83
142
|
|
|
84
|
-
|
|
143
|
+
1. Clone the repo
|
|
144
|
+
2. Install dependencies with `npm install`
|
|
145
|
+
3. Run Storybook (`npm run storybook`)
|
|
146
|
+
4. Add or update a component inside `src/components`
|
|
147
|
+
5. Submit a pull request 🎉
|
|
85
148
|
|
|
86
|
-
|
|
87
|
-
Show your appreciation to those who have contributed to the project.
|
|
149
|
+
---
|
|
88
150
|
|
|
89
|
-
## License
|
|
90
|
-
For open source projects, say how it is licensed.
|
|
151
|
+
## 📜 License
|
|
91
152
|
|
|
92
|
-
|
|
93
|
-
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
|
153
|
+
MIT © Smartestprep
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { default as dayjs, Dayjs } from '../../../lib/dayjs';
|
|
2
|
+
/** Public value types */
|
|
3
|
+
export type SingleValue = Dayjs | null;
|
|
4
|
+
export type RangeTuple = [Dayjs | null, Dayjs | null];
|
|
5
|
+
export type RangeValue = RangeTuple | null;
|
|
6
|
+
/** Shared props */
|
|
7
|
+
export type BaseProps = {
|
|
8
|
+
multiMonth?: boolean;
|
|
9
|
+
onCard?: boolean;
|
|
10
|
+
initialMonth?: Dayjs;
|
|
11
|
+
minDate?: Dayjs;
|
|
12
|
+
maxDate?: Dayjs;
|
|
13
|
+
weekStartsOn?: 0 | 1;
|
|
14
|
+
className?: string;
|
|
15
|
+
};
|
|
16
|
+
/** Single-date props (default mode) */
|
|
17
|
+
export type CalendarPropsSingle = BaseProps & {
|
|
18
|
+
allowRange?: false;
|
|
19
|
+
value?: SingleValue;
|
|
20
|
+
defaultValue?: SingleValue;
|
|
21
|
+
onChange?: (value: SingleValue) => void;
|
|
22
|
+
};
|
|
23
|
+
/** Range props (when allowRange is true) */
|
|
24
|
+
export type CalendarPropsRange = BaseProps & {
|
|
25
|
+
allowRange: true;
|
|
26
|
+
value?: RangeValue;
|
|
27
|
+
defaultValue?: RangeValue;
|
|
28
|
+
onChange?: (value: RangeValue) => void;
|
|
29
|
+
};
|
|
30
|
+
/** Discriminated union of prop shapes */
|
|
31
|
+
export type CalendarProps = CalendarPropsSingle | CalendarPropsRange;
|
|
32
|
+
/** Narrowing helpers */
|
|
33
|
+
export declare const asDay: (d: Dayjs | Date | null | undefined) => dayjs.Dayjs | null;
|
|
34
|
+
/** Overloads for better DX */
|
|
35
|
+
export declare function Calendar(props: CalendarPropsSingle): JSX.Element;
|
|
36
|
+
export declare function Calendar(props: CalendarPropsRange): JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export type CornerType = "start" | "end" | "both" | null;
|
|
3
|
+
export interface CalendarDayProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onClick"> {
|
|
4
|
+
number: number;
|
|
5
|
+
isActive?: boolean;
|
|
6
|
+
isCorner?: boolean;
|
|
7
|
+
isInRange?: boolean;
|
|
8
|
+
cornerType?: CornerType;
|
|
9
|
+
onClick?: (dayNumber: number) => void;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const CalendarDay: React.MemoExoticComponent<React.ForwardRefExoticComponent<CalendarDayProps & React.RefAttributes<HTMLButtonElement>>>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Dayjs } from '../../../../lib/dayjs';
|
|
2
|
+
import { CornerType } from '../CalendarDay/CalendarDay';
|
|
3
|
+
export interface CalendarMonthProps {
|
|
4
|
+
monthDate: Dayjs;
|
|
5
|
+
weekStartsOn: 0 | 1;
|
|
6
|
+
locale?: string;
|
|
7
|
+
minDate?: Dayjs;
|
|
8
|
+
maxDate?: Dayjs;
|
|
9
|
+
onSelectDay: (d: Dayjs) => void;
|
|
10
|
+
isInRange?: (d: Dayjs) => boolean;
|
|
11
|
+
isSelected?: (d: Dayjs) => boolean;
|
|
12
|
+
cornerType?: (d: Dayjs) => CornerType;
|
|
13
|
+
allowRange?: boolean;
|
|
14
|
+
showPrev?: boolean;
|
|
15
|
+
showNext?: boolean;
|
|
16
|
+
onPrev?: () => void;
|
|
17
|
+
onNext?: () => void;
|
|
18
|
+
prevDisabled?: boolean;
|
|
19
|
+
nextDisabled?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare const CalendarMonth: import('react').MemoExoticComponent<({ monthDate, weekStartsOn, minDate, maxDate, onSelectDay, isInRange, isSelected, cornerType, allowRange, showPrev, showNext, onPrev, onNext, prevDisabled, nextDisabled, }: CalendarMonthProps) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Dayjs } from '../../../lib/dayjs';
|
|
2
|
+
export declare const startOfDay: (d: Dayjs) => Dayjs;
|
|
3
|
+
export declare const endOfDay: (d: Dayjs) => Dayjs;
|
|
4
|
+
export declare const isSameDay: (a?: Dayjs | null, b?: Dayjs | null) => boolean;
|
|
5
|
+
export declare const isBefore: (a: Dayjs, b: Dayjs) => boolean;
|
|
6
|
+
export declare const isAfter: (a: Dayjs, b: Dayjs) => boolean;
|
|
7
|
+
export declare const clampDate: (d: Dayjs, min?: Dayjs, max?: Dayjs) => Dayjs;
|
|
8
|
+
export declare const addMonths: (d: Dayjs, n: number) => Dayjs;
|
|
9
|
+
export declare const addDays: (d: Dayjs, n: number) => Dayjs;
|
|
10
|
+
/** 6×7 grid for a month view */
|
|
11
|
+
export declare const daysInMonthGrid: (month: Dayjs, weekStartsOn: 0 | 1) => {
|
|
12
|
+
date: Dayjs;
|
|
13
|
+
inCurrentMonth: boolean;
|
|
14
|
+
}[];
|
|
15
|
+
export declare const isDisabled: (d: Dayjs, min?: Dayjs, max?: Dayjs) => boolean | undefined;
|
|
@@ -5,3 +5,7 @@ export * from './Input/Input';
|
|
|
5
5
|
export * from './Input/TextArea';
|
|
6
6
|
export * from './RadioButton/RadioButton';
|
|
7
7
|
export * from './Select/Select';
|
|
8
|
+
export * from './Calendar/Calendar';
|
|
9
|
+
export * from './Calendar/CalendarDay/CalendarDay';
|
|
10
|
+
export * from './Calendar/CalendarMonth/CalendarMonth';
|
|
11
|
+
export * from './Calendar/dateUtils';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useIsMobile: () => boolean;
|