@adamjanicki/ui 1.1.7 → 1.1.8

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.
@@ -28,6 +28,14 @@ type Props = Omit<React.DetailedHTMLProps<React.SelectHTMLAttributes<HTMLSelectE
28
28
  * Name of the select for accessibility purposes
29
29
  */
30
30
  "aria-label": string;
31
+ /**
32
+ * [Optional] The styles to apply to the select element
33
+ */
34
+ innerStyle?: React.CSSProperties;
35
+ /**
36
+ * [Optional] The class name to apply to the select element
37
+ */
38
+ innerClassName?: string;
31
39
  };
32
40
  declare const _default: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLSelectElement>>;
33
41
  export default _default;
@@ -20,12 +20,12 @@ var __rest = (this && this.__rest) || function (s, e) {
20
20
  }
21
21
  return t;
22
22
  };
23
- import { jsx as _jsx } from "react/jsx-runtime";
23
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
24
  import { forwardRef } from "react";
25
25
  import { classNames } from "../../utils/util";
26
26
  var identity = function (x) { return x; };
27
27
  var Select = function (_a, ref) {
28
- var className = _a.className, options = _a.options, _b = _a.getOptionValue, getOptionValue = _b === void 0 ? identity : _b, _c = _a.getOptionLabel, getOptionLabel = _c === void 0 ? identity : _c, _d = _a.corners, corners = _d === void 0 ? "rounded" : _d, props = __rest(_a, ["className", "options", "getOptionValue", "getOptionLabel", "corners"]);
29
- return (_jsx("select", __assign({}, props, { ref: ref, className: classNames("ajui-select-base corners--".concat(corners), className), children: options.map(function (option, index) { return (_jsx("option", { value: getOptionValue(option), children: getOptionLabel(option) }, index)); }) })));
28
+ var className = _a.className, options = _a.options, _b = _a.getOptionValue, getOptionValue = _b === void 0 ? identity : _b, _c = _a.getOptionLabel, getOptionLabel = _c === void 0 ? identity : _c, _d = _a.corners, corners = _d === void 0 ? "rounded" : _d, style = _a.style, innerStyle = _a.innerStyle, innerClassName = _a.innerClassName, disabled = _a.disabled, props = __rest(_a, ["className", "options", "getOptionValue", "getOptionLabel", "corners", "style", "innerStyle", "innerClassName", "disabled"]);
29
+ return (_jsxs("div", { className: classNames("ajui-select-container", disabled ? "ajui-select-disabled" : undefined, className), style: style, children: [_jsx("select", __assign({}, props, { ref: ref, className: classNames("ajui-select-base corners--".concat(corners), innerClassName), style: innerStyle, disabled: disabled, children: options.map(function (option, index) { return (_jsx("option", { value: getOptionValue(option), children: getOptionLabel(option) }, index)); }) })), _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 64 64", className: "ajui-select-triangle", "aria-hidden": "true", children: _jsx("path", { fill: "currentColor", d: "M 29.175781 50.824219 C 30.738281 52.386719 33.273438 52.386719 34.835938 50.824219 L 58.835938 26.824219 C 60.398438 25.261719 60.398438 22.726562 58.835938 21.164062 C 57.273438 19.601562 54.738281 19.601562 53.175781 21.164062 L 32 42.335938 L 10.824219 21.175781 C 9.261719 19.613281 6.726562 19.613281 5.164062 21.175781 C 3.601562 22.738281 3.601562 25.273438 5.164062 26.835938 L 29.164062 50.835938 Z M 29.175781 50.824219" }) })] }));
30
30
  };
31
31
  export default forwardRef(Select);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamjanicki/ui",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "description": "Basic UI components and hooks for React in TypeScript",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
package/style.css CHANGED
@@ -112,8 +112,8 @@ button:not([disabled]):focus-visible {
112
112
  outline: 3px solid var(--ajui-link-color);
113
113
  outline-offset: 0;
114
114
  }
115
- .ajui-input-default:focus-within,
116
- .ajui-select-base:focus-within {
115
+ .ajui-input-default:not([disabled]):focus-within,
116
+ .ajui-select-base:not([disabled]):focus-within {
117
117
  outline: 3px solid var(--ajui-focus-ring-color);
118
118
  outline-offset: 0;
119
119
  }
@@ -294,22 +294,39 @@ a {
294
294
  }
295
295
 
296
296
  /* Select */
297
+ .ajui-select-container {
298
+ position: relative;
299
+ }
300
+
301
+ .ajui-select-disabled {
302
+ opacity: var(--ajui-disabled-opacity);
303
+ cursor: not-allowed;
304
+ }
305
+
297
306
  .ajui-select-base {
298
307
  color: inherit;
299
308
  outline: 0px solid transparent;
300
309
  border: none;
301
310
  background-color: inherit;
302
- padding: 0.75rem 0.5rem;
311
+ padding: 0.75rem 1.75rem 0.75rem 0.5rem;
303
312
  font-size: 1rem;
304
313
  font-weight: 400;
305
314
  transition: outline var(--ajui-default-transition);
306
315
  outline: 0px solid transparent;
307
316
  box-shadow: inset 0 0 0 1px var(--ajui-select-border);
308
- }
309
-
310
- .ajui-select-base:disabled {
311
- opacity: var(--ajui-disabled-opacity);
312
- cursor: not-allowed;
317
+ appearance: none;
318
+ -webkit-appearance: none;
319
+ -moz-appearance: none;
320
+ }
321
+
322
+ .ajui-select-triangle {
323
+ --size: 0.75rem;
324
+ width: var(--size);
325
+ height: var(--size);
326
+ position: absolute;
327
+ top: 50%;
328
+ transform: translateY(-50%);
329
+ right: calc(var(--size) - 0.25rem);
313
330
  }
314
331
 
315
332
  /* Modal */
package/tmp ADDED
@@ -0,0 +1,95 @@
1
+ import React, { forwardRef } from "react";
2
+ import { classNames } from "../../utils/util";
3
+ import { CornerType } from "../../utils/types";
4
+
5
+ type Props = Omit<
6
+ React.DetailedHTMLProps<
7
+ React.SelectHTMLAttributes<HTMLSelectElement>,
8
+ HTMLSelectElement
9
+ >,
10
+ "aria-label"
11
+ > & {
12
+ /**
13
+ * Array of options to display in the select
14
+ */
15
+ options: string[];
16
+ /**
17
+ * Mapper function to get the value of the option
18
+ *
19
+ * @param option the option to get the value of
20
+ * @returns the value of the option
21
+ */
22
+ getOptionValue?: (option: string) => string;
23
+ /**
24
+ * Mapper function to get the label of the option
25
+ *
26
+ * @param option the option to get the label of
27
+ * @returns the label of the option
28
+ */
29
+ getOptionLabel?: (option: string) => string;
30
+ /**
31
+ * [Optional] The corner style of the select element.
32
+ * @default "rounded"
33
+ */
34
+ corners?: CornerType;
35
+ /**
36
+ * Name of the select for accessibility purposes
37
+ */
38
+ "aria-label": string;
39
+ /**
40
+ * [Optional] The styles to apply to the select element
41
+ */
42
+ innerStyle?: React.CSSProperties;
43
+ /**
44
+ * [Optional] The class name to apply to the select element
45
+ */
46
+ innerClassName?: string;
47
+ };
48
+
49
+ const identity = (x: string) => x;
50
+
51
+ const Select = (
52
+ {
53
+ className,
54
+ options,
55
+ getOptionValue = identity,
56
+ getOptionLabel = identity,
57
+ corners = "rounded",
58
+ style,
59
+ innerStyle,
60
+ innerClassName,
61
+ ...props
62
+ }: Props,
63
+ ref: React.Ref<HTMLSelectElement>
64
+ ) => (
65
+ <div className={classNames("ajui-select-container", className)} style={style}>
66
+ <select
67
+ {...props}
68
+ ref={ref}
69
+ className={classNames(
70
+ `ajui-select-base corners--${corners}`,
71
+ innerClassName
72
+ )}
73
+ style={innerStyle}
74
+ >
75
+ {options.map((option, index) => (
76
+ <option key={index} value={getOptionValue(option)}>
77
+ {getOptionLabel(option)}
78
+ </option>
79
+ ))}
80
+ </select>
81
+ <svg
82
+ xmlns="http://www.w3.org/2000/svg"
83
+ viewBox="0 0 64 64"
84
+ className="ajui-select-triangle"
85
+ aria-hidden="true"
86
+ >
87
+ <path
88
+ fill="currentColor"
89
+ d="M 29.175781 50.824219 C 30.738281 52.386719 33.273438 52.386719 34.835938 50.824219 L 58.835938 26.824219 C 60.398438 25.261719 60.398438 22.726562 58.835938 21.164062 C 57.273438 19.601562 54.738281 19.601562 53.175781 21.164062 L 32 42.335938 L 10.824219 21.175781 C 9.261719 19.613281 6.726562 19.613281 5.164062 21.175781 C 3.601562 22.738281 3.601562 25.273438 5.164062 26.835938 L 29.164062 50.835938 Z M 29.175781 50.824219"
90
+ />
91
+ </svg>
92
+ </div>
93
+ );
94
+
95
+ export default forwardRef(Select);