@officesdk/design 0.2.3 → 0.2.5
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/dist/components/cjs/index.d.ts +15 -1
- package/dist/components/cjs/index.js +50 -11
- package/dist/components/cjs/index.js.map +1 -1
- package/dist/components/esm/index.d.ts +15 -1
- package/dist/components/esm/index.js +51 -12
- package/dist/components/esm/index.js.map +1 -1
- package/dist/theme/cjs/index.js +6 -4
- package/dist/theme/cjs/index.js.map +1 -1
- package/dist/theme/esm/index.js +6 -4
- package/dist/theme/esm/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -583,6 +583,11 @@ interface NumberInputProps {
|
|
|
583
583
|
* Placeholder text
|
|
584
584
|
*/
|
|
585
585
|
placeholder?: string;
|
|
586
|
+
/**
|
|
587
|
+
* Whether to show step buttons (increment/decrement)
|
|
588
|
+
* @default true
|
|
589
|
+
*/
|
|
590
|
+
showStepButtons?: boolean;
|
|
586
591
|
/**
|
|
587
592
|
* Callback when value changes
|
|
588
593
|
* @param fixedValue - The clamped value within min/max range (can be undefined if empty)
|
|
@@ -927,6 +932,10 @@ interface TabsProps {
|
|
|
927
932
|
* Tab size
|
|
928
933
|
*/
|
|
929
934
|
size?: 'large';
|
|
935
|
+
/**
|
|
936
|
+
* Tab items alignment (only works for 'line' variant)
|
|
937
|
+
*/
|
|
938
|
+
justify?: 'start' | 'center' | 'end';
|
|
930
939
|
/**
|
|
931
940
|
* Callback when tab changes
|
|
932
941
|
*/
|
|
@@ -1095,7 +1104,7 @@ interface ToolbarButtonProps extends Omit<React$1.HTMLAttributes<HTMLDivElement>
|
|
|
1095
1104
|
*/
|
|
1096
1105
|
declare const ToolbarButton: React$1.FC<ToolbarButtonProps>;
|
|
1097
1106
|
|
|
1098
|
-
type DropdownButtonSize = 'large' | 'medium';
|
|
1107
|
+
type DropdownButtonSize = 'large' | 'medium' | 'small';
|
|
1099
1108
|
type DropdownButtonVariant = 'framed' | 'frameless';
|
|
1100
1109
|
interface DropdownButtonProps extends Omit<React$1.ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {
|
|
1101
1110
|
/**
|
|
@@ -1148,6 +1157,11 @@ interface DropdownButtonProps extends Omit<React$1.ButtonHTMLAttributes<HTMLButt
|
|
|
1148
1157
|
* Custom text style
|
|
1149
1158
|
*/
|
|
1150
1159
|
textStyle?: React$1.CSSProperties;
|
|
1160
|
+
/**
|
|
1161
|
+
* Custom content to render instead of value/placeholder
|
|
1162
|
+
* When provided, value and placeholder are ignored
|
|
1163
|
+
*/
|
|
1164
|
+
children?: React$1.ReactNode;
|
|
1151
1165
|
}
|
|
1152
1166
|
/**
|
|
1153
1167
|
* DropdownButton Component
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ReactDOM from 'react-dom';
|
|
2
2
|
import React3, { forwardRef, useState, createContext, useEffect, useMemo, useRef, useCallback, useContext } from 'react';
|
|
3
|
-
import { ArrowRightIcon, CloseIcon, SearchIcon, ErrorIcon, WarningIcon, InfoIcon, SuccessIcon, CheckIcon,
|
|
3
|
+
import { ArrowRightIcon, CloseIcon, SearchIcon, ErrorIcon, WarningIcon, InfoIcon, SuccessIcon, CheckIcon, ArrowDownIcon } from '@officesdk/design/icons';
|
|
4
4
|
import { lightTheme } from '@officesdk/design/theme';
|
|
5
5
|
import baseStyled, { createGlobalStyle as createGlobalStyle$1 } from 'styled-components';
|
|
6
6
|
import RcTooltip from 'rc-tooltip';
|
|
@@ -1278,10 +1278,26 @@ var init_Slider2 = __esm({
|
|
|
1278
1278
|
init_valueMap();
|
|
1279
1279
|
}
|
|
1280
1280
|
});
|
|
1281
|
-
var NumberInputContainer, InputWrapper, UnitText, StyledInput, ButtonGroup, StepButton, UpArrow, DownArrow, NumberInput;
|
|
1281
|
+
var getDecimalPlaces, precisionAdd, precisionSubtract, NumberInputContainer, InputWrapper, UnitText, StyledInput, ButtonGroup, StepButton, UpArrow, DownArrow, NumberInput;
|
|
1282
1282
|
var init_NumberInput = __esm({
|
|
1283
1283
|
"src/NumberInput/NumberInput.tsx"() {
|
|
1284
1284
|
init_styled();
|
|
1285
|
+
getDecimalPlaces = (num) => {
|
|
1286
|
+
const str = String(num);
|
|
1287
|
+
const decimalIndex = str.indexOf(".");
|
|
1288
|
+
if (decimalIndex === -1) return 0;
|
|
1289
|
+
return str.length - decimalIndex - 1;
|
|
1290
|
+
};
|
|
1291
|
+
precisionAdd = (a, b) => {
|
|
1292
|
+
const precision = Math.max(getDecimalPlaces(a), getDecimalPlaces(b));
|
|
1293
|
+
const multiplier = Math.pow(10, precision);
|
|
1294
|
+
return Math.round(a * multiplier + b * multiplier) / multiplier;
|
|
1295
|
+
};
|
|
1296
|
+
precisionSubtract = (a, b) => {
|
|
1297
|
+
const precision = Math.max(getDecimalPlaces(a), getDecimalPlaces(b));
|
|
1298
|
+
const multiplier = Math.pow(10, precision);
|
|
1299
|
+
return Math.round(a * multiplier - b * multiplier) / multiplier;
|
|
1300
|
+
};
|
|
1285
1301
|
NumberInputContainer = styled.div`
|
|
1286
1302
|
display: inline-flex;
|
|
1287
1303
|
align-items: center;
|
|
@@ -1471,6 +1487,7 @@ var init_NumberInput = __esm({
|
|
|
1471
1487
|
parser,
|
|
1472
1488
|
unit,
|
|
1473
1489
|
placeholder,
|
|
1490
|
+
showStepButtons = true,
|
|
1474
1491
|
onChange,
|
|
1475
1492
|
className,
|
|
1476
1493
|
style
|
|
@@ -1532,13 +1549,23 @@ var init_NumberInput = __esm({
|
|
|
1532
1549
|
const increment = useCallback(() => {
|
|
1533
1550
|
if (disabled) return;
|
|
1534
1551
|
const currentValue = value ?? 0;
|
|
1535
|
-
|
|
1536
|
-
|
|
1552
|
+
const newValue = precisionAdd(currentValue, step);
|
|
1553
|
+
handleValueChange(newValue);
|
|
1554
|
+
if (isFocused) {
|
|
1555
|
+
const clampedValue = clampValue(newValue);
|
|
1556
|
+
setDisplayValue(formatValue(clampedValue));
|
|
1557
|
+
}
|
|
1558
|
+
}, [disabled, value, step, handleValueChange, isFocused, clampValue, formatValue]);
|
|
1537
1559
|
const decrement = useCallback(() => {
|
|
1538
1560
|
if (disabled) return;
|
|
1539
1561
|
const currentValue = value ?? 0;
|
|
1540
|
-
|
|
1541
|
-
|
|
1562
|
+
const newValue = precisionSubtract(currentValue, step);
|
|
1563
|
+
handleValueChange(newValue);
|
|
1564
|
+
if (isFocused) {
|
|
1565
|
+
const clampedValue = clampValue(newValue);
|
|
1566
|
+
setDisplayValue(formatValue(clampedValue));
|
|
1567
|
+
}
|
|
1568
|
+
}, [disabled, value, step, handleValueChange, isFocused, clampValue, formatValue]);
|
|
1542
1569
|
const handleInputChange = useCallback((e) => {
|
|
1543
1570
|
setDisplayValue(e.target.value);
|
|
1544
1571
|
}, []);
|
|
@@ -1605,7 +1632,7 @@ var init_NumberInput = __esm({
|
|
|
1605
1632
|
$disabled: disabled
|
|
1606
1633
|
}
|
|
1607
1634
|
), unit && /* @__PURE__ */ React3.createElement(UnitText, { $size: size, $disabled: disabled }, unit)),
|
|
1608
|
-
/* @__PURE__ */ React3.createElement(ButtonGroup, { $alert: alert, $disabled: disabled }, /* @__PURE__ */ React3.createElement(
|
|
1635
|
+
showStepButtons && /* @__PURE__ */ React3.createElement(ButtonGroup, { $alert: alert, $disabled: disabled }, /* @__PURE__ */ React3.createElement(
|
|
1609
1636
|
StepButton,
|
|
1610
1637
|
{
|
|
1611
1638
|
type: "button",
|
|
@@ -2856,10 +2883,12 @@ var TabList = styled.div`
|
|
|
2856
2883
|
height: 100%;
|
|
2857
2884
|
|
|
2858
2885
|
|
|
2859
|
-
${({ $variant, theme: theme2 }) => {
|
|
2886
|
+
${({ $variant, $justify, theme: theme2 }) => {
|
|
2860
2887
|
const variantConfig = theme2.components.tab[$variant];
|
|
2888
|
+
const justifyContent = $variant === "line" ? $justify === "center" ? "center" : $justify === "end" ? "flex-end" : "flex-start" : "flex-start";
|
|
2861
2889
|
return `
|
|
2862
2890
|
gap: ${variantConfig.layout.gap};
|
|
2891
|
+
justify-content: ${justifyContent};
|
|
2863
2892
|
`;
|
|
2864
2893
|
}}
|
|
2865
2894
|
|
|
@@ -2990,6 +3019,7 @@ var Tabs = ({
|
|
|
2990
3019
|
variant = "line",
|
|
2991
3020
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2992
3021
|
size: _size = "large",
|
|
3022
|
+
justify = "start",
|
|
2993
3023
|
onChange,
|
|
2994
3024
|
className,
|
|
2995
3025
|
style,
|
|
@@ -3010,7 +3040,7 @@ var Tabs = ({
|
|
|
3010
3040
|
},
|
|
3011
3041
|
[controlledActiveKey, onChange]
|
|
3012
3042
|
);
|
|
3013
|
-
return /* @__PURE__ */ React3.createElement(TabContainer, { $variant: variant, className, style }, /* @__PURE__ */ React3.createElement(TabList, { $variant: variant, role: "tablist" }, items.map((item) => /* @__PURE__ */ React3.createElement(
|
|
3043
|
+
return /* @__PURE__ */ React3.createElement(TabContainer, { $variant: variant, className, style }, /* @__PURE__ */ React3.createElement(TabList, { $variant: variant, $justify: justify, role: "tablist" }, items.map((item) => /* @__PURE__ */ React3.createElement(
|
|
3014
3044
|
TabItem,
|
|
3015
3045
|
{
|
|
3016
3046
|
key: item.key,
|
|
@@ -3225,6 +3255,8 @@ var TooltipGlobalStyles = createGlobalStyle$1`
|
|
|
3225
3255
|
line-height: ${() => getGlobalTheme().components.tooltip.black.lineHeight};
|
|
3226
3256
|
font-weight: ${() => getGlobalTheme().components.tooltip.black.fontWeight};
|
|
3227
3257
|
max-width: ${() => getGlobalTheme().components.tooltip.black.maxWidth};
|
|
3258
|
+
white-space: normal;
|
|
3259
|
+
word-wrap: break-word;
|
|
3228
3260
|
text-align: left;
|
|
3229
3261
|
text-decoration: none;
|
|
3230
3262
|
}
|
|
@@ -3244,6 +3276,9 @@ var TooltipGlobalStyles = createGlobalStyle$1`
|
|
|
3244
3276
|
font-size: ${() => getGlobalTheme().components.tooltip.white.small.fontSize};
|
|
3245
3277
|
line-height: ${() => getGlobalTheme().components.tooltip.white.small.lineHeight};
|
|
3246
3278
|
font-weight: ${() => getGlobalTheme().components.tooltip.white.small.fontWeight};
|
|
3279
|
+
max-width: ${() => getGlobalTheme().components.tooltip.white.small.maxWidth};
|
|
3280
|
+
white-space: normal;
|
|
3281
|
+
word-wrap: break-word;
|
|
3247
3282
|
text-align: left;
|
|
3248
3283
|
text-decoration: none;
|
|
3249
3284
|
}
|
|
@@ -3263,6 +3298,9 @@ var TooltipGlobalStyles = createGlobalStyle$1`
|
|
|
3263
3298
|
font-size: ${() => getGlobalTheme().components.tooltip.white.large.fontSize};
|
|
3264
3299
|
line-height: ${() => getGlobalTheme().components.tooltip.white.large.lineHeight};
|
|
3265
3300
|
font-weight: ${() => getGlobalTheme().components.tooltip.white.large.fontWeight};
|
|
3301
|
+
max-width: ${() => getGlobalTheme().components.tooltip.white.large.maxWidth};
|
|
3302
|
+
white-space: normal;
|
|
3303
|
+
word-wrap: break-word;
|
|
3266
3304
|
text-align: left;
|
|
3267
3305
|
text-decoration: none;
|
|
3268
3306
|
}
|
|
@@ -3654,7 +3692,7 @@ var ToolbarButton = ({
|
|
|
3654
3692
|
},
|
|
3655
3693
|
renderIcon(),
|
|
3656
3694
|
renderLabel(),
|
|
3657
|
-
/* @__PURE__ */ React3.createElement(DropdownArrow, { $disabled: disabled }, /* @__PURE__ */ React3.createElement(
|
|
3695
|
+
/* @__PURE__ */ React3.createElement(DropdownArrow, { $disabled: disabled }, /* @__PURE__ */ React3.createElement(ArrowDownIcon, null))
|
|
3658
3696
|
)
|
|
3659
3697
|
);
|
|
3660
3698
|
}
|
|
@@ -3690,7 +3728,7 @@ var ToolbarButton = ({
|
|
|
3690
3728
|
onClick: handleDropdownClick,
|
|
3691
3729
|
disabled
|
|
3692
3730
|
},
|
|
3693
|
-
/* @__PURE__ */ React3.createElement(DropdownArrow, { $disabled: disabled }, /* @__PURE__ */ React3.createElement(
|
|
3731
|
+
/* @__PURE__ */ React3.createElement(DropdownArrow, { $disabled: disabled }, /* @__PURE__ */ React3.createElement(ArrowDownIcon, null))
|
|
3694
3732
|
)
|
|
3695
3733
|
);
|
|
3696
3734
|
}
|
|
@@ -3883,6 +3921,7 @@ var DropdownButton2 = forwardRef(
|
|
|
3883
3921
|
style,
|
|
3884
3922
|
textStyle,
|
|
3885
3923
|
onClick,
|
|
3924
|
+
children,
|
|
3886
3925
|
...rest
|
|
3887
3926
|
}, ref) => {
|
|
3888
3927
|
const effectiveSize = size || (variant === "framed" ? "large" : "medium");
|
|
@@ -3912,7 +3951,7 @@ var DropdownButton2 = forwardRef(
|
|
|
3912
3951
|
...rest
|
|
3913
3952
|
},
|
|
3914
3953
|
iconElement && /* @__PURE__ */ React3.createElement(IconWrapper5, { $size: effectiveSize }, iconElement),
|
|
3915
|
-
/* @__PURE__ */ React3.createElement(TextContent, { $disabled: disabled, $hasValue: hasValue, style: textStyle }, value || placeholder),
|
|
3954
|
+
children ? children : /* @__PURE__ */ React3.createElement(TextContent, { $disabled: disabled, $hasValue: hasValue, style: textStyle }, value || placeholder),
|
|
3916
3955
|
/* @__PURE__ */ React3.createElement(IndicatorWrapper, { $size: effectiveSize, $open: open, $disabled: disabled }, indicatorIcon || /* @__PURE__ */ React3.createElement(ArrowRightIcon, null))
|
|
3917
3956
|
);
|
|
3918
3957
|
}
|