@adamjanicki/ui 1.7.1 → 1.7.2

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.
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import { type BoxProps } from "../Box/Box";
3
3
  import ui from "../ui";
4
4
  type SelectProps = React.ComponentProps<typeof ui.select>;
5
- type Props = Omit<BoxProps, "children"> & {
5
+ type Props = Omit<BoxProps, "children" | "onChange"> & {
6
6
  /**
7
7
  * Array of options to display in the select
8
8
  */
@@ -14,10 +14,18 @@ type Props = Omit<BoxProps, "children"> & {
14
14
  * @returns the label of the option
15
15
  */
16
16
  getOptionLabel?: (option: string) => string;
17
+ /**
18
+ * Current value of the select
19
+ */
20
+ value?: SelectProps["value"];
21
+ /**
22
+ * Change handler for the select
23
+ */
24
+ onChange?: SelectProps["onChange"];
17
25
  /**
18
26
  * Props to pass to the underlying select element
19
27
  */
20
- selectProps?: SelectProps;
28
+ selectProps?: Omit<SelectProps, "value" | "onChange">;
21
29
  };
22
30
  declare const Select: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLSelectElement>>;
23
31
  export default Select;
@@ -27,8 +27,8 @@ import Box from "../Box/Box";
27
27
  import Icon from "../Icon";
28
28
  import ui from "../ui";
29
29
  var Select = React.forwardRef(function (_a, ref) {
30
- var className = _a.className, options = _a.options, vfx = _a.vfx, getOptionLabel = _a.getOptionLabel, selectProps = _a.selectProps, rest = __rest(_a, ["className", "options", "vfx", "getOptionLabel", "selectProps"]);
30
+ var className = _a.className, options = _a.options, vfx = _a.vfx, getOptionLabel = _a.getOptionLabel, selectProps = _a.selectProps, value = _a.value, onChange = _a.onChange, rest = __rest(_a, ["className", "options", "vfx", "getOptionLabel", "selectProps", "value", "onChange"]);
31
31
  var selectClassName = (selectProps || {}).className;
32
- return (_jsxs(Box, __assign({ vfx: __assign({ pos: "relative", width: "fit", axis: "x", align: "center", radius: "rounded", backgroundColor: "default", color: "default", padding: "none" }, vfx), className: classNames("aui-select-container", (selectProps === null || selectProps === void 0 ? void 0 : selectProps.disabled) ? "aui-select-disabled" : undefined, className) }, rest, { children: [_jsx(ui.select, __assign({}, selectProps, { className: classNames("aui-select", selectClassName), ref: ref, children: options.map(function (option, index) { return (_jsx("option", { value: option, children: (getOptionLabel === null || getOptionLabel === void 0 ? void 0 : getOptionLabel(option)) || option }, index)); }) })), _jsx(Icon, { icon: "chevron-down", className: "aui-select-icon", "aria-hidden": true })] })));
32
+ return (_jsxs(Box, __assign({ vfx: __assign({ pos: "relative", width: "fit", axis: "x", align: "center", radius: "rounded", backgroundColor: "default", color: "default", padding: "none" }, vfx), className: classNames("aui-select-container", (selectProps === null || selectProps === void 0 ? void 0 : selectProps.disabled) ? "aui-select-disabled" : undefined, className) }, rest, { children: [_jsx(ui.select, __assign({}, selectProps, { value: value, onChange: onChange, className: classNames("aui-select", selectClassName), ref: ref, children: options.map(function (option, index) { return (_jsx("option", { value: option, children: (getOptionLabel === null || getOptionLabel === void 0 ? void 0 : getOptionLabel(option)) || option }, index)); }) })), _jsx(Icon, { icon: "chevron-down", className: "aui-select-icon", "aria-hidden": true })] })));
33
33
  });
34
34
  export default Select;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamjanicki/ui",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "description": "Basic UI components and hooks for React in TypeScript",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -1,194 +1,186 @@
1
1
  var transformers = {
2
2
  // --- Layout ---
3
- pos: function (_a) {
3
+ pos: function (classes, _a) {
4
4
  var pos = _a.pos;
5
- return "aui-pos-".concat(pos);
5
+ return classes.push("aui-pos-".concat(pos));
6
6
  },
7
- axis: function (_a) {
7
+ axis: function (classes, _a) {
8
8
  var axis = _a.axis;
9
- return "aui-flex-".concat(axis);
9
+ return classes.push("aui-flex-".concat(axis));
10
10
  },
11
- gap: function (_a) {
11
+ gap: function (classes, _a) {
12
12
  var gap = _a.gap;
13
- return "aui-gap-".concat(gap);
13
+ return classes.push("aui-gap-".concat(gap));
14
14
  },
15
- align: function (_a) {
15
+ align: function (classes, _a) {
16
16
  var align = _a.align;
17
- return "aui-align-".concat(align);
17
+ return classes.push("aui-align-".concat(align));
18
18
  },
19
- justify: function (_a) {
19
+ justify: function (classes, _a) {
20
20
  var justify = _a.justify;
21
- return "aui-justify-".concat(justify);
21
+ return classes.push("aui-justify-".concat(justify));
22
22
  },
23
- wrap: function () { return "aui-flex-wrap"; },
24
- overflow: function (_a) {
23
+ wrap: function (classes) { return classes.push("aui-flex-wrap"); },
24
+ overflow: function (classes, _a) {
25
25
  var overflow = _a.overflow;
26
- return "aui-ov-".concat(overflow);
26
+ return classes.push("aui-ov-".concat(overflow));
27
27
  },
28
- overflowX: function (_a) {
28
+ overflowX: function (classes, _a) {
29
29
  var overflowX = _a.overflowX;
30
- return "aui-ov-x-".concat(overflowX);
30
+ return classes.push("aui-ov-x-".concat(overflowX));
31
31
  },
32
- overflowY: function (_a) {
32
+ overflowY: function (classes, _a) {
33
33
  var overflowY = _a.overflowY;
34
- return "aui-ov-y-".concat(overflowY);
34
+ return classes.push("aui-ov-y-".concat(overflowY));
35
35
  },
36
- z: function (_a) {
36
+ z: function (classes, _a) {
37
37
  var z = _a.z;
38
- return "aui-z-".concat(z);
38
+ return classes.push("aui-z-".concat(z));
39
39
  },
40
40
  // --- Spacing ---
41
- padding: function (_a) {
41
+ padding: function (classes, _a) {
42
42
  var padding = _a.padding;
43
- return "aui-pa-".concat(padding);
43
+ return classes.push("aui-pa-".concat(padding));
44
44
  },
45
- paddingX: function (_a) {
45
+ paddingX: function (classes, _a) {
46
46
  var paddingX = _a.paddingX, paddingLeft = _a.paddingLeft, paddingRight = _a.paddingRight;
47
- var result = [];
48
47
  if (!paddingLeft)
49
- result.push("aui-pl-".concat(paddingX));
48
+ classes.push("aui-pl-".concat(paddingX));
50
49
  if (!paddingRight)
51
- result.push("aui-pr-".concat(paddingX));
52
- return result.join(" ");
50
+ classes.push("aui-pr-".concat(paddingX));
53
51
  },
54
- paddingY: function (_a) {
52
+ paddingY: function (classes, _a) {
55
53
  var paddingY = _a.paddingY, paddingTop = _a.paddingTop, paddingBottom = _a.paddingBottom;
56
- var result = [];
57
54
  if (!paddingTop)
58
- result.push("aui-pt-".concat(paddingY));
55
+ classes.push("aui-pt-".concat(paddingY));
59
56
  if (!paddingBottom)
60
- result.push("aui-pb-".concat(paddingY));
61
- return result.join(" ");
57
+ classes.push("aui-pb-".concat(paddingY));
62
58
  },
63
- paddingTop: function (_a) {
59
+ paddingTop: function (classes, _a) {
64
60
  var paddingTop = _a.paddingTop;
65
- return "aui-pt-".concat(paddingTop);
61
+ return classes.push("aui-pt-".concat(paddingTop));
66
62
  },
67
- paddingBottom: function (_a) {
63
+ paddingBottom: function (classes, _a) {
68
64
  var paddingBottom = _a.paddingBottom;
69
- return "aui-pb-".concat(paddingBottom);
65
+ return classes.push("aui-pb-".concat(paddingBottom));
70
66
  },
71
- paddingLeft: function (_a) {
67
+ paddingLeft: function (classes, _a) {
72
68
  var paddingLeft = _a.paddingLeft;
73
- return "aui-pl-".concat(paddingLeft);
69
+ return classes.push("aui-pl-".concat(paddingLeft));
74
70
  },
75
- paddingRight: function (_a) {
71
+ paddingRight: function (classes, _a) {
76
72
  var paddingRight = _a.paddingRight;
77
- return "aui-pr-".concat(paddingRight);
73
+ return classes.push("aui-pr-".concat(paddingRight));
78
74
  },
79
- margin: function (_a) {
75
+ margin: function (classes, _a) {
80
76
  var margin = _a.margin;
81
- return "aui-ma-".concat(margin);
77
+ return classes.push("aui-ma-".concat(margin));
82
78
  },
83
- marginX: function (_a) {
79
+ marginX: function (classes, _a) {
84
80
  var marginX = _a.marginX, marginLeft = _a.marginLeft, marginRight = _a.marginRight;
85
- var result = [];
86
81
  if (!marginLeft)
87
- result.push("aui-ml-".concat(marginX));
82
+ classes.push("aui-ml-".concat(marginX));
88
83
  if (!marginRight)
89
- result.push("aui-mr-".concat(marginX));
90
- return result.join(" ");
84
+ classes.push("aui-mr-".concat(marginX));
91
85
  },
92
- marginY: function (_a) {
86
+ marginY: function (classes, _a) {
93
87
  var marginY = _a.marginY, marginTop = _a.marginTop, marginBottom = _a.marginBottom;
94
- var result = [];
95
88
  if (!marginTop)
96
- result.push("aui-mt-".concat(marginY));
89
+ classes.push("aui-mt-".concat(marginY));
97
90
  if (!marginBottom)
98
- result.push("aui-mb-".concat(marginY));
99
- return result.join(" ");
91
+ classes.push("aui-mb-".concat(marginY));
100
92
  },
101
- marginTop: function (_a) {
93
+ marginTop: function (classes, _a) {
102
94
  var marginTop = _a.marginTop;
103
- return "aui-mt-".concat(marginTop);
95
+ return classes.push("aui-mt-".concat(marginTop));
104
96
  },
105
- marginBottom: function (_a) {
97
+ marginBottom: function (classes, _a) {
106
98
  var marginBottom = _a.marginBottom;
107
- return "aui-mb-".concat(marginBottom);
99
+ return classes.push("aui-mb-".concat(marginBottom));
108
100
  },
109
- marginLeft: function (_a) {
101
+ marginLeft: function (classes, _a) {
110
102
  var marginLeft = _a.marginLeft;
111
- return "aui-ml-".concat(marginLeft);
103
+ return classes.push("aui-ml-".concat(marginLeft));
112
104
  },
113
- marginRight: function (_a) {
105
+ marginRight: function (classes, _a) {
114
106
  var marginRight = _a.marginRight;
115
- return "aui-mr-".concat(marginRight);
107
+ return classes.push("aui-mr-".concat(marginRight));
116
108
  },
117
109
  // --- Dimensions ---
118
- width: function (_a) {
110
+ width: function (classes, _a) {
119
111
  var width = _a.width;
120
- return "aui-w-".concat(width);
112
+ return classes.push("aui-w-".concat(width));
121
113
  },
122
- maxWidth: function (_a) {
114
+ maxWidth: function (classes, _a) {
123
115
  var maxWidth = _a.maxWidth;
124
- return "aui-mw-".concat(maxWidth);
116
+ return classes.push("aui-mw-".concat(maxWidth));
125
117
  },
126
- height: function (_a) {
118
+ height: function (classes, _a) {
127
119
  var height = _a.height;
128
- return "aui-h-".concat(height);
120
+ return classes.push("aui-h-".concat(height));
129
121
  },
130
- maxHeight: function (_a) {
122
+ maxHeight: function (classes, _a) {
131
123
  var maxHeight = _a.maxHeight;
132
- return "aui-mh-".concat(maxHeight);
124
+ return classes.push("aui-mh-".concat(maxHeight));
133
125
  },
134
126
  // --- Borders ---
135
- radius: function (_a) {
127
+ radius: function (classes, _a) {
136
128
  var radius = _a.radius;
137
- return "aui-radius-".concat(radius);
138
- },
139
- border: function () { return "aui-ba"; },
140
- borderTop: function () { return "aui-bt"; },
141
- borderBottom: function () { return "aui-bb"; },
142
- borderLeft: function () { return "aui-bl"; },
143
- borderRight: function () { return "aui-br"; },
144
- borderWidth: function (_a) {
129
+ return classes.push("aui-radius-".concat(radius));
130
+ },
131
+ border: function (classes) { return classes.push("aui-ba"); },
132
+ borderTop: function (classes) { return classes.push("aui-bt"); },
133
+ borderBottom: function (classes) { return classes.push("aui-bb"); },
134
+ borderLeft: function (classes) { return classes.push("aui-bl"); },
135
+ borderRight: function (classes) { return classes.push("aui-br"); },
136
+ borderWidth: function (classes, _a) {
145
137
  var borderWidth = _a.borderWidth;
146
- return "aui-bw-".concat(borderWidth);
138
+ return classes.push("aui-bw-".concat(borderWidth));
147
139
  },
148
- borderStyle: function (_a) {
140
+ borderStyle: function (classes, _a) {
149
141
  var borderStyle = _a.borderStyle;
150
- return "aui-bs-".concat(borderStyle);
142
+ return classes.push("aui-bs-".concat(borderStyle));
151
143
  },
152
- borderColor: function (_a) {
144
+ borderColor: function (classes, _a) {
153
145
  var borderColor = _a.borderColor;
154
- return "aui-bc-".concat(borderColor);
146
+ return classes.push("aui-bc-".concat(borderColor));
155
147
  },
156
148
  // --- Effects ---
157
- shadow: function (_a) {
149
+ shadow: function (classes, _a) {
158
150
  var shadow = _a.shadow;
159
- return "aui-shadow-".concat(shadow);
151
+ return classes.push("aui-shadow-".concat(shadow));
160
152
  },
161
- opacity: function (_a) {
153
+ opacity: function (classes, _a) {
162
154
  var opacity = _a.opacity;
163
- return "aui-op-".concat(opacity);
155
+ return classes.push("aui-op-".concat(opacity));
164
156
  },
165
157
  // --- Typography ---
166
- fontSize: function (_a) {
158
+ fontSize: function (classes, _a) {
167
159
  var fontSize = _a.fontSize;
168
- return "aui-f-".concat(fontSize);
160
+ return classes.push("aui-f-".concat(fontSize));
169
161
  },
170
- fontWeight: function (_a) {
162
+ fontWeight: function (classes, _a) {
171
163
  var fontWeight = _a.fontWeight;
172
- return "aui-fw-".concat(fontWeight);
164
+ return classes.push("aui-fw-".concat(fontWeight));
173
165
  },
174
- textAlign: function (_a) {
166
+ textAlign: function (classes, _a) {
175
167
  var textAlign = _a.textAlign;
176
- return "aui-ta-".concat(textAlign);
168
+ return classes.push("aui-ta-".concat(textAlign));
177
169
  },
178
- italics: function () { return "aui-it"; },
170
+ italics: function (classes) { return classes.push("aui-it"); },
179
171
  // --- Colors ---
180
- color: function (_a) {
172
+ color: function (classes, _a) {
181
173
  var color = _a.color;
182
- return "aui-c-".concat(color);
174
+ return classes.push("aui-c-".concat(color));
183
175
  },
184
- backgroundColor: function (_a) {
176
+ backgroundColor: function (classes, _a) {
185
177
  var backgroundColor = _a.backgroundColor;
186
- return "aui-bg-".concat(backgroundColor);
178
+ return classes.push("aui-bg-".concat(backgroundColor));
187
179
  },
188
180
  // --- Misc ---
189
- cursor: function (_a) {
181
+ cursor: function (classes, _a) {
190
182
  var cursor = _a.cursor;
191
- return "aui-cur-".concat(cursor);
183
+ return classes.push("aui-cursor-".concat(cursor));
192
184
  },
193
185
  };
194
186
  // Main function
@@ -198,10 +190,7 @@ export default function transformVfx(vfx) {
198
190
  var classes = [];
199
191
  for (var key in vfx) {
200
192
  var transformer = transformers[key];
201
- var result = transformer(vfx);
202
- if (result) {
203
- classes.push(result);
204
- }
193
+ transformer(classes, vfx);
205
194
  }
206
195
  return classes.join(" ") || null;
207
196
  }