@navikt/ds-react 4.10.2 → 4.11.0

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.
Files changed (64) hide show
  1. package/_docs.json +145 -63
  2. package/cjs/form/combobox/Input/Input.js +5 -2
  3. package/cjs/form/combobox/SelectedOptions/SelectedOptions.js +3 -0
  4. package/cjs/grid/Cell.js +4 -0
  5. package/cjs/grid/Grid.js +4 -0
  6. package/cjs/grid/index.js +1 -3
  7. package/cjs/index.js +2 -0
  8. package/cjs/layout/content-container/index.js +8 -0
  9. package/cjs/layout/content-container/package.json +6 -0
  10. package/cjs/layout/grid/HGrid.js +92 -0
  11. package/cjs/layout/grid/index.js +8 -0
  12. package/cjs/layout/grid/package.json +6 -0
  13. package/cjs/layout/stack/Stack.js +1 -1
  14. package/cjs/layout/utilities/css.js +20 -4
  15. package/esm/form/combobox/Input/Input.js +5 -2
  16. package/esm/form/combobox/Input/Input.js.map +1 -1
  17. package/esm/form/combobox/SelectedOptions/SelectedOptions.js +3 -0
  18. package/esm/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
  19. package/esm/grid/Cell.d.ts +4 -0
  20. package/esm/grid/Cell.js +4 -0
  21. package/esm/grid/Cell.js.map +1 -1
  22. package/esm/grid/Grid.d.ts +4 -0
  23. package/esm/grid/Grid.js +4 -0
  24. package/esm/grid/Grid.js.map +1 -1
  25. package/esm/grid/index.d.ts +0 -1
  26. package/esm/grid/index.js +0 -1
  27. package/esm/grid/index.js.map +1 -1
  28. package/esm/index.d.ts +2 -0
  29. package/esm/index.js +2 -0
  30. package/esm/index.js.map +1 -1
  31. package/esm/layout/content-container/ContentContainer.js.map +1 -0
  32. package/esm/layout/content-container/index.d.ts +1 -0
  33. package/esm/layout/content-container/index.js +2 -0
  34. package/esm/layout/content-container/index.js.map +1 -0
  35. package/esm/layout/grid/HGrid.d.ts +49 -0
  36. package/esm/layout/grid/HGrid.js +64 -0
  37. package/esm/layout/grid/HGrid.js.map +1 -0
  38. package/esm/layout/grid/index.d.ts +1 -0
  39. package/esm/layout/grid/index.js +2 -0
  40. package/esm/layout/grid/index.js.map +1 -0
  41. package/esm/layout/stack/Stack.js +1 -1
  42. package/esm/layout/stack/Stack.js.map +1 -1
  43. package/esm/layout/utilities/css.d.ts +8 -4
  44. package/esm/layout/utilities/css.js +18 -3
  45. package/esm/layout/utilities/css.js.map +1 -1
  46. package/package.json +2 -2
  47. package/src/form/combobox/Input/Input.tsx +6 -0
  48. package/src/form/combobox/SelectedOptions/SelectedOptions.tsx +3 -0
  49. package/src/form/combobox/combobox.stories.tsx +10 -2
  50. package/src/grid/Cell.tsx +4 -0
  51. package/src/grid/Grid.tsx +4 -0
  52. package/src/grid/index.ts +0 -4
  53. package/src/index.ts +2 -0
  54. package/src/layout/content-container/index.ts +4 -0
  55. package/src/layout/grid/HGrid.tsx +101 -0
  56. package/src/layout/grid/h-grid.stories.tsx +102 -0
  57. package/src/layout/grid/index.ts +1 -0
  58. package/src/layout/stack/Stack.tsx +5 -5
  59. package/src/layout/utilities/css.ts +38 -16
  60. package/esm/grid/ContentContainer.js.map +0 -1
  61. /package/cjs/{grid → layout/content-container}/ContentContainer.js +0 -0
  62. /package/esm/{grid → layout/content-container}/ContentContainer.d.ts +0 -0
  63. /package/esm/{grid → layout/content-container}/ContentContainer.js +0 -0
  64. /package/src/{grid → layout/content-container}/ContentContainer.tsx +0 -0
