@officesdk/design 0.2.8 → 0.2.9

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.
@@ -1614,29 +1614,12 @@ var init_numberLocale = __esm({
1614
1614
  };
1615
1615
  }
1616
1616
  });
1617
- var getDecimalPlaces, precisionAdd, precisionSubtract, NumberInputContainer, InputWrapper, UnitText, StyledInput, ButtonGroup, StepButton, UpArrow, DownArrow; exports.NumberInput = void 0;
1618
- var init_NumberInput = __esm({
1619
- "src/NumberInput/NumberInput.tsx"() {
1617
+
1618
+ // src/NumberInput/NumberInput.styled.ts
1619
+ var NumberInputContainer, InputWrapper, StyledInput, ButtonGroup, StepButton;
1620
+ var init_NumberInput_styled = __esm({
1621
+ "src/NumberInput/NumberInput.styled.ts"() {
1620
1622
  init_styled();
1621
- init_UIConfigProvider2();
1622
- init_numberLocale();
1623
- init_valueMap();
1624
- getDecimalPlaces = (num) => {
1625
- const str = String(num);
1626
- const decimalIndex = str.indexOf(".");
1627
- if (decimalIndex === -1) return 0;
1628
- return str.length - decimalIndex - 1;
1629
- };
1630
- precisionAdd = (a, b) => {
1631
- const precision = Math.max(getDecimalPlaces(a), getDecimalPlaces(b));
1632
- const multiplier = Math.pow(10, precision);
1633
- return Math.round(a * multiplier + b * multiplier) / multiplier;
1634
- };
1635
- precisionSubtract = (a, b) => {
1636
- const precision = Math.max(getDecimalPlaces(a), getDecimalPlaces(b));
1637
- const multiplier = Math.pow(10, precision);
1638
- return Math.round(a * multiplier - b * multiplier) / multiplier;
1639
- };
1640
1623
  NumberInputContainer = exports.styled.div`
1641
1624
  display: inline-flex;
1642
1625
  align-items: center;
@@ -1707,25 +1690,6 @@ var init_NumberInput = __esm({
1707
1690
  align-items: center;
1708
1691
  padding: 0 8px;
1709
1692
  min-width: 0;
1710
- gap: 4px;
1711
- `;
1712
- UnitText = exports.styled.span`
1713
- flex-shrink: 0;
1714
- font-family: 'PingFang SC', sans-serif;
1715
- font-weight: 400;
1716
- line-height: 20px;
1717
-
1718
- ${({ $size }) => $size === "small" ? `
1719
- font-size: 12px;
1720
- ` : `
1721
- font-size: 13px;
1722
- `}
1723
-
1724
- ${({ $disabled, theme: theme2 }) => $disabled ? `
1725
- color: ${theme2.colors.palettes.transparency["30"]};
1726
- ` : `
1727
- color: ${theme2.colors.palettes.gray["120"]};
1728
- `}
1729
1693
  `;
1730
1694
  StyledInput = exports.styled.input`
1731
1695
  width: 100%;
@@ -1843,6 +1807,31 @@ var init_NumberInput = __esm({
1843
1807
  fill: ${({ $disabled, theme: theme2 }) => $disabled ? theme2.colors.palettes.transparency["30"] : theme2.colors.palettes.gray["120"]};
1844
1808
  }
1845
1809
  `;
1810
+ }
1811
+ });
1812
+ var getDecimalPlaces, precisionAdd, precisionSubtract, UpArrow, DownArrow; exports.NumberInput = void 0;
1813
+ var init_NumberInput = __esm({
1814
+ "src/NumberInput/NumberInput.tsx"() {
1815
+ init_UIConfigProvider2();
1816
+ init_numberLocale();
1817
+ init_valueMap();
1818
+ init_NumberInput_styled();
1819
+ getDecimalPlaces = (num) => {
1820
+ const str = String(num);
1821
+ const decimalIndex = str.indexOf(".");
1822
+ if (decimalIndex === -1) return 0;
1823
+ return str.length - decimalIndex - 1;
1824
+ };
1825
+ precisionAdd = (a, b) => {
1826
+ const precision = Math.max(getDecimalPlaces(a), getDecimalPlaces(b));
1827
+ const multiplier = Math.pow(10, precision);
1828
+ return Math.round(a * multiplier + b * multiplier) / multiplier;
1829
+ };
1830
+ precisionSubtract = (a, b) => {
1831
+ const precision = Math.max(getDecimalPlaces(a), getDecimalPlaces(b));
1832
+ const multiplier = Math.pow(10, precision);
1833
+ return Math.round(a * multiplier - b * multiplier) / multiplier;
1834
+ };
1846
1835
  UpArrow = () => /* @__PURE__ */ React3__default.default.createElement("svg", { viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React3__default.default.createElement("path", { d: "M7 4.5L10.5 8.5H3.5L7 4.5Z", fill: "currentColor" }));
1847
1836
  DownArrow = () => /* @__PURE__ */ React3__default.default.createElement("svg", { viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React3__default.default.createElement("path", { d: "M7 9.5L3.5 5.5H10.5L7 9.5Z", fill: "currentColor" }));
1848
1837
  exports.NumberInput = ({
@@ -1892,15 +1881,20 @@ var init_NumberInput = __esm({
1892
1881
  if (val === void 0) {
1893
1882
  return "";
1894
1883
  }
1884
+ let formatted;
1895
1885
  if (formatter) {
1896
- return formatter(val);
1886
+ formatted = formatter(val);
1887
+ } else if (useThousandsSeparator) {
1888
+ formatted = formatNumber(val, locale, precision);
1889
+ } else {
1890
+ formatted = formatNumberForEdit(val, locale, precision);
1897
1891
  }
1898
- if (useThousandsSeparator) {
1899
- return formatNumber(val, locale, precision);
1892
+ if (unit) {
1893
+ return formatted + unit;
1900
1894
  }
1901
- return formatNumberForEdit(val, locale, precision);
1895
+ return formatted;
1902
1896
  },
1903
- [formatter, precision, locale, useThousandsSeparator]
1897
+ [formatter, precision, locale, useThousandsSeparator, unit]
1904
1898
  );
1905
1899
  const formatValueForEdit = React3.useCallback(
1906
1900
  (val) => {
@@ -2071,7 +2065,7 @@ var init_NumberInput = __esm({
2071
2065
  $size: size,
2072
2066
  $disabled: disabled
2073
2067
  }
2074
- ), unit && /* @__PURE__ */ React3__default.default.createElement(UnitText, { $size: size, $disabled: disabled }, unit)),
2068
+ )),
2075
2069
  showStepButtons && (showStepButtonsTrigger !== "hover" || isHovered || isFocused) && /* @__PURE__ */ React3__default.default.createElement(ButtonGroup, { $alert: alert, $disabled: disabled, $lineType: lineType }, /* @__PURE__ */ React3__default.default.createElement(
2076
2070
  StepButton,
2077
2071
  {