@spark-web/select 1.0.13 → 3.0.0-rc.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/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # @spark-web/select
2
2
 
3
+ ## 3.0.0-rc.0
4
+
5
+ ### Major Changes
6
+
7
+ - rc versio
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies []:
12
+ - @spark-web/text-input@4.0.0-rc.0
13
+ - @spark-web/field@4.0.0-rc.0
14
+ - @spark-web/theme@4.0.0-rc.0
15
+ - @spark-web/icon@2.0.0-rc.0
16
+ - @spark-web/box@2.0.0-rc.0
17
+
18
+ ## 2.0.0
19
+
20
+ ### Minor Changes
21
+
22
+ - [#382](https://github.com/brighte-labs/spark-web/pull/382)
23
+ [`955bf5d`](https://github.com/brighte-labs/spark-web/commit/955bf5d7698bfdf45e7f317aa3e726c81d3444c0)
24
+ Thanks [@dilipt-brighte](https://github.com/dilipt-brighte)! - Updates React
25
+ version to latest (18.2.0)
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies
30
+ [[`955bf5d`](https://github.com/brighte-labs/spark-web/commit/955bf5d7698bfdf45e7f317aa3e726c81d3444c0)]:
31
+ - @spark-web/box@1.2.0
32
+ - @spark-web/field@3.1.0
33
+ - @spark-web/icon@1.3.0
34
+ - @spark-web/text-input@3.0.0
35
+ - @spark-web/theme@3.2.0
36
+
3
37
  ## 1.0.13
4
38
 
5
39
  ### Patch Changes
@@ -1 +1,2 @@
1
- export * from "./declarations/src/index";
1
+ export * from "../src/index";
2
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3Bhcmstd2ViLXNlbGVjdC5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9
@@ -1,7 +1,16 @@
1
- 'use strict';
1
+ "use strict";
2
+ // this file might look strange and you might be wondering what it's for
3
+ // it's lets you import your source files by importing this entrypoint
4
+ // as you would import it if it was built with preconstruct build
5
+ // this file is slightly different to some others though
6
+ // it has a require hook which compiles your code with Babel
7
+ // this means that you don't have to set up @babel/register or anything like that
8
+ // but you can still require this module and it'll be compiled
2
9
 
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./spark-web-select.cjs.prod.js");
5
- } else {
6
- module.exports = require("./spark-web-select.cjs.dev.js");
7
- }
10
+ // this bit of code imports the require hook and registers it
11
+ let unregister = require("../../../node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../..", "..");
12
+
13
+ // this re-exports the source file
14
+ module.exports = require("../src/index.ts");
15
+
16
+ unregister();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spark-web/select",
3
- "version": "1.0.13",
3
+ "version": "3.0.0-rc.0",
4
4
  "homepage": "https://github.com/brighte-labs/spark-web#readme",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,21 +15,21 @@
15
15
  "README.md"
16
16
  ],
17
17
  "dependencies": {
18
- "@babel/runtime": "^7.19.0",
19
- "@emotion/css": "^11.9.0",
20
- "@spark-web/box": "^1.1.0",
21
- "@spark-web/icon": "^1.2.2",
22
- "@spark-web/text-input": "^2.0.4",
23
- "@spark-web/theme": "^3.1.0"
18
+ "@babel/runtime": "^7.25.0",
19
+ "@emotion/react": "^11.13.5",
20
+ "@spark-web/box": "^2.0.0-rc.0",
21
+ "@spark-web/icon": "^2.0.0-rc.0",
22
+ "@spark-web/text-input": "^4.0.0-rc.0",
23
+ "@spark-web/theme": "^4.0.0-rc.0"
24
24
  },
25
25
  "devDependencies": {
26
- "@spark-web/field": "^3.0.6",
27
- "@spark-web/utils": "^1.2.3",
28
- "@types/react": "^17.0.12",
29
- "react": "^17.0.2"
26
+ "@spark-web/field": "^4.0.0-rc.0",
27
+ "@spark-web/utils": "^2.0.0-rc.0",
28
+ "@types/react": "^18.2.0",
29
+ "react": "^18.2.0"
30
30
  },
31
31
  "peerDependencies": {
32
- "@spark-web/field": "^3.0.6",
32
+ "@spark-web/field": "^4.0.0-rc.0",
33
33
  "react": ">=17.0.2"
34
34
  },
35
35
  "engines": {
@@ -1,2 +0,0 @@
1
- export { Select } from './select';
2
- export type { SelectProps } from './select';
@@ -1,34 +0,0 @@
1
- import type { DataAttributeMap } from '@spark-web/utils/internal';
2
- import type { SelectHTMLAttributes } from 'react';
3
- export declare type Option = {
4
- /** Whether or not the option is disabled. */
5
- disabled?: boolean;
6
- /** Label for the option. */
7
- label: string;
8
- /** Value of the option. */
9
- value: string | number;
10
- };
11
- export declare type Group = {
12
- /** List of options for the group. */
13
- options: Array<Option>;
14
- /** Label for the group. */
15
- label: string;
16
- };
17
- export declare type OptionsOrGroups = Array<Option | Group>;
18
- export declare type NativeSelectProps = Pick<SelectHTMLAttributes<HTMLSelectElement>, 'defaultValue' | 'name' | 'onBlur' | 'onChange' | 'required' | 'value'>;
19
- export declare type SelectProps = NativeSelectProps & {
20
- /** Sets data attributes for the element. */
21
- data?: DataAttributeMap;
22
- /** The values that can be selected by the input. */
23
- options: OptionsOrGroups;
24
- /** Placeholder text for when the input does not have an initial value. */
25
- placeholder?: string;
26
- };
27
- export declare const Select: import("react").ForwardRefExoticComponent<NativeSelectProps & {
28
- /** Sets data attributes for the element. */
29
- data?: DataAttributeMap | undefined;
30
- /** The values that can be selected by the input. */
31
- options: OptionsOrGroups;
32
- /** Placeholder text for when the input does not have an initial value. */
33
- placeholder?: string | undefined;
34
- } & import("react").RefAttributes<HTMLSelectElement>>;
@@ -1,118 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
6
- var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
7
- var css = require('@emotion/css');
8
- var box = require('@spark-web/box');
9
- var field = require('@spark-web/field');
10
- var icon = require('@spark-web/icon');
11
- var textInput = require('@spark-web/text-input');
12
- var theme = require('@spark-web/theme');
13
- var react = require('react');
14
- var jsxRuntime = require('react/jsx-runtime');
15
-
16
- var Select = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
17
- var data = _ref.data,
18
- defaultValue = _ref.defaultValue,
19
- name = _ref.name,
20
- onBlur = _ref.onBlur,
21
- onChange = _ref.onChange,
22
- optionsOrGroups = _ref.options,
23
- placeholder = _ref.placeholder,
24
- required = _ref.required,
25
- value = _ref.value;
26
-
27
- var _useFieldContext = field.useFieldContext(),
28
- _useFieldContext2 = _slicedToArray(_useFieldContext, 2),
29
- _useFieldContext2$ = _useFieldContext2[0],
30
- disabled = _useFieldContext2$.disabled,
31
- invalid = _useFieldContext2$.invalid,
32
- a11yProps = _useFieldContext2[1];
33
-
34
- var _useSelectStyles = useSelectStyles({
35
- disabled: disabled,
36
- invalid: invalid
37
- }),
38
- _useSelectStyles2 = _slicedToArray(_useSelectStyles, 2),
39
- boxProps = _useSelectStyles2[0],
40
- inputStyles = _useSelectStyles2[1];
41
-
42
- var mapOptions = react.useCallback(function (opt) {
43
- return /*#__PURE__*/jsxRuntime.jsx("option", {
44
- value: opt.value,
45
- disabled: opt.disabled,
46
- children: opt.label
47
- }, opt.value);
48
- }, []);
49
- return /*#__PURE__*/jsxRuntime.jsxs(textInput.InputContainer, {
50
- children: [/*#__PURE__*/jsxRuntime.jsx(Indicator, {}), /*#__PURE__*/jsxRuntime.jsxs(box.Box, _objectSpread(_objectSpread(_objectSpread({}, boxProps), a11yProps), {}, {
51
- as: "select",
52
- className: css.css(inputStyles),
53
- data: data,
54
- defaultValue: (defaultValue !== null && defaultValue !== void 0 ? defaultValue : placeholder) ? '' : undefined,
55
- disabled: disabled,
56
- name: name,
57
- onBlur: onBlur,
58
- onChange: onChange,
59
- ref: forwardedRef,
60
- required: required,
61
- value: value,
62
- width: "full",
63
- children: [!value || placeholder ? /*#__PURE__*/jsxRuntime.jsx("option", {
64
- value: "",
65
- disabled: true,
66
- children: placeholder
67
- }) : null, optionsOrGroups.map(function (optionOrGroup) {
68
- if ('options' in optionOrGroup) {
69
- return /*#__PURE__*/jsxRuntime.jsx("optgroup", {
70
- label: optionOrGroup.label,
71
- children: optionOrGroup.options.map(function (option) {
72
- return mapOptions(option);
73
- })
74
- }, optionOrGroup.label);
75
- }
76
-
77
- return mapOptions(optionOrGroup);
78
- })]
79
- }))]
80
- });
81
- });
82
- Select.displayName = 'Select';
83
-
84
- var Indicator = function Indicator() {
85
- return /*#__PURE__*/jsxRuntime.jsx(box.Box, {
86
- position: "absolute",
87
- top: 0,
88
- bottom: 0,
89
- right: 0,
90
- display: "flex",
91
- alignItems: "center",
92
- padding: "medium",
93
- className: css.css({
94
- pointerEvents: 'none'
95
- }),
96
- children: /*#__PURE__*/jsxRuntime.jsx(icon.ChevronDownIcon, {
97
- size: "xxsmall",
98
- tone: "placeholder"
99
- })
100
- });
101
- };
102
-
103
- function useSelectStyles(props) {
104
- var _useInputStyles = textInput.useInputStyles(props),
105
- _useInputStyles2 = _slicedToArray(_useInputStyles, 2),
106
- boxProps = _useInputStyles2[0],
107
- inputStyles = _useInputStyles2[1];
108
-
109
- var theme$1 = theme.useTheme();
110
- return [boxProps, _objectSpread(_objectSpread({}, inputStyles), {}, {
111
- // Prevent text going underneath the chevron icon
112
- paddingRight: theme$1.sizing.xxsmall + // size of chevron icon
113
- theme$1.spacing.medium * 2 // paddingX value
114
-
115
- })];
116
- }
117
-
118
- exports.Select = Select;
@@ -1,118 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
6
- var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
7
- var css = require('@emotion/css');
8
- var box = require('@spark-web/box');
9
- var field = require('@spark-web/field');
10
- var icon = require('@spark-web/icon');
11
- var textInput = require('@spark-web/text-input');
12
- var theme = require('@spark-web/theme');
13
- var react = require('react');
14
- var jsxRuntime = require('react/jsx-runtime');
15
-
16
- var Select = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
17
- var data = _ref.data,
18
- defaultValue = _ref.defaultValue,
19
- name = _ref.name,
20
- onBlur = _ref.onBlur,
21
- onChange = _ref.onChange,
22
- optionsOrGroups = _ref.options,
23
- placeholder = _ref.placeholder,
24
- required = _ref.required,
25
- value = _ref.value;
26
-
27
- var _useFieldContext = field.useFieldContext(),
28
- _useFieldContext2 = _slicedToArray(_useFieldContext, 2),
29
- _useFieldContext2$ = _useFieldContext2[0],
30
- disabled = _useFieldContext2$.disabled,
31
- invalid = _useFieldContext2$.invalid,
32
- a11yProps = _useFieldContext2[1];
33
-
34
- var _useSelectStyles = useSelectStyles({
35
- disabled: disabled,
36
- invalid: invalid
37
- }),
38
- _useSelectStyles2 = _slicedToArray(_useSelectStyles, 2),
39
- boxProps = _useSelectStyles2[0],
40
- inputStyles = _useSelectStyles2[1];
41
-
42
- var mapOptions = react.useCallback(function (opt) {
43
- return /*#__PURE__*/jsxRuntime.jsx("option", {
44
- value: opt.value,
45
- disabled: opt.disabled,
46
- children: opt.label
47
- }, opt.value);
48
- }, []);
49
- return /*#__PURE__*/jsxRuntime.jsxs(textInput.InputContainer, {
50
- children: [/*#__PURE__*/jsxRuntime.jsx(Indicator, {}), /*#__PURE__*/jsxRuntime.jsxs(box.Box, _objectSpread(_objectSpread(_objectSpread({}, boxProps), a11yProps), {}, {
51
- as: "select",
52
- className: css.css(inputStyles),
53
- data: data,
54
- defaultValue: (defaultValue !== null && defaultValue !== void 0 ? defaultValue : placeholder) ? '' : undefined,
55
- disabled: disabled,
56
- name: name,
57
- onBlur: onBlur,
58
- onChange: onChange,
59
- ref: forwardedRef,
60
- required: required,
61
- value: value,
62
- width: "full",
63
- children: [!value || placeholder ? /*#__PURE__*/jsxRuntime.jsx("option", {
64
- value: "",
65
- disabled: true,
66
- children: placeholder
67
- }) : null, optionsOrGroups.map(function (optionOrGroup) {
68
- if ('options' in optionOrGroup) {
69
- return /*#__PURE__*/jsxRuntime.jsx("optgroup", {
70
- label: optionOrGroup.label,
71
- children: optionOrGroup.options.map(function (option) {
72
- return mapOptions(option);
73
- })
74
- }, optionOrGroup.label);
75
- }
76
-
77
- return mapOptions(optionOrGroup);
78
- })]
79
- }))]
80
- });
81
- });
82
- Select.displayName = 'Select';
83
-
84
- var Indicator = function Indicator() {
85
- return /*#__PURE__*/jsxRuntime.jsx(box.Box, {
86
- position: "absolute",
87
- top: 0,
88
- bottom: 0,
89
- right: 0,
90
- display: "flex",
91
- alignItems: "center",
92
- padding: "medium",
93
- className: css.css({
94
- pointerEvents: 'none'
95
- }),
96
- children: /*#__PURE__*/jsxRuntime.jsx(icon.ChevronDownIcon, {
97
- size: "xxsmall",
98
- tone: "placeholder"
99
- })
100
- });
101
- };
102
-
103
- function useSelectStyles(props) {
104
- var _useInputStyles = textInput.useInputStyles(props),
105
- _useInputStyles2 = _slicedToArray(_useInputStyles, 2),
106
- boxProps = _useInputStyles2[0],
107
- inputStyles = _useInputStyles2[1];
108
-
109
- var theme$1 = theme.useTheme();
110
- return [boxProps, _objectSpread(_objectSpread({}, inputStyles), {}, {
111
- // Prevent text going underneath the chevron icon
112
- paddingRight: theme$1.sizing.xxsmall + // size of chevron icon
113
- theme$1.spacing.medium * 2 // paddingX value
114
-
115
- })];
116
- }
117
-
118
- exports.Select = Select;
@@ -1,114 +0,0 @@
1
- import _objectSpread from '@babel/runtime/helpers/esm/objectSpread2';
2
- import _slicedToArray from '@babel/runtime/helpers/esm/slicedToArray';
3
- import { css } from '@emotion/css';
4
- import { Box } from '@spark-web/box';
5
- import { useFieldContext } from '@spark-web/field';
6
- import { ChevronDownIcon } from '@spark-web/icon';
7
- import { InputContainer, useInputStyles } from '@spark-web/text-input';
8
- import { useTheme } from '@spark-web/theme';
9
- import { forwardRef, useCallback } from 'react';
10
- import { jsx, jsxs } from 'react/jsx-runtime';
11
-
12
- var Select = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
13
- var data = _ref.data,
14
- defaultValue = _ref.defaultValue,
15
- name = _ref.name,
16
- onBlur = _ref.onBlur,
17
- onChange = _ref.onChange,
18
- optionsOrGroups = _ref.options,
19
- placeholder = _ref.placeholder,
20
- required = _ref.required,
21
- value = _ref.value;
22
-
23
- var _useFieldContext = useFieldContext(),
24
- _useFieldContext2 = _slicedToArray(_useFieldContext, 2),
25
- _useFieldContext2$ = _useFieldContext2[0],
26
- disabled = _useFieldContext2$.disabled,
27
- invalid = _useFieldContext2$.invalid,
28
- a11yProps = _useFieldContext2[1];
29
-
30
- var _useSelectStyles = useSelectStyles({
31
- disabled: disabled,
32
- invalid: invalid
33
- }),
34
- _useSelectStyles2 = _slicedToArray(_useSelectStyles, 2),
35
- boxProps = _useSelectStyles2[0],
36
- inputStyles = _useSelectStyles2[1];
37
-
38
- var mapOptions = useCallback(function (opt) {
39
- return /*#__PURE__*/jsx("option", {
40
- value: opt.value,
41
- disabled: opt.disabled,
42
- children: opt.label
43
- }, opt.value);
44
- }, []);
45
- return /*#__PURE__*/jsxs(InputContainer, {
46
- children: [/*#__PURE__*/jsx(Indicator, {}), /*#__PURE__*/jsxs(Box, _objectSpread(_objectSpread(_objectSpread({}, boxProps), a11yProps), {}, {
47
- as: "select",
48
- className: css(inputStyles),
49
- data: data,
50
- defaultValue: (defaultValue !== null && defaultValue !== void 0 ? defaultValue : placeholder) ? '' : undefined,
51
- disabled: disabled,
52
- name: name,
53
- onBlur: onBlur,
54
- onChange: onChange,
55
- ref: forwardedRef,
56
- required: required,
57
- value: value,
58
- width: "full",
59
- children: [!value || placeholder ? /*#__PURE__*/jsx("option", {
60
- value: "",
61
- disabled: true,
62
- children: placeholder
63
- }) : null, optionsOrGroups.map(function (optionOrGroup) {
64
- if ('options' in optionOrGroup) {
65
- return /*#__PURE__*/jsx("optgroup", {
66
- label: optionOrGroup.label,
67
- children: optionOrGroup.options.map(function (option) {
68
- return mapOptions(option);
69
- })
70
- }, optionOrGroup.label);
71
- }
72
-
73
- return mapOptions(optionOrGroup);
74
- })]
75
- }))]
76
- });
77
- });
78
- Select.displayName = 'Select';
79
-
80
- var Indicator = function Indicator() {
81
- return /*#__PURE__*/jsx(Box, {
82
- position: "absolute",
83
- top: 0,
84
- bottom: 0,
85
- right: 0,
86
- display: "flex",
87
- alignItems: "center",
88
- padding: "medium",
89
- className: css({
90
- pointerEvents: 'none'
91
- }),
92
- children: /*#__PURE__*/jsx(ChevronDownIcon, {
93
- size: "xxsmall",
94
- tone: "placeholder"
95
- })
96
- });
97
- };
98
-
99
- function useSelectStyles(props) {
100
- var _useInputStyles = useInputStyles(props),
101
- _useInputStyles2 = _slicedToArray(_useInputStyles, 2),
102
- boxProps = _useInputStyles2[0],
103
- inputStyles = _useInputStyles2[1];
104
-
105
- var theme = useTheme();
106
- return [boxProps, _objectSpread(_objectSpread({}, inputStyles), {}, {
107
- // Prevent text going underneath the chevron icon
108
- paddingRight: theme.sizing.xxsmall + // size of chevron icon
109
- theme.spacing.medium * 2 // paddingX value
110
-
111
- })];
112
- }
113
-
114
- export { Select };