kwant-ui 3.47.1-dev.6 → 3.48.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.md CHANGED
@@ -1,73 +1,181 @@
1
- # Kwant UI Components
1
+ # Kwant-UI
2
2
 
3
- Welcome to Kwant UI Components! This repository contains a collection of reusable user interface components that can be used to build modern and responsive web applications. These components are designed to provide a consistent and intuitive user experience across different platforms and devices.
3
+ `kwant-ui` is the official frontend component library for Kwant-App. It provides a set of reusable, accessible, and themeable React components to build beautiful and consistent user interfaces.
4
4
 
5
- ## Table of Contents
5
+ ## šŸ“‹ Table of Contents
6
6
 
7
- - [Installation](#installation)
8
- - [Development environment](#Development)
9
- - [Usage](#usage)
10
- - [Storybook](#storybook)
7
+ - [About The Project](#about-the-project 'null')
8
+ - [Installation](#installation 'null')
9
+ - [Usage](#usage 'null')
10
+ - [Storybook: Visualizing Components](#storybook-visualizing-components 'null')
11
+ - [Available Scripts for Development](#available-scripts-for-development 'null')
11
12
 
12
- ## Installation
13
+ - [Publishing to NPM](#publishing-to-npm)
14
+ - [Folder Structure](#folder-structure 'null')
15
+ - [Contributing](#contributing 'null')
13
16
 
14
- To install Kwant UI Components, you can use NPM or YARN package manager.
17
+ ## šŸš€ About The Project
15
18
 
16
- ```bash
17
- # npm
18
- npm install kwant-ui
19
+ This library contains all the foundational UI elements required for the Kwant ecosystem. Each component is built with TypeScript for type safety and styled to fit our design system. The components are bundled using Rollup.js for optimized performance.
19
20
 
20
- # yarn
21
- yarn add kwant-ui
22
- ```
21
+ **Built With:**
23
22
 
24
- ## Development
23
+ - [**React**](https://reactjs.org/ 'null')**:** A JavaScript library for building user interfaces.
25
24
 
26
- #### Clone the repository to your local machine:
25
+ - [**Styled Components**](https://styled-components.com/ 'null')**:** For component level styling.
27
26
 
28
- ```bash
29
- git clone git@gitlab.com:kwant.ai/frontend/ui-components.git
30
- ```
27
+ - [**TypeScript**](https://www.typescriptlang.org/ 'null')**:** For robust, type-safe components.
28
+ - [**Storybook**](https://storybook.js.org/ 'null')**:** For developing and showcasing components in isolation.
29
+ - [**Rollup.js**](https://rollupjs.org/ 'null')**:** For bundling the library into a distributable format.
30
+ - [**ESLint**](https://eslint.org/ 'null')**:** For maintaining code quality.
31
31
 
32
- #### Navigate to the project directory:
32
+ ## šŸ“„ Installation
33
33
 
34
- ```bash
35
- cd ui-components
36
- ```
34
+ To use kwant-ui in your project, you need to install the library along with its peer dependencies.
37
35
 
38
- #### Install the required dependencies:
36
+ Install with npm:
39
37
 
40
- ```bash
41
- npm install
38
+ ```
39
+ npm install kwant-ui react react-dom styled-components react-viewport-list
42
40
  ```
43
41
 
44
- If you encounter a `Could not resolve dependency` error when configuring the packages above, you can either downgrade Rollup to v3.0.0, downgrade the version of the plugins that have the dependency issue to the version suggested in the terminal, or try running the command with the `--force` option.`
42
+ **Note:** `react-dom, styled-components, react-viewport-list` are a peer dependency and must be installed alongside `kwant-ui`.
45
43
 
46
- ## Usage
44
+ ## šŸ’” Usage
47
45
 
48
- You can now import the components into your project and start using them. Here's an example of how to use a button component:
46
+ To use `kwant-ui`, you must wrap your application with the `ThemeProvider` from `styled-components` and provide it with a theme from our library. This is a required step for the components to render correctly.
49
47
 
50
- example
48
+ ### 1. Set up the ThemeProvider
51
49
 
52
- ```jsx
50
+ In your main application entry point (`main.tsx` or `index.tsx`), set up the provider as follows:
51
+
52
+ ```
53
+ import React from 'react';
54
+ import ReactDOM from 'react-dom/client';
55
+ import { createBrowserRouter, RouterProvider } from 'react-router-dom';
56
+ import { ROUTES } from './routes';
57
+ import { ThemeProvider } from 'styled-components';
58
+ import './assets/styles/index.scss';
59
+ import { colors } from 'kwant-ui';
60
+
61
+ const router = createBrowserRouter(ROUTES);
62
+
63
+ ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
64
+ <React.StrictMode>
65
+ <ThemeProvider theme={colors}>
66
+ <RouterProvider router={router} />
67
+ </ThemeProvider>
68
+ </React.StrictMode>
69
+ );
70
+
71
+ ```
72
+
73
+ ### 2. Use Components in Your App
74
+
75
+ Once the `ThemeProvider` is set up, you can import and use any component from the library throughout your application.
76
+
77
+ ```
53
78
  import React from 'react';
54
- import { Button } from 'kwant-ui';
79
+ import { Button, Text } from 'kwant-ui';
55
80
 
56
- function App() {
81
+ function MyComponent() {
57
82
  return (
58
- <div>
59
- <Button variant='primary'>Click me</Button>
60
- </div>
83
+ <>
84
+ <Text category="subtitle2" weight="semiBold">Welcome</Text>
85
+ <Button onClick={() => alert('Button Clicked!')} label="Click Me"/>
86
+ </>
61
87
  );
62
88
  }
63
89
 
64
- export default App;
90
+ export default MyComponent;
91
+
92
+ ```
93
+
94
+ ## šŸ“– Storybook: Visualizing Components
95
+
96
+ We use Storybook for interactive development and documentation. It allows you to browse the component library, view the different states of each component, and interact with them in a live environment.
97
+
98
+ #### Live Playground
99
+
100
+ _Explore the live Storybook playground at:_ [_https://ui.kwant.ai/_](https://ui.kwant.ai/ 'null')
101
+
102
+ #### Local Development
103
+
104
+ To run Storybook locally, clone this repository and run:
105
+
106
+ ```
107
+ npm run storybook
108
+ ```
109
+
110
+ This will start the Storybook development server on [http://localhost:6006](https://www.google.com/search?q=http://localhost:6006 'null').
111
+
112
+ ## šŸ“œ Available Scripts for Development
113
+
114
+ These scripts are for the development and maintenance of this library.
115
+
116
+ ### `npm run storybook` or `npm run dev`
117
+
118
+ Starts the Storybook development server. This is the primary command for developing and testing components in isolation.
119
+
120
+ ### `npm run build`
121
+
122
+ ```
123
+ rm -rf ./dist && rollup -c --bundleConfigAsCjs
65
124
  ```
66
125
 
67
- ## Storybook
126
+ Builds the library for production. It first cleans the `dist` directory and then uses Rollup to bundle the components into an optimized format suitable for publishing to NPM.
127
+
128
+ ### `npm run prebuild`
129
+
130
+ This script runs automatically before the `build` script.
131
+
132
+ - `npm run generate-icon-types`: Executes a utility script to automatically generate TypeScript type definitions for the icons used in the library.
133
+
134
+ ### `npm run build-storybook`
135
+
136
+ Builds a static version of the Storybook documentation site, which can be deployed and hosted online.
137
+
138
+ ### `npm run lint`
68
139
 
69
- You can explore and interact with the Kwant UI Components using our Storybook. The Storybook showcases all the available components with their various configurations and states.
140
+ ```
141
+ eslint "**/*.ts*"
142
+ ```
143
+
144
+ Lints all TypeScript files (`.ts` and `.tsx`) in the project to enforce code quality and style consistency.
145
+
146
+ ## šŸ“¦ Publishing to NPM
147
+
148
+ For instructions on how to publish a new version of `kwant-ui` to the NPM repository, please refer to our internal documentation on Confluence.
149
+
150
+ [**Publishing Guide: Publishing a version of ui-components(npm package)**](https://ontargetapp.atlassian.net/wiki/x/AwDcfg 'null')
151
+
152
+ ## šŸ“‚ Folder Structure
153
+
154
+ The library is organized as follows:
155
+
156
+ ```
157
+ kwant-ui/
158
+ ā”œā”€ā”€ .storybook/ # Storybook configuration files
159
+ ā”œā”€ā”€ components/ # The source code for all React components
160
+ ā”œā”€ā”€ GlobalStyles/ # Global CSS styles and resets
161
+ ā”œā”€ā”€ HOC/ # Higher-Order Components
162
+ ā”œā”€ā”€ hooks/ # Custom React hooks
163
+ ā”œā”€ā”€ stories/ # Storybook stories for each component
164
+ ā”œā”€ā”€ themes/ # Design tokens (colors, spacing, typography)
165
+ ā”œā”€ā”€ types/ # Global TypeScript type definitions
166
+ ā”œā”€ā”€ utils/ # Utility scripts, like the icon type generator
167
+ ā”œā”€ā”€ .eslintrc.cjs # ESLint configuration
168
+ ā”œā”€ā”€ .prettierrc # Prettier configuration
169
+ ā”œā”€ā”€ package.json # Project dependencies and scripts
170
+ ā”œā”€ā”€ rollup.config.js # Rollup configuration for building the library
171
+ └── tsconfig.json # TypeScript configuration
172
+
173
+ ```
70
174
 
71
- You can access the Storybook here: [Kwant UI Components Storybook](https://ui.kwant.ai/)
175
+ ## šŸ¤ Contributing
72
176
 
73
- Feel free to experiment with the components and see how they can be customized and integrated into your projects.
177
+ 1. Fork the Project
178
+ 2. Create your Feature Branch (`git checkout -b PR-JIRA-TICKET-ID`)
179
+ 3. Commit your Changes (`git commit -m 'Add NewComponent'`)
180
+ 4. Push to the Branch (`git push origin PR-JIRA-TICKET-ID`)
181
+ 5. Open a Pull Request
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import { RefObject } from 'react';
2
2
  import { AvatarDeclarations } from '../Avatar/Avatar.types';
3
3
  import { IBaseDropdown } from '../BaseDropdown/BaseDropdownTypes';
4
4
  export declare namespace IDropdown {
@@ -10,6 +10,7 @@ export declare namespace IDropdown {
10
10
  };
11
11
  type Props = Omit<IBaseDropdown.Props, 'height' | 'children'> & {
12
12
  maxHeight?: number;
13
+ isDynamicOptionPosition?: boolean;
13
14
  onChange?: React.Dispatch<React.SetStateAction<boolean>>;
14
15
  onDropdownVisibilityChange?: () => void;
15
16
  data?: Option[];
@@ -32,3 +33,19 @@ export declare namespace IDropdown {
32
33
  withInput?: boolean;
33
34
  };
34
35
  }
36
+ export interface DropdownOffsets {
37
+ offsetTop?: string;
38
+ offsetBottom?: string;
39
+ maxHeight: number;
40
+ }
41
+ export interface UseDropdownPositioningProps {
42
+ isDynamicOptionPosition?: boolean;
43
+ targetRef?: RefObject<HTMLElement>;
44
+ opened: boolean;
45
+ maxHeight?: number;
46
+ offsetTop?: string;
47
+ offsetBottom?: string;
48
+ searchable?: boolean;
49
+ dataLength?: number;
50
+ itemHeight?: number;
51
+ }
@@ -0,0 +1,7 @@
1
+ import { DropdownOffsets, UseDropdownPositioningProps } from '../DropdownTypes';
2
+ export declare const useDropdownPositioning: ({ isDynamicOptionPosition, targetRef, opened, maxHeight, offsetTop, offsetBottom, searchable, dataLength, itemHeight, }: UseDropdownPositioningProps) => {
3
+ currentOffsets: DropdownOffsets;
4
+ isOpeningUpward: boolean;
5
+ calculateDropdownPosition: () => void;
6
+ renderDropDown: boolean;
7
+ };
@@ -3,7 +3,7 @@ import { IDropdown } from '../Dropdown/DropdownTypes';
3
3
  export declare namespace IDropdownSelect {
4
4
  type Option = IDropdown.Option;
5
5
  type Props = IDropdown.Props & {
6
- children: React.ReactNode;
6
+ children?: React.ReactNode;
7
7
  toggleOnTargetClick?: boolean;
8
8
  withInput?: boolean;
9
9
  disabled?: boolean;
@@ -17,6 +17,7 @@ export declare namespace ISelect {
17
17
  onClear?: () => void;
18
18
  onSelect?: (option: ISelect.Option, index?: number) => void;
19
19
  disabled?: boolean;
20
+ isDynamicOptionPosition?: boolean;
20
21
  }
21
22
  interface Option extends IDropdownSelect.Option {
22
23
  }
@@ -0,0 +1,2 @@
1
+ import { TimePickerProps } from './types';
2
+ export declare function TimePicker({ label, disabled, tooltipContent, tooltipPosition, format, onChange, onBlur, value, required, id, period, onlyHours, }: TimePickerProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { TimePicker } from './TimePicker';
2
+ export { TimePicker };
@@ -0,0 +1,13 @@
1
+ export declare const TimeContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export declare const TimeInput: import("styled-components").StyledComponent<"input", any, {
3
+ format?: string;
4
+ onlyHours?: boolean;
5
+ }, never>;
6
+ export declare const TimeInputWrapper: import("styled-components").StyledComponent<"div", any, {
7
+ onlyHours?: boolean;
8
+ }, never>;
9
+ export declare const ColonSeparator: import("styled-components").StyledComponent<"span", any, {}, never>;
10
+ export declare const DisabledMinutes: import("styled-components").StyledComponent<"span", any, {}, never>;
11
+ export declare const DropdownContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
12
+ export declare const DropdownButton: import("styled-components").StyledComponent<"button", any, {}, never>;
13
+ export declare const PeriodText: import("styled-components").StyledComponent<"span", any, {}, never>;
@@ -0,0 +1,22 @@
1
+ /// <reference types="react" />
2
+ import { TooltipComponent } from '../Tooltip/types';
3
+ type Period = 'AM' | 'PM';
4
+ type Format = '12' | '24';
5
+ export interface TimePickerProps {
6
+ onChange?: (value: {
7
+ time: string;
8
+ period?: Period;
9
+ }) => void;
10
+ onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;
11
+ disabled?: boolean;
12
+ required?: boolean;
13
+ label?: string;
14
+ id?: string;
15
+ value?: string;
16
+ tooltipContent?: string;
17
+ tooltipPosition?: TooltipComponent.Position;
18
+ format?: Format;
19
+ period?: Period;
20
+ onlyHours?: boolean;
21
+ }
22
+ export {};
package/dist/index.d.ts CHANGED
@@ -61,6 +61,7 @@ export * from './components/Charts/HorizontalStackedBarChart';
61
61
  export * from './components/Charts/GaugeChart';
62
62
  export * from './components/Charts/ProgressChart';
63
63
  export * from './components/Charts/LineChart';
64
+ export * from './components/TimePicker';
64
65
  export { CALENDAR_CONSTANTS, getDateObjectForCalendarConstants, } from './components/Calendar/CalendarUtils';
65
66
  export * from './components/TrendPercentage';
66
67
  export * from './components/Charts/WorkerTimeChart';