@basic-ui/material 1.0.0-alpha.32 → 1.0.0-alpha.34
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/build/cjs/index.js +92 -21
- package/build/cjs/index.js.map +1 -1
- package/build/esm/BottomSheet/BottomSheet.d.ts +1 -1
- package/build/esm/BottomSheet/BottomSheetSurface.d.ts +1 -1
- package/build/esm/Button/Button.d.ts +1 -1
- package/build/esm/CheckBox/CheckBox.d.ts +1 -1
- package/build/esm/Chip/ButtonChip.d.ts +1 -1
- package/build/esm/Chip/ChoiceChip.d.ts +1 -1
- package/build/esm/Combobox/Combobox.d.ts +7 -7
- package/build/esm/Dialog/Dialog.d.ts +1 -1
- package/build/esm/Dialog/DialogBackdrop.d.ts +1 -1
- package/build/esm/Dialog/DialogSurface.d.ts +1 -1
- package/build/esm/Menu/Menu.d.ts +5 -5
- package/build/esm/NavRail/NavRailItem.d.ts +3 -3
- package/build/esm/RadioButton/RadioGroup.d.ts +1 -1
- package/build/esm/Select/CustomContainerExample.d.ts +3 -0
- package/build/esm/Select/CustomContainerExample.js +59 -0
- package/build/esm/Select/CustomContainerExample.js.map +1 -0
- package/build/esm/Select/Select.d.ts +21 -7
- package/build/esm/Select/Select.js +52 -10
- package/build/esm/Select/Select.js.map +1 -1
- package/build/esm/Select/context.d.ts +5 -4
- package/build/esm/Select/context.js +2 -1
- package/build/esm/Select/context.js.map +1 -1
- package/build/esm/Select/defaultRender.d.ts +2 -1
- package/build/esm/Select/defaultRender.js +33 -4
- package/build/esm/Select/defaultRender.js.map +1 -1
- package/build/esm/SelectItem/SelectItem.d.ts +7 -3
- package/build/esm/SelectItem/SelectItem.js +14 -3
- package/build/esm/SelectItem/SelectItem.js.map +1 -1
- package/build/esm/Slider/Slider.d.ts +6 -6
- package/build/esm/Snackbar/Snackbar.d.ts +1 -1
- package/build/esm/Switch/Switch.d.ts +1 -1
- package/build/esm/Tab/Tab.d.ts +1 -1
- package/build/esm/Tab/TabList.d.ts +1 -1
- package/build/esm/Tab/TabPanel.d.ts +1 -1
- package/build/esm/TabIndicator/TabIndicator.d.ts +1 -1
- package/build/esm/Table/TableHead.d.ts +1 -1
- package/build/esm/TextField/FilledContainer.d.ts +4 -1
- package/build/esm/TextField/FilledContainer.js +5 -5
- package/build/esm/TextField/FilledContainer.js.map +1 -1
- package/build/esm/TextField/TextField.d.ts +1 -1
- package/build/esm/ThemeExplorer/ThemeBuilder.js +13 -2
- package/build/esm/ThemeExplorer/ThemeBuilder.js.map +1 -1
- package/build/esm/ThemeExplorer/ThemeColors.js +33 -15
- package/build/esm/ThemeExplorer/ThemeColors.js.map +1 -1
- package/build/esm/ThemeExplorer/components.d.ts +1 -1
- package/build/esm/ThemeExplorer/components.js +11 -13
- package/build/esm/ThemeExplorer/components.js.map +1 -1
- package/build/esm/ThemeExplorer/makeColorScheme.d.ts +32 -4
- package/build/esm/ThemeExplorer/makeColorScheme.js +41 -8
- package/build/esm/ThemeExplorer/makeColorScheme.js.map +1 -1
- package/build/esm/Tooltip/Tooltip.d.ts +1 -1
- package/build/esm/theme/theme.js +2 -2
- package/build/esm/theme/theme.js.map +1 -1
- package/build/tsconfig-build.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/Select/CustomContainerExample.tsx +59 -0
- package/src/Select/Select.story.tsx +68 -69
- package/src/Select/Select.tsx +99 -27
- package/src/Select/SelectMultiple.story.tsx +215 -0
- package/src/Select/context.ts +5 -3
- package/src/Select/defaultRender.tsx +49 -0
- package/src/SelectItem/SelectItem.tsx +68 -46
- package/src/TextField/FilledContainer.tsx +6 -5
- package/src/ThemeExplorer/ThemeBuilder.tsx +16 -5
- package/src/ThemeExplorer/ThemeColors.tsx +39 -15
- package/src/ThemeExplorer/components.tsx +12 -20
- package/src/ThemeExplorer/makeColorScheme.tsx +39 -6
- package/src/theme/theme.ts +2 -2
- package/src/Select/defaultRender.ts +0 -19
package/build/cjs/index.js
CHANGED
|
@@ -502,8 +502,8 @@ const theme = {
|
|
|
502
502
|
styles: {
|
|
503
503
|
root: {
|
|
504
504
|
body: {
|
|
505
|
-
fontFamily: '
|
|
506
|
-
fontWeight: '
|
|
505
|
+
fontFamily: 'body1',
|
|
506
|
+
fontWeight: 'body1',
|
|
507
507
|
lineHeight: 'body',
|
|
508
508
|
backgroundColor: 'surface',
|
|
509
509
|
color: 'on.surface'
|
|
@@ -2193,9 +2193,9 @@ const LineRipple = /*#__PURE__*/react$1.forwardRef(function LineRipple(props, fo
|
|
|
2193
2193
|
});
|
|
2194
2194
|
});
|
|
2195
2195
|
|
|
2196
|
-
const makeSelector$1 = state => `input:${state} ~ &,` + `select:${state} ~ &,` + `button:${state} ~ &,` + `textarea:${state} ~ &`;
|
|
2196
|
+
const makeSelector$1 = state => `input:${state} ~ &,` + `select:${state} ~ &,` + `button:${state} ~ &,` + `textarea:${state} ~ &,` + `[role="button"]:${state} ~ &`;
|
|
2197
2197
|
|
|
2198
|
-
const
|
|
2198
|
+
const FilledContainerOverlay = props => {
|
|
2199
2199
|
const {
|
|
2200
2200
|
forceActive
|
|
2201
2201
|
} = props;
|
|
@@ -2228,7 +2228,7 @@ const Overlay = props => {
|
|
|
2228
2228
|
});
|
|
2229
2229
|
};
|
|
2230
2230
|
|
|
2231
|
-
const
|
|
2231
|
+
const FilledContainerBorderBottom = () => /*#__PURE__*/jsxRuntime.jsx(Box, {
|
|
2232
2232
|
__css: {
|
|
2233
2233
|
position: 'absolute',
|
|
2234
2234
|
bottom: 0,
|
|
@@ -2298,9 +2298,9 @@ const FilledContainer = /*#__PURE__*/react$1.forwardRef(function FilledContainer
|
|
|
2298
2298
|
htmlFor: inputId,
|
|
2299
2299
|
color: active || error ? color : undefined,
|
|
2300
2300
|
children: label
|
|
2301
|
-
}), children, /*#__PURE__*/jsxRuntime.jsx(
|
|
2301
|
+
}), children, /*#__PURE__*/jsxRuntime.jsx(FilledContainerOverlay, {
|
|
2302
2302
|
forceActive: active
|
|
2303
|
-
}), /*#__PURE__*/jsxRuntime.jsx(
|
|
2303
|
+
}), /*#__PURE__*/jsxRuntime.jsx(FilledContainerBorderBottom, {}), /*#__PURE__*/jsxRuntime.jsx(LineRipple, {
|
|
2304
2304
|
active: active || error,
|
|
2305
2305
|
color: color
|
|
2306
2306
|
})]
|
|
@@ -4143,7 +4143,8 @@ const SelectButton = /*#__PURE__*/react$1.forwardRef(({
|
|
|
4143
4143
|
const selectContext = /*#__PURE__*/react$1.createContext({
|
|
4144
4144
|
native: false,
|
|
4145
4145
|
onSelect: () => {// noop
|
|
4146
|
-
}
|
|
4146
|
+
},
|
|
4147
|
+
multiple: false
|
|
4147
4148
|
});
|
|
4148
4149
|
const {
|
|
4149
4150
|
Provider: SelectProvider
|
|
@@ -4186,16 +4187,41 @@ const makeDefaultRender = children => val => {
|
|
|
4186
4187
|
for (let i = 0; i < allChildren.length; i++) {
|
|
4187
4188
|
const child = allChildren[i];
|
|
4188
4189
|
|
|
4189
|
-
if ( /*#__PURE__*/react$1.isValidElement(child)) {
|
|
4190
|
-
|
|
4191
|
-
return child.props.children;
|
|
4192
|
-
}
|
|
4190
|
+
if ( /*#__PURE__*/react$1.isValidElement(child) && String(child.props.value) === val) {
|
|
4191
|
+
return child.props.children;
|
|
4193
4192
|
}
|
|
4194
4193
|
}
|
|
4195
4194
|
}
|
|
4196
4195
|
|
|
4197
4196
|
return val || undefined;
|
|
4198
4197
|
};
|
|
4198
|
+
const makeDefaultMultipleRender = children => val => {
|
|
4199
|
+
const ret = [];
|
|
4200
|
+
|
|
4201
|
+
if (children && val !== undefined && val.length > 0) {
|
|
4202
|
+
const set = new Set(val);
|
|
4203
|
+
const allChildren = react$1.Children.toArray(children);
|
|
4204
|
+
|
|
4205
|
+
for (let i = 0; i < allChildren.length; i++) {
|
|
4206
|
+
const child = allChildren[i];
|
|
4207
|
+
|
|
4208
|
+
if ( /*#__PURE__*/react$1.isValidElement(child) && set.has(String(child.props.value))) {
|
|
4209
|
+
ret.push(child.props.children);
|
|
4210
|
+
}
|
|
4211
|
+
}
|
|
4212
|
+
}
|
|
4213
|
+
|
|
4214
|
+
return /*#__PURE__*/jsxRuntime.jsx(Box, {
|
|
4215
|
+
as: "span",
|
|
4216
|
+
sx: {
|
|
4217
|
+
maxWidth: '100%',
|
|
4218
|
+
overflow: 'hidden',
|
|
4219
|
+
textOverflow: 'ellipsis',
|
|
4220
|
+
whiteSpace: 'nowrap'
|
|
4221
|
+
},
|
|
4222
|
+
children: ret.join(', ')
|
|
4223
|
+
});
|
|
4224
|
+
};
|
|
4199
4225
|
|
|
4200
4226
|
const componentMap = {
|
|
4201
4227
|
outlined: OutlinedContainer,
|
|
@@ -4208,7 +4234,7 @@ const Select = /*#__PURE__*/react$1.forwardRef(function Select(props, forwardedR
|
|
|
4208
4234
|
variant = 'outlined',
|
|
4209
4235
|
color = 'primary',
|
|
4210
4236
|
value: valueProp,
|
|
4211
|
-
defaultValue = '',
|
|
4237
|
+
defaultValue = props.multiple ? [] : '',
|
|
4212
4238
|
disabled,
|
|
4213
4239
|
error = false,
|
|
4214
4240
|
label = null,
|
|
@@ -4218,20 +4244,27 @@ const Select = /*#__PURE__*/react$1.forwardRef(function Select(props, forwardedR
|
|
|
4218
4244
|
onFocus,
|
|
4219
4245
|
onBlur,
|
|
4220
4246
|
native = false,
|
|
4247
|
+
multiple = false,
|
|
4221
4248
|
children,
|
|
4222
4249
|
renderValue: renderValueProp,
|
|
4223
4250
|
leadingIcon = null,
|
|
4251
|
+
CustomContainer: overwrittenContainer,
|
|
4224
4252
|
...otherProps
|
|
4225
4253
|
} = props;
|
|
4226
4254
|
const [value, onChange] = core.useControlledState(valueProp, onChangeProp, defaultValue, setState => (e, v) => {
|
|
4227
4255
|
setState(v);
|
|
4228
4256
|
});
|
|
4257
|
+
|
|
4258
|
+
if (multiple && !Array.isArray(value)) {
|
|
4259
|
+
console.warn('Warning: The `value` prop supplied to <Select> must be an array if `multiple` is true.');
|
|
4260
|
+
}
|
|
4261
|
+
|
|
4229
4262
|
const [hasFocus, setHasFocus] = react$1.useState(false);
|
|
4230
4263
|
const buttonRef = react$1.useRef();
|
|
4231
4264
|
const [open, setOpen] = react$1.useState(false);
|
|
4232
4265
|
const fallbackId = react$1.useId();
|
|
4233
4266
|
const theme = useTheme();
|
|
4234
|
-
const Container = componentMap[variant] || OutlinedContainer;
|
|
4267
|
+
const Container = overwrittenContainer || componentMap[variant] || OutlinedContainer;
|
|
4235
4268
|
|
|
4236
4269
|
const handleFocus = () => {
|
|
4237
4270
|
setHasFocus(true);
|
|
@@ -4246,7 +4279,23 @@ const Select = /*#__PURE__*/react$1.forwardRef(function Select(props, forwardedR
|
|
|
4246
4279
|
};
|
|
4247
4280
|
|
|
4248
4281
|
const handleOnChange = e => {
|
|
4249
|
-
|
|
4282
|
+
const selectedValue = native ? e.target.value : e.currentTarget.dataset.value;
|
|
4283
|
+
|
|
4284
|
+
if (multiple && Array.isArray(value)) {
|
|
4285
|
+
if (value.find(c => c === selectedValue)) {
|
|
4286
|
+
onChange && onChange(e, value.filter(c => c !== selectedValue));
|
|
4287
|
+
} else {
|
|
4288
|
+
onChange && onChange(e, [...value, selectedValue]);
|
|
4289
|
+
}
|
|
4290
|
+
|
|
4291
|
+
const isMac = Boolean(/mac os|ios/i.test(navigator.userAgent));
|
|
4292
|
+
|
|
4293
|
+
if (e.key === ' ' || isMac && e.metaKey || !isMac && e.ctrlKey) {
|
|
4294
|
+
e.preventDefault();
|
|
4295
|
+
}
|
|
4296
|
+
} else {
|
|
4297
|
+
onChange && onChange(e, selectedValue);
|
|
4298
|
+
}
|
|
4250
4299
|
};
|
|
4251
4300
|
|
|
4252
4301
|
const hasError = Boolean(error);
|
|
@@ -4254,8 +4303,18 @@ const Select = /*#__PURE__*/react$1.forwardRef(function Select(props, forwardedR
|
|
|
4254
4303
|
const id = idProp || fallbackId;
|
|
4255
4304
|
const inputId = `${id}-text-field`;
|
|
4256
4305
|
const helperTextId = helperText ? `${id}-helper-text` : undefined;
|
|
4257
|
-
const
|
|
4258
|
-
const
|
|
4306
|
+
const defaultRenderFn = react$1.useMemo(() => multiple ? makeDefaultMultipleRender(children) : makeDefaultRender(children), [children, multiple]);
|
|
4307
|
+
const renderValue = renderValueProp || defaultRenderFn;
|
|
4308
|
+
|
|
4309
|
+
function hasAnySelected() {
|
|
4310
|
+
if (multiple) {
|
|
4311
|
+
return value.length > 0;
|
|
4312
|
+
} else {
|
|
4313
|
+
return value !== '';
|
|
4314
|
+
}
|
|
4315
|
+
}
|
|
4316
|
+
|
|
4317
|
+
const labelIsFloating = hasFocus || open || hasAnySelected();
|
|
4259
4318
|
const Comp = native ? Select$1 : SelectButton;
|
|
4260
4319
|
react$1.useEffect(() => {
|
|
4261
4320
|
// right after mounting, if the default value in the select element
|
|
@@ -4270,7 +4329,8 @@ const Select = /*#__PURE__*/react$1.forwardRef(function Select(props, forwardedR
|
|
|
4270
4329
|
value: {
|
|
4271
4330
|
native,
|
|
4272
4331
|
onSelect: handleOnChange,
|
|
4273
|
-
value
|
|
4332
|
+
value,
|
|
4333
|
+
multiple
|
|
4274
4334
|
},
|
|
4275
4335
|
children: /*#__PURE__*/jsxRuntime.jsxs(Box, {
|
|
4276
4336
|
display: "inline-flex",
|
|
@@ -4287,7 +4347,7 @@ const Select = /*#__PURE__*/react$1.forwardRef(function Select(props, forwardedR
|
|
|
4287
4347
|
labelIsFloating: labelIsFloating,
|
|
4288
4348
|
inputId: inputId,
|
|
4289
4349
|
hasFocus: hasFocus,
|
|
4290
|
-
disabled: disabled,
|
|
4350
|
+
disabled: disabled ?? false,
|
|
4291
4351
|
forceActive: open,
|
|
4292
4352
|
error: hasError,
|
|
4293
4353
|
leadingIcon: Boolean(leadingIcon),
|
|
@@ -4313,6 +4373,7 @@ const Select = /*#__PURE__*/react$1.forwardRef(function Select(props, forwardedR
|
|
|
4313
4373
|
hasLabel: !!label,
|
|
4314
4374
|
leadingIcon: Boolean(leadingIcon),
|
|
4315
4375
|
name: native ? name : undefined,
|
|
4376
|
+
multiple: native ? multiple : undefined,
|
|
4316
4377
|
trailingIcon: true,
|
|
4317
4378
|
...otherProps,
|
|
4318
4379
|
children: native ? children : renderValue(value)
|
|
@@ -4361,12 +4422,14 @@ const SelectItem = /*#__PURE__*/react$1.forwardRef(function SelectItem(props, fo
|
|
|
4361
4422
|
children,
|
|
4362
4423
|
value: valueProp,
|
|
4363
4424
|
disabled,
|
|
4425
|
+
onKeyDown,
|
|
4364
4426
|
...otherProps
|
|
4365
4427
|
} = props;
|
|
4366
4428
|
const {
|
|
4367
4429
|
native,
|
|
4368
4430
|
onSelect,
|
|
4369
|
-
value: selectedValue
|
|
4431
|
+
value: selectedValue,
|
|
4432
|
+
multiple
|
|
4370
4433
|
} = useSelectContext();
|
|
4371
4434
|
const value = valueProp !== undefined && valueProp !== null ? String(valueProp) : children;
|
|
4372
4435
|
|
|
@@ -4384,7 +4447,14 @@ const SelectItem = /*#__PURE__*/react$1.forwardRef(function SelectItem(props, fo
|
|
|
4384
4447
|
return null;
|
|
4385
4448
|
}
|
|
4386
4449
|
|
|
4387
|
-
|
|
4450
|
+
let selected = false;
|
|
4451
|
+
|
|
4452
|
+
if (multiple && Array.isArray(selectedValue)) {
|
|
4453
|
+
selected = Boolean(selectedValue.find(v => v === value));
|
|
4454
|
+
} else {
|
|
4455
|
+
selected = value === String(selectedValue);
|
|
4456
|
+
}
|
|
4457
|
+
|
|
4388
4458
|
return /*#__PURE__*/jsxRuntime.jsx(Comp, {
|
|
4389
4459
|
as: MenuItem,
|
|
4390
4460
|
onSelect: core.wrapEvent(onSelectProp, onSelect),
|
|
@@ -5831,6 +5901,7 @@ exports.EASING_STANDARD = EASING_STANDARD;
|
|
|
5831
5901
|
exports.EASING_STANDARD_ACCELERATE = EASING_STANDARD_ACCELERATE;
|
|
5832
5902
|
exports.EASING_STANDARD_DECELERATE = EASING_STANDARD_DECELERATE;
|
|
5833
5903
|
exports.FilledContainer = FilledContainer;
|
|
5904
|
+
exports.FilledContainerOverlay = FilledContainerOverlay;
|
|
5834
5905
|
exports.FloatingLabel = FloatingLabel;
|
|
5835
5906
|
exports.HelperText = HelperText;
|
|
5836
5907
|
exports.LineRipple = LineRipple;
|