@knkcs/anker 0.0.4 → 0.0.6

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.
@@ -1,7 +1,7 @@
1
1
  import { defineRecipe, defineSlotRecipe, createSystem, defaultConfig } from '@chakra-ui/react';
2
2
  import { toHex, transparentize as transparentize$1 } from 'color2k';
3
3
 
4
- // src/theme/index.ts
4
+ // src/theme/create-theme.ts
5
5
  var buttonTheme = defineRecipe({
6
6
  base: {
7
7
  lineHeight: "1.2",
@@ -10,16 +10,19 @@ var buttonTheme = defineRecipe({
10
10
  transitionProperty: "common",
11
11
  transitionDuration: "normal",
12
12
  _focusVisible: {
13
- boxShadow: "none",
14
- outlineOffset: "2px",
15
- outlineWidth: "2px",
16
- outlineStyle: "solid",
17
- outlineColor: "primary.600"
13
+ boxShadow: "focus-ring",
14
+ outline: "none"
15
+ },
16
+ _active: {
17
+ transform: "scale(0.98)"
18
18
  },
19
19
  _disabled: {
20
20
  opacity: 0.4,
21
21
  cursor: "not-allowed",
22
- boxShadow: "none"
22
+ boxShadow: "none",
23
+ _active: {
24
+ transform: "none"
25
+ }
23
26
  },
24
27
  _hover: {
25
28
  _disabled: {
@@ -97,7 +100,9 @@ var buttonTheme = defineRecipe({
97
100
  }
98
101
  }
99
102
  },
100
- // Primary: solid style locked to the primary color palette
103
+ // @deprecated Use variant="solid" instead solid now defaults to
104
+ // colorPalette="primary". This variant will be removed in a future
105
+ // major release.
101
106
  primary: {
102
107
  bg: "primary.500",
103
108
  color: "white",
@@ -177,21 +182,28 @@ var buttonTheme = defineRecipe({
177
182
  },
178
183
  defaultVariants: {
179
184
  size: "lg",
180
- variant: "solid"
185
+ variant: "solid",
186
+ colorPalette: "primary"
181
187
  }
182
188
  });
183
189
  var cardSlotRecipe = defineSlotRecipe({
184
190
  slots: ["root", "header", "body", "footer", "title", "description"],
185
191
  base: {
186
192
  root: {
187
- bg: { base: "white", _dark: "gray.800" }
193
+ bg: { base: "white", _dark: "gray.800" },
194
+ transitionProperty: "box-shadow, transform",
195
+ transitionDuration: "normal"
188
196
  }
189
197
  },
190
198
  variants: {
191
199
  variant: {
192
200
  elevated: {
193
201
  root: {
194
- boxShadow: "md"
202
+ boxShadow: "md",
203
+ _hover: {
204
+ boxShadow: "lg",
205
+ transform: "translateY(-1px)"
206
+ }
195
207
  }
196
208
  },
197
209
  flat: {
@@ -537,7 +549,7 @@ var menuTheme = defineSlotRecipe({
537
549
  }
538
550
  });
539
551
  var modalSlotRecipe = defineSlotRecipe({
540
- slots: ["header", "closeButton", "dialog"],
552
+ slots: ["header", "closeButton", "dialog", "backdrop"],
541
553
  base: {
542
554
  header: {
543
555
  px: "6",
@@ -546,7 +558,10 @@ var modalSlotRecipe = defineSlotRecipe({
546
558
  fontWeight: "semibold",
547
559
  roundedTop: "md"
548
560
  },
549
- closeButton: {}
561
+ closeButton: {},
562
+ backdrop: {
563
+ backdropFilter: "blur(4px)"
564
+ }
550
565
  },
551
566
  variants: {
552
567
  size: {
@@ -1384,7 +1399,8 @@ var tagTheme = defineRecipe({
1384
1399
  }
1385
1400
  },
1386
1401
  defaultVariants: {
1387
- size: "lg"
1402
+ size: "lg",
1403
+ colorPalette: "primary"
1388
1404
  }
1389
1405
  });
1390
1406
  var textarea_default = defineRecipe({
@@ -1420,7 +1436,8 @@ var tooltipTheme = defineRecipe({
1420
1436
  fontSize: "sm",
1421
1437
  boxShadow: "md",
1422
1438
  maxW: "xs",
1423
- zIndex: "tooltip"
1439
+ zIndex: "tooltip",
1440
+ animation: "slideUp 150ms ease-out"
1424
1441
  }
1425
1442
  });
1426
1443
  var tree_item_default = defineSlotRecipe({
@@ -1502,12 +1519,38 @@ var tree_item_default = defineSlotRecipe({
1502
1519
  var durations = {
1503
1520
  fast: { value: "150ms" },
1504
1521
  normal: { value: "200ms" },
1505
- slow: { value: "300ms" }
1522
+ slow: { value: "300ms" },
1523
+ slower: { value: "400ms" },
1524
+ entrance: { value: "250ms" },
1525
+ exit: { value: "200ms" }
1506
1526
  };
1507
1527
  var easings = {
1508
1528
  "ease-in": { value: "cubic-bezier(0.4, 0, 1, 1)" },
1509
1529
  "ease-out": { value: "cubic-bezier(0, 0, 0.2, 1)" },
1510
- "ease-in-out": { value: "cubic-bezier(0.4, 0, 0.2, 1)" }
1530
+ "ease-in-out": { value: "cubic-bezier(0.4, 0, 0.2, 1)" },
1531
+ spring: { value: "cubic-bezier(0.175, 0.885, 0.32, 1.275)" }
1532
+ };
1533
+ var keyframes = {
1534
+ fadeIn: {
1535
+ from: { opacity: 0 },
1536
+ to: { opacity: 1 }
1537
+ },
1538
+ fadeOut: {
1539
+ from: { opacity: 1 },
1540
+ to: { opacity: 0 }
1541
+ },
1542
+ slideUp: {
1543
+ from: { opacity: 0, transform: "translateY(4px)" },
1544
+ to: { opacity: 1, transform: "translateY(0)" }
1545
+ },
1546
+ slideDown: {
1547
+ from: { opacity: 0, transform: "translateY(-4px)" },
1548
+ to: { opacity: 1, transform: "translateY(0)" }
1549
+ },
1550
+ scaleIn: {
1551
+ from: { opacity: 0, transform: "scale(0.95)" },
1552
+ to: { opacity: 1, transform: "scale(1)" }
1553
+ }
1511
1554
  };
1512
1555
 
1513
1556
  // src/theme/tokens/colors.ts
@@ -1754,6 +1797,18 @@ var semanticTokens = {
1754
1797
  base: "0px 0px 1px rgba(45, 55, 72, 0.05), 0px 16px 24px rgba(45, 55, 72, 0.1)",
1755
1798
  _dark: "0px 0px 1px rgba(13, 14, 20, 1), 0px 16px 24px rgba(13, 14, 20, 0.9)"
1756
1799
  }
1800
+ },
1801
+ "2xl": {
1802
+ value: {
1803
+ base: "0px 0px 1px rgba(45, 55, 72, 0.04), 0px 24px 48px rgba(45, 55, 72, 0.12)",
1804
+ _dark: "0px 0px 1px rgba(13, 14, 20, 1), 0px 24px 48px rgba(13, 14, 20, 0.9)"
1805
+ }
1806
+ },
1807
+ "focus-ring": {
1808
+ value: {
1809
+ base: "0 0 0 3px rgba(32, 135, 215, 0.4)",
1810
+ _dark: "0 0 0 3px rgba(32, 135, 215, 0.6)"
1811
+ }
1757
1812
  }
1758
1813
  },
1759
1814
  opacity: {
@@ -1836,6 +1891,26 @@ var textStyles = {
1836
1891
  fontSize: "xs",
1837
1892
  lineHeight: "1.125rem"
1838
1893
  // 18px
1894
+ },
1895
+ // Additional semantic presets
1896
+ display: {
1897
+ fontSize: "6xl",
1898
+ lineHeight: "4.5rem",
1899
+ letterSpacing: "-0.03em",
1900
+ fontWeight: "bold"
1901
+ },
1902
+ caption: {
1903
+ fontSize: "xs",
1904
+ lineHeight: "1rem",
1905
+ letterSpacing: "0.01em",
1906
+ color: "muted"
1907
+ },
1908
+ overline: {
1909
+ fontSize: "xs",
1910
+ lineHeight: "1rem",
1911
+ letterSpacing: "0.08em",
1912
+ fontWeight: "semibold",
1913
+ textTransform: "uppercase"
1839
1914
  }
1840
1915
  };
1841
1916
 
@@ -1849,6 +1924,142 @@ var zIndex = {
1849
1924
  toast: { value: 1700 }
1850
1925
  };
1851
1926
  var z_index_default = zIndex;
1927
+
1928
+ // src/theme/create-theme.ts
1929
+ function createAnkerTheme(preset) {
1930
+ const fonts2 = {
1931
+ heading: preset?.fonts?.heading ?? fonts.heading,
1932
+ body: preset?.fonts?.body ?? fonts.body
1933
+ };
1934
+ const colors2 = preset?.colors ? { ...colors_default, ...preset.colors } : colors_default;
1935
+ const durations2 = preset?.durations ? { ...durations, ...preset.durations } : durations;
1936
+ const easings2 = preset?.easings ? { ...easings, ...preset.easings } : easings;
1937
+ const radii2 = preset?.radii ?? radii_default;
1938
+ const textStyles2 = preset?.textStyles ? { ...textStyles, ...preset.textStyles } : textStyles;
1939
+ const semanticTokens2 = preset?.semanticTokens ? deepMerge(
1940
+ semantic_default,
1941
+ preset.semanticTokens
1942
+ ) : semantic_default;
1943
+ return createSystem(defaultConfig, {
1944
+ globalCss: {
1945
+ "@keyframes fadeIn": keyframes.fadeIn,
1946
+ "@keyframes fadeOut": keyframes.fadeOut,
1947
+ "@keyframes slideUp": keyframes.slideUp,
1948
+ "@keyframes slideDown": keyframes.slideDown,
1949
+ "@keyframes scaleIn": keyframes.scaleIn,
1950
+ body: {
1951
+ color: "default",
1952
+ bg: { base: "white", _dark: "#000" }
1953
+ },
1954
+ "*::placeholder": {
1955
+ opacity: 1,
1956
+ color: "muted"
1957
+ },
1958
+ "*, *::before, *::after": {
1959
+ borderColor: "border"
1960
+ },
1961
+ "table, td, th": {
1962
+ borderColor: "border"
1963
+ },
1964
+ "html, body": {
1965
+ height: "100%"
1966
+ },
1967
+ "#__next, #root, #app": {
1968
+ display: "flex",
1969
+ flexDirection: "column",
1970
+ minH: "100%"
1971
+ },
1972
+ "*": {
1973
+ _motionReduce: {
1974
+ animationDuration: "0.01ms !important",
1975
+ animationIterationCount: "1 !important",
1976
+ transitionDuration: "0.01ms !important",
1977
+ scrollBehavior: "auto !important"
1978
+ }
1979
+ }
1980
+ },
1981
+ theme: {
1982
+ tokens: {
1983
+ colors: colors2,
1984
+ durations: durations2,
1985
+ easings: easings2,
1986
+ fonts: {
1987
+ heading: { value: fonts2.heading },
1988
+ body: { value: fonts2.body }
1989
+ },
1990
+ spacing: Object.fromEntries(
1991
+ Object.entries(spacing_default).map(([k, v]) => [k, { value: v }])
1992
+ ),
1993
+ radii: Object.fromEntries(
1994
+ Object.entries(radii2).map(([k, v]) => [k, { value: v }])
1995
+ ),
1996
+ zIndex: z_index_default
1997
+ },
1998
+ textStyles: textStyles2,
1999
+ semanticTokens: semanticTokens2,
2000
+ recipes: {
2001
+ button: buttonTheme,
2002
+ container: container_default,
2003
+ prose: proseTheme,
2004
+ separator: separator_default,
2005
+ formLabel: form_label_default,
2006
+ textarea: textarea_default,
2007
+ tooltip: tooltipTheme,
2008
+ tsRadioCard: radioCardTheme,
2009
+ tag: tagTheme
2010
+ },
2011
+ slotRecipes: {
2012
+ card: card_default,
2013
+ tsProperty: propertyTheme,
2014
+ treeItem: tree_item_default,
2015
+ checkbox: checkbox_default,
2016
+ comment: comment_default,
2017
+ dialog,
2018
+ drawer: drawerTheme,
2019
+ // Field.Root override: v3 defaults to alignItems: flex-start which
2020
+ // shrinks children. Restore v2 behavior where children stretch.
2021
+ field: defineSlotRecipe({
2022
+ slots: ["root"],
2023
+ variants: {
2024
+ orientation: {
2025
+ vertical: {
2026
+ root: {
2027
+ alignItems: "stretch"
2028
+ }
2029
+ }
2030
+ }
2031
+ }
2032
+ }),
2033
+ input: input_default,
2034
+ menu: menuTheme,
2035
+ modal: modalSlotRecipe,
2036
+ persona: persona_default,
2037
+ popover: popover_default,
2038
+ stepper: stepperTheme,
2039
+ table: tableTheme,
2040
+ tabs: tabTheme
2041
+ }
2042
+ }
2043
+ });
2044
+ }
2045
+ function deepMerge(base, override) {
2046
+ const result = { ...base };
2047
+ for (const key of Object.keys(override)) {
2048
+ const baseVal = base[key];
2049
+ const overrideVal = override[key];
2050
+ if (baseVal && overrideVal && typeof baseVal === "object" && typeof overrideVal === "object" && !Array.isArray(baseVal)) {
2051
+ result[key] = { ...baseVal, ...overrideVal };
2052
+ } else if (overrideVal !== void 0) {
2053
+ result[key] = overrideVal;
2054
+ }
2055
+ }
2056
+ return result;
2057
+ }
2058
+
2059
+ // src/theme/presets/default.ts
2060
+ var defaultPreset = {
2061
+ name: "default"
2062
+ };
1852
2063
  var getColor = (theme, color, fallback) => {
1853
2064
  const hex = get(theme, `colors.${color}`, color);
1854
2065
  try {
@@ -1879,104 +2090,9 @@ function get(obj, path, fallback) {
1879
2090
  }
1880
2091
 
1881
2092
  // src/theme/index.ts
1882
- var system = createSystem(defaultConfig, {
1883
- globalCss: {
1884
- body: {
1885
- color: "default",
1886
- bg: { base: "white", _dark: "#000" }
1887
- },
1888
- "*::placeholder": {
1889
- opacity: 1,
1890
- color: "muted"
1891
- },
1892
- "*, *::before, *::after": {
1893
- borderColor: "border"
1894
- },
1895
- "table, td, th": {
1896
- borderColor: "border"
1897
- },
1898
- "html, body": {
1899
- height: "100%"
1900
- },
1901
- "#__next, #root, #app": {
1902
- display: "flex",
1903
- flexDirection: "column",
1904
- minH: "100%"
1905
- },
1906
- "*": {
1907
- _motionReduce: {
1908
- animationDuration: "0.01ms !important",
1909
- animationIterationCount: "1 !important",
1910
- transitionDuration: "0.01ms !important",
1911
- scrollBehavior: "auto !important"
1912
- }
1913
- }
1914
- },
1915
- theme: {
1916
- tokens: {
1917
- colors: colors_default,
1918
- durations,
1919
- easings,
1920
- fonts: {
1921
- heading: { value: fonts.heading },
1922
- body: { value: fonts.body }
1923
- },
1924
- spacing: Object.fromEntries(
1925
- Object.entries(spacing_default).map(([k, v]) => [k, { value: v }])
1926
- ),
1927
- radii: Object.fromEntries(
1928
- Object.entries(radii_default).map(([k, v]) => [k, { value: v }])
1929
- ),
1930
- zIndex: z_index_default
1931
- },
1932
- textStyles,
1933
- semanticTokens: semantic_default,
1934
- recipes: {
1935
- button: buttonTheme,
1936
- container: container_default,
1937
- prose: proseTheme,
1938
- separator: separator_default,
1939
- formLabel: form_label_default,
1940
- textarea: textarea_default,
1941
- tooltip: tooltipTheme,
1942
- tsRadioCard: radioCardTheme,
1943
- tag: tagTheme
1944
- },
1945
- slotRecipes: {
1946
- card: card_default,
1947
- tsProperty: propertyTheme,
1948
- treeItem: tree_item_default,
1949
- checkbox: checkbox_default,
1950
- comment: comment_default,
1951
- dialog,
1952
- drawer: drawerTheme,
1953
- // Field.Root override: v3 defaults to alignItems: flex-start which
1954
- // shrinks children. Restore v2 behavior where children stretch.
1955
- field: defineSlotRecipe({
1956
- slots: ["root"],
1957
- variants: {
1958
- orientation: {
1959
- vertical: {
1960
- root: {
1961
- alignItems: "stretch"
1962
- }
1963
- }
1964
- }
1965
- }
1966
- }),
1967
- input: input_default,
1968
- menu: menuTheme,
1969
- modal: modalSlotRecipe,
1970
- persona: persona_default,
1971
- popover: popover_default,
1972
- stepper: stepperTheme,
1973
- table: tableTheme,
1974
- tabs: tabTheme
1975
- }
1976
- }
1977
- });
2093
+ var system = createAnkerTheme();
1978
2094
  var theme_default = system;
1979
2095
 
1980
- export { colors_default, durations, easings, fonts, getColor, radii_default, semantic_default, spacing_default, textStyles, theme_default, transparentize, z_index_default };
1981
- //# sourceMappingURL=chunk-YSFUGIQM.js.map
1982
- //# sourceMappingURL=chunk-YSFUGIQM.js.map
2096
+ export { colors_default, createAnkerTheme, defaultPreset, durations, easings, fonts, getColor, keyframes, radii_default, semantic_default, spacing_default, textStyles, theme_default, transparentize, z_index_default };
2097
+ //# sourceMappingURL=chunk-7WPKYUHP.js.map
2098
+ //# sourceMappingURL=chunk-7WPKYUHP.js.map