@shlinkio/shlink-frontend-kit 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 shlinkio
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Shlink frontend kit
2
+
3
+ React components and utilities for Shlink frontend projects
package/dist/index.css ADDED
@@ -0,0 +1 @@
1
+ .search-field{position:relative}.search-field:focus-within{z-index:1}.search-field__input.search-field__input{padding-left:40px;padding-right:40px}.search-field__input--no-border.search-field__input--no-border{border:none;border-radius:0}.search-field__icon{position:absolute;top:50%;transform:translateY(-50%);left:15px;color:#6c757d}.search-field__close{position:absolute;top:50%;transform:translateY(-50%);right:10px;cursor:pointer}.dropdown-btn__toggle.dropdown-btn__toggle{text-align:left}.dropdown-btn__toggle.dropdown-btn__toggle--with-caret{padding-right:1.75rem}.dropdown-btn__toggle.dropdown-btn__toggle,.dropdown-btn__toggle.dropdown-btn__toggle:not(:disabled):not(.disabled).active,.dropdown-btn__toggle.dropdown-btn__toggle:not(:disabled):not(.disabled):active,.dropdown-btn__toggle.dropdown-btn__toggle:not(:disabled):not(.disabled):focus,.dropdown-btn__toggle.dropdown-btn__toggle:not(:disabled):not(.disabled):hover,.show>.dropdown-btn__toggle.dropdown-btn__toggle.dropdown-toggle{color:var(--input-text-color);background-color:var(--primary-color);border-color:var(--input-border-color)}.card .dropdown-btn__toggle.dropdown-btn__toggle,.card .dropdown-btn__toggle.dropdown-btn__toggle:not(:disabled):not(.disabled).active,.card .dropdown-btn__toggle.dropdown-btn__toggle:not(:disabled):not(.disabled):active,.card .dropdown-btn__toggle.dropdown-btn__toggle:not(:disabled):not(.disabled):focus,.card .dropdown-btn__toggle.dropdown-btn__toggle:not(:disabled):not(.disabled):hover,.show>.card .dropdown-btn__toggle.dropdown-btn__toggle.dropdown-toggle{background-color:var(--input-color)}.dropdown-btn__toggle.dropdown-btn__toggle.disabled,.dropdown-btn__toggle.dropdown-btn__toggle:disabled{background-color:var(--input-disabled-color)}.dropdown-btn__toggle.dropdown-btn__toggle:after{position:absolute;top:50%;transform:translateY(-50%);right:.75rem}.nav-pills__nav{position:sticky!important;top:55px;z-index:2}.nav-pills__nav-link.nav-pills__nav-link{border-radius:0!important;padding-bottom:calc(.5rem - 3px)!important;border-bottom:3px solid transparent!important;color:#5d6778;font-weight:700;cursor:pointer;text-decoration:none}@media (min-width: 576px) and (max-width: 991px){.nav-pills__nav-link.nav-pills__nav-link{font-size:89%}}.nav-pills__nav-link:hover{color:#4696e5!important}.nav-pills__nav-link.active{border-color:#4696e5!important;background-color:var(--primary-color)!important;color:#4696e5!important}.ordering-dropdown__menu--link.ordering-dropdown__menu--link{min-width:11rem}.ordering-dropdown__sort-icon{margin:3.5px 0 0;float:right}
@@ -0,0 +1,170 @@
1
+ import type { CardProps } from 'reactstrap';
2
+ import type { ChangeEvent } from 'react';
3
+ import type { DropdownToggleProps } from 'reactstrap/types/lib/DropdownToggle';
4
+ import type { FC } from 'react';
5
+ import type { InputType } from 'reactstrap/types/lib/Input';
6
+ import { JSX as JSX_2 } from 'react/jsx-runtime';
7
+ import { MutableRefObject } from 'react';
8
+ import type { PropsWithChildren } from 'react';
9
+ import type { ReactNode } from 'react';
10
+
11
+ declare type BooleanControlProps = PropsWithChildren<{
12
+ checked?: boolean;
13
+ onChange?: (checked: boolean, e: ChangeEvent<HTMLInputElement>) => void;
14
+ className?: string;
15
+ inline?: boolean;
16
+ }>;
17
+
18
+ export declare const changeThemeInMarkup: (theme: Theme) => void | undefined;
19
+
20
+ export declare const Checkbox: FC<BooleanControlProps>;
21
+
22
+ export declare const determineOrderDir: <T extends string = string>(currentField: T, newField?: T | undefined, currentOrderDir?: OrderDir) => OrderDir;
23
+
24
+ export declare const DropdownBtn: FC<DropdownBtnProps>;
25
+
26
+ export declare type DropdownBtnMenuProps = PropsWithChildren<{
27
+ minWidth?: number;
28
+ }>;
29
+
30
+ export declare type DropdownBtnProps = PropsWithChildren<Omit<DropdownToggleProps, 'caret' | 'size' | 'outline'> & {
31
+ text: ReactNode;
32
+ noCaret?: boolean;
33
+ className?: string;
34
+ dropdownClassName?: string;
35
+ inline?: boolean;
36
+ minWidth?: number;
37
+ size?: 'sm' | 'md' | 'lg';
38
+ }>;
39
+
40
+ export declare const HIGHLIGHTED_COLOR = "#f77f28";
41
+
42
+ export declare const HIGHLIGHTED_COLOR_ALPHA = "rgba(247, 127, 40, 0.4)";
43
+
44
+ export declare const InputFormGroup: FC<InputFormGroupProps>;
45
+
46
+ export declare type InputFormGroupProps = PropsWithChildren<{
47
+ value: string;
48
+ onChange: (newValue: string) => void;
49
+ type?: InputType;
50
+ required?: boolean;
51
+ placeholder?: string;
52
+ className?: string;
53
+ labelClassName?: string;
54
+ }>;
55
+
56
+ export declare const isDarkThemeEnabled: () => boolean;
57
+
58
+ export declare const LabeledFormGroup: FC<LabeledFormGroupProps>;
59
+
60
+ declare type LabeledFormGroupProps = PropsWithChildren<{
61
+ label: ReactNode;
62
+ noMargin?: boolean;
63
+ className?: string;
64
+ labelClassName?: string;
65
+ id?: string;
66
+ }>;
67
+
68
+ export declare const MAIN_COLOR = "#4696e5";
69
+
70
+ export declare const MAIN_COLOR_ALPHA = "rgba(70, 150, 229, 0.4)";
71
+
72
+ export declare const Message: FC<MessageProps>;
73
+
74
+ export declare type MessageProps = PropsWithChildren<{
75
+ className?: string;
76
+ loading?: boolean;
77
+ fullWidth?: boolean;
78
+ type?: MessageType;
79
+ }>;
80
+
81
+ declare type MessageType = 'default' | 'error';
82
+
83
+ export declare const NavPillItem: FC<NavPillProps>;
84
+
85
+ declare type NavPillProps = PropsWithChildren<{
86
+ to: string;
87
+ replace?: boolean;
88
+ }>;
89
+
90
+ export declare const NavPills: FC<NavPillsProps>;
91
+
92
+ declare type NavPillsProps = PropsWithChildren<{
93
+ fill?: boolean;
94
+ className?: string;
95
+ }>;
96
+
97
+ export declare type Order<Fields> = {
98
+ field?: Fields;
99
+ dir?: OrderDir;
100
+ };
101
+
102
+ export declare type OrderDir = 'ASC' | 'DESC' | undefined;
103
+
104
+ export declare function OrderingDropdown<T extends string = string>({ items, order, onChange, isButton, right, prefixed }: OrderingDropdownProps<T>): JSX_2.Element;
105
+
106
+ export declare type OrderingDropdownProps<T extends string = string> = {
107
+ items: Record<T, string>;
108
+ order: Order<T>;
109
+ onChange: (orderField?: T, orderDir?: OrderDir) => void;
110
+ isButton?: boolean;
111
+ right?: boolean;
112
+ prefixed?: boolean;
113
+ };
114
+
115
+ export declare const orderToString: <T>(order: Order<T>) => string | undefined;
116
+
117
+ export declare const parseQuery: <T>(search: string) => T;
118
+
119
+ export declare const PRIMARY_DARK_COLOR = "#161b22";
120
+
121
+ export declare const PRIMARY_LIGHT_COLOR = "white";
122
+
123
+ export declare const Result: FC<ResultProps>;
124
+
125
+ export declare type ResultProps = PropsWithChildren<{
126
+ type: ResultType;
127
+ className?: string;
128
+ small?: boolean;
129
+ }>;
130
+
131
+ export declare type ResultType = 'success' | 'error' | 'warning';
132
+
133
+ export declare const RowDropdownBtn: FC<DropdownBtnMenuProps>;
134
+
135
+ export declare const SearchField: ({ onChange, className, large, noBorder, initialValue }: SearchFieldProps) => JSX_2.Element;
136
+
137
+ declare type SearchFieldProps = {
138
+ onChange: (value: string) => void;
139
+ className?: string;
140
+ large?: boolean;
141
+ noBorder?: boolean;
142
+ initialValue?: string;
143
+ };
144
+
145
+ export declare const SimpleCard: ({ title, children, bodyClassName, ...rest }: SimpleCardProps) => JSX_2.Element;
146
+
147
+ export declare type SimpleCardProps = Omit<CardProps, 'title'> & {
148
+ title?: ReactNode;
149
+ bodyClassName?: string;
150
+ };
151
+
152
+ export declare const sortList: <List>(list: List[], { field, dir }: Order<keyof List>) => List[];
153
+
154
+ export declare const stringifyQuery: (query: any) => string;
155
+
156
+ export declare const stringToOrder: <T>(order: string) => Order<T>;
157
+
158
+ export declare type Theme = 'dark' | 'light';
159
+
160
+ declare type ToggleResult = [boolean, () => void, () => void, () => void];
161
+
162
+ export declare const ToggleSwitch: FC<BooleanControlProps>;
163
+
164
+ export declare const useDomId: () => string;
165
+
166
+ export declare const useElementRef: <T>() => MutableRefObject<T | null>;
167
+
168
+ export declare const useToggle: (initialValue?: boolean) => ToggleResult;
169
+
170
+ export { }