@basic-ui/material 1.0.0-alpha.29 → 1.0.0-alpha.30
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 +85 -65
- package/build/cjs/index.js.map +1 -1
- package/build/esm/CheckBox/CheckBox.d.ts +1 -1
- package/build/esm/Chip/ButtonChip.d.ts +1 -1
- package/build/esm/SelectionControl/SelectionControlLabel.d.ts +1 -1
- package/build/esm/SelectionControl/SelectionControlLabel.js +2 -1
- package/build/esm/SelectionControl/SelectionControlLabel.js.map +1 -1
- package/build/esm/Switch/Switch.d.ts +2 -1
- package/build/esm/Switch/Switch.js +59 -46
- package/build/esm/Switch/Switch.js.map +1 -1
- package/build/esm/Switch/styledComponents.js +19 -20
- package/build/esm/Switch/styledComponents.js.map +1 -1
- package/build/esm/Table/TableHead.d.ts +1 -1
- package/build/tsconfig-build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/SelectionControl/SelectionControlLabel.tsx +1 -0
- package/src/Switch/Switch.story.tsx +14 -0
- package/src/Switch/Switch.tsx +75 -46
- package/src/Switch/styledComponents.tsx +26 -25
package/build/cjs/index.js
CHANGED
|
@@ -3104,6 +3104,7 @@ const SelectionControlLabel = /*#__PURE__*/react$1.forwardRef(function Selection
|
|
|
3104
3104
|
position: 'relative',
|
|
3105
3105
|
alignItems: 'center',
|
|
3106
3106
|
WebkitTapHighlightColor: 'transparent',
|
|
3107
|
+
gap: 1,
|
|
3107
3108
|
...__css
|
|
3108
3109
|
},
|
|
3109
3110
|
...otherProps
|
|
@@ -5119,23 +5120,24 @@ const Snackbar = /*#__PURE__*/react$1.forwardRef(function Snackbar(props, forwar
|
|
|
5119
5120
|
});
|
|
5120
5121
|
});
|
|
5121
5122
|
|
|
5122
|
-
const BORDER_WIDTH =
|
|
5123
|
-
const TRAIL_WIDTH =
|
|
5124
|
-
const TRAIL_HEIGHT =
|
|
5125
|
-
const
|
|
5126
|
-
const
|
|
5127
|
-
const
|
|
5128
|
-
const
|
|
5123
|
+
const BORDER_WIDTH = 'var(--switch-border-width)';
|
|
5124
|
+
const TRAIL_WIDTH = 'var(--switch-trail-width)';
|
|
5125
|
+
const TRAIL_HEIGHT = 'var(--switch-trail-height)';
|
|
5126
|
+
const STATE_LAYER_SIZE = 'var(--switch-state-layer-size)';
|
|
5127
|
+
const CIRCLE_SIZE_INACTIVE_CHECKED = 'var(--switch-thumb-size-checked-inactive)';
|
|
5128
|
+
const CIRCLE_SIZE_ACTIVE_CHECKED = 'var(--switch-thumb-size-checked-active)';
|
|
5129
|
+
const CIRCLE_SIZE_INACTIVE_UNCHECKED = 'var(--switch-thumb-size-unchecked-inactive)';
|
|
5130
|
+
const CIRCLE_SIZE_ACTIVE_UNCHECKED = 'var(--switch-thumb-size-unchecked-active)';
|
|
5129
5131
|
const SwitchTrail = ({
|
|
5130
5132
|
checked = false,
|
|
5131
5133
|
disabled = false,
|
|
5132
5134
|
...otherProps
|
|
5133
5135
|
}) => /*#__PURE__*/jsxRuntime.jsx(Box, {
|
|
5134
5136
|
__css: {
|
|
5135
|
-
width:
|
|
5136
|
-
height:
|
|
5137
|
-
borderRadius:
|
|
5138
|
-
borderWidth:
|
|
5137
|
+
width: TRAIL_WIDTH,
|
|
5138
|
+
height: TRAIL_HEIGHT,
|
|
5139
|
+
borderRadius: 'full',
|
|
5140
|
+
borderWidth: BORDER_WIDTH,
|
|
5139
5141
|
borderStyle: 'solid',
|
|
5140
5142
|
backgroundColor: checked ? 'primary' : 'surface-variant',
|
|
5141
5143
|
borderColor: checked ? 'primary' : 'outline',
|
|
@@ -5147,24 +5149,25 @@ const SwitchTrail = ({
|
|
|
5147
5149
|
},
|
|
5148
5150
|
...otherProps
|
|
5149
5151
|
});
|
|
5150
|
-
const THUMB_SIZE = 40;
|
|
5151
5152
|
const SwitchThumb = ({
|
|
5152
5153
|
checked = false,
|
|
5153
5154
|
...otherProps
|
|
5154
5155
|
}) => /*#__PURE__*/jsxRuntime.jsx(Box, {
|
|
5155
5156
|
position: "absolute",
|
|
5156
|
-
width:
|
|
5157
|
-
height:
|
|
5157
|
+
width: STATE_LAYER_SIZE,
|
|
5158
|
+
height: STATE_LAYER_SIZE,
|
|
5158
5159
|
borderRadius: "full",
|
|
5159
5160
|
left: '50%',
|
|
5160
5161
|
top: '50%',
|
|
5161
5162
|
__css: {
|
|
5162
|
-
transform: `translateX(calc(-50% ${checked ? '+' : '-'}
|
|
5163
|
+
transform: `translateX(calc(-50% ${checked ? '+' : '-'}
|
|
5164
|
+
(${TRAIL_WIDTH} - ${CIRCLE_SIZE_INACTIVE_CHECKED} - ${BORDER_WIDTH} * 4) / 2
|
|
5165
|
+
)) translateY(-50%)`,
|
|
5163
5166
|
WebkitTapHighlightColor: 'transparent',
|
|
5164
5167
|
transition: `background-color 90ms ${EASING_STANDARD},border-color 90ms ${EASING_STANDARD},transform 90ms ${EASING_STANDARD},height 90ms ${EASING_STANDARD},width 90ms ${EASING_STANDARD}`,
|
|
5165
5168
|
'& > input': {
|
|
5166
|
-
width:
|
|
5167
|
-
height:
|
|
5169
|
+
width: STATE_LAYER_SIZE,
|
|
5170
|
+
height: STATE_LAYER_SIZE
|
|
5168
5171
|
}
|
|
5169
5172
|
},
|
|
5170
5173
|
...otherProps
|
|
@@ -5175,8 +5178,8 @@ const SwitchCircle = ({
|
|
|
5175
5178
|
}) => /*#__PURE__*/jsxRuntime.jsx(Box, {
|
|
5176
5179
|
__css: {
|
|
5177
5180
|
position: 'absolute',
|
|
5178
|
-
width: checked ?
|
|
5179
|
-
height: checked ?
|
|
5181
|
+
width: checked ? CIRCLE_SIZE_INACTIVE_CHECKED : CIRCLE_SIZE_INACTIVE_UNCHECKED,
|
|
5182
|
+
height: checked ? CIRCLE_SIZE_INACTIVE_CHECKED : CIRCLE_SIZE_INACTIVE_UNCHECKED,
|
|
5180
5183
|
boxSizing: 'border-box',
|
|
5181
5184
|
borderRadius: 'full',
|
|
5182
5185
|
pointerEvents: 'none',
|
|
@@ -5207,67 +5210,84 @@ const SwitchCircle = ({
|
|
|
5207
5210
|
});
|
|
5208
5211
|
|
|
5209
5212
|
const CheckBoxCore = core.CheckBox;
|
|
5213
|
+
|
|
5214
|
+
function getSizeCssVariables(size) {
|
|
5215
|
+
const multiplier = size === 'small' ? 0.75 : 1;
|
|
5216
|
+
const BORDER_WIDTH = 2;
|
|
5217
|
+
const TRAIL_WIDTH = 52 * multiplier;
|
|
5218
|
+
const TRAIL_HEIGHT = 32 * multiplier;
|
|
5219
|
+
return {
|
|
5220
|
+
['--switch-border-width']: polished.rem(BORDER_WIDTH),
|
|
5221
|
+
['--switch-trail-width']: polished.rem(TRAIL_WIDTH),
|
|
5222
|
+
['--switch-trail-height']: polished.rem(TRAIL_HEIGHT),
|
|
5223
|
+
['--switch-state-layer-size']: polished.rem(40 * multiplier),
|
|
5224
|
+
['--switch-thumb-size-checked-inactive']: polished.rem(TRAIL_HEIGHT - BORDER_WIDTH * 4),
|
|
5225
|
+
['--switch-thumb-size-checked-active']: polished.rem(TRAIL_HEIGHT - BORDER_WIDTH * 2),
|
|
5226
|
+
['--switch-thumb-size-unchecked-inactive']: polished.rem(TRAIL_HEIGHT / 2),
|
|
5227
|
+
['--switch-thumb-size-unchecked-active']: polished.rem(TRAIL_HEIGHT - BORDER_WIDTH * 2)
|
|
5228
|
+
};
|
|
5229
|
+
}
|
|
5230
|
+
|
|
5210
5231
|
const SwitchInner = /*#__PURE__*/react$1.forwardRef(function SwitchInner(props, forwardedRef) {
|
|
5211
5232
|
const {
|
|
5212
5233
|
as: Comp = 'input',
|
|
5213
5234
|
disabled,
|
|
5214
5235
|
checked,
|
|
5215
5236
|
onChange,
|
|
5237
|
+
size = 'default',
|
|
5216
5238
|
__css,
|
|
5217
5239
|
...otherProps
|
|
5218
5240
|
} = props;
|
|
5219
5241
|
const color = checked ? 'primary' : 'on.surface';
|
|
5220
5242
|
const theme = useTheme();
|
|
5221
|
-
return /*#__PURE__*/jsxRuntime.
|
|
5222
|
-
p: 2,
|
|
5243
|
+
return /*#__PURE__*/jsxRuntime.jsxs(Box, {
|
|
5223
5244
|
display: "inline-block",
|
|
5245
|
+
position: "relative",
|
|
5224
5246
|
minWidth: "auto",
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5247
|
+
sx: getSizeCssVariables(size),
|
|
5248
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(SwitchTrail, {
|
|
5249
|
+
checked: checked,
|
|
5250
|
+
disabled: disabled
|
|
5251
|
+
}), /*#__PURE__*/jsxRuntime.jsxs(SwitchThumb, {
|
|
5252
|
+
checked: checked,
|
|
5253
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(RippleBox, {
|
|
5254
|
+
as: Comp,
|
|
5255
|
+
role: "switch",
|
|
5256
|
+
type: "checkbox",
|
|
5231
5257
|
checked: checked,
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
position: 'absolute',
|
|
5264
|
-
...__css
|
|
5265
|
-
}
|
|
5266
|
-
}), /*#__PURE__*/jsxRuntime.jsx(SwitchCircle, {
|
|
5267
|
-
checked: checked
|
|
5268
|
-
})]
|
|
5258
|
+
onChange: onChange,
|
|
5259
|
+
theme: theme,
|
|
5260
|
+
ref: forwardedRef,
|
|
5261
|
+
"aria-checked": checked ? 'true' : 'false',
|
|
5262
|
+
rippleColor: color,
|
|
5263
|
+
baseOpacity: 0,
|
|
5264
|
+
hoverOpacity: 0.04,
|
|
5265
|
+
focusOpacity: 0.12,
|
|
5266
|
+
center: true,
|
|
5267
|
+
disabled: disabled,
|
|
5268
|
+
"data-switch-thumb": "",
|
|
5269
|
+
...otherProps,
|
|
5270
|
+
__css: {
|
|
5271
|
+
top: '50%',
|
|
5272
|
+
left: '50%',
|
|
5273
|
+
backgroundColor: 'transparent',
|
|
5274
|
+
transform: 'translate(-50%, -50%)',
|
|
5275
|
+
width: '100%',
|
|
5276
|
+
height: '100%',
|
|
5277
|
+
appearance: 'none',
|
|
5278
|
+
':focus': {
|
|
5279
|
+
outline: 'none'
|
|
5280
|
+
},
|
|
5281
|
+
border: 'none',
|
|
5282
|
+
borderRadius: 'full',
|
|
5283
|
+
zIndex: 1,
|
|
5284
|
+
position: 'absolute',
|
|
5285
|
+
...__css
|
|
5286
|
+
}
|
|
5287
|
+
}), /*#__PURE__*/jsxRuntime.jsx(SwitchCircle, {
|
|
5288
|
+
checked: checked
|
|
5269
5289
|
})]
|
|
5270
|
-
})
|
|
5290
|
+
})]
|
|
5271
5291
|
});
|
|
5272
5292
|
});
|
|
5273
5293
|
const Switch = /*#__PURE__*/react$1.forwardRef(function Switch(props, forwardedRef) {
|