@@ -21,36 +21,58 @@ export type SpacingScale =
21
21
  | "24"
22
22
  | "32";
23
23
 
24
- export type ResponsiveProp<T> =
25
- | T
26
- | {
27
- // eslint-disable-next-line no-unused-vars
28
- [Breakpoint in BreakpointsAlias]?: T;
29
- };
24
+ type ResponsivePropConfig<T = string> = {
25
+ // eslint-disable-next-line no-unused-vars
26
+ [Breakpoint in BreakpointsAlias]?: T;
27
+ };
28
+
29
+ export type ResponsiveProp<T> = T | ResponsivePropConfig<T>;
30
+
31
+ export type ResponsiveValue<T = string> = undefined | ResponsiveProp<T>;
30
32
 
31
- export function getResponsiveProps(
33
+ export function getResponsiveProps<T = string>(
32
34
  componentName: string,
33
35
  componentProp: string,
34
36
  tokenSubgroup: string,
35
- responsiveProp?:
36
- | string
37
- | {
38
- // eslint-disable-next-line no-unused-vars
39
- [Breakpoint in BreakpointsAlias]?: string;
40
- }
37
+ responsiveProp?: ResponsiveProp<T>
41
38
  ) {
42
- if (!responsiveProp) return {};
39
+ if (!responsiveProp) {
40
+ return {};
41
+ }
43
42
 
44
43
  if (typeof responsiveProp === "string") {
45
44
  return {
46
- [`--ac-${componentName}-${componentProp}-xs`]: `var(--a-${tokenSubgroup}-${responsiveProp})`,
45
+ [`--__ac-${componentName}-${componentProp}-xs`]: `var(--a-${tokenSubgroup}-${responsiveProp})`,
47
46
  };
48
47
  }
49
48
 
50
49
  return Object.fromEntries(
51
50
  Object.entries(responsiveProp).map(([breakpointAlias, aliasOrScale]) => [
52
- `--ac-${componentName}-${componentProp}-${breakpointAlias}`,
51
+ `--__ac-${componentName}-${componentProp}-${breakpointAlias}`,
53
52
  `var(--a-${tokenSubgroup}-${aliasOrScale})`,
54
53
  ])
55
54
  );
56
55
  }
56
+
57
+ export function getResponsiveValue<T = string>(
58
+ componentName: string,
59
+ componentProp: string,
60
+ responsiveProp?: ResponsiveValue<T>
61
+ ) {
62
+ if (!responsiveProp) {
63
+ return {};
64
+ }
65
+
66
+ if (typeof responsiveProp === "string") {
67
+ return {
68
+ [`--__ac-${componentName}-${componentProp}-xs`]: responsiveProp,
69
+ };
70
+ }
71
+
72
+ return Object.fromEntries(
73
+ Object.entries(responsiveProp).map(([breakpointAlias, responsiveValue]) => [
74
+ `--__ac-${componentName}-${componentProp}-${breakpointAlias}`,
75
+ responsiveValue,
76
+ ])
77
+ );
78
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"ContentContainer.js","sourceRoot":"","sources":["../../src/grid/ContentContainer.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,MAAM,MAAM,CAAC;AAStB,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAGxC,CAAC,EAAsB,EAAE,GAAG,EAAE,EAAE;QAA/B,EAAE,SAAS,OAAW,EAAN,IAAI,cAApB,aAAsB,CAAF;IAAY,OAAA,CACjC,2CACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,yBAAyB,EAAE,SAAS,CAAC,IAC/C,IAAI,EACR,CACH,CAAA;CAAA,CAAC,CAAC;AAEH,eAAe,gBAAgB,CAAC"}