@ndla/ui 49.0.13 → 50.1.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 (49) hide show
  1. package/es/Breadcrumb/BreadcrumbItem.js +6 -6
  2. package/es/Breadcrumb/HomeBreadcrumb.js +7 -7
  3. package/es/MyNdla/Resource/Folder.js +9 -9
  4. package/es/MyNdla/Resource/FolderInput.js +59 -54
  5. package/es/index.js +0 -1
  6. package/es/locale/messages-en.js +52 -8
  7. package/es/locale/messages-nb.js +53 -9
  8. package/es/locale/messages-nn.js +52 -8
  9. package/es/locale/messages-se.js +52 -8
  10. package/es/locale/messages-sma.js +52 -8
  11. package/lib/Breadcrumb/BreadcrumbItem.d.ts +1 -1
  12. package/lib/Breadcrumb/BreadcrumbItem.js +6 -6
  13. package/lib/Breadcrumb/HomeBreadcrumb.js +7 -7
  14. package/lib/MyNdla/Resource/Folder.js +8 -8
  15. package/lib/MyNdla/Resource/FolderInput.d.ts +7 -4
  16. package/lib/MyNdla/Resource/FolderInput.js +56 -51
  17. package/lib/index.d.ts +0 -1
  18. package/lib/index.js +0 -7
  19. package/lib/locale/messages-en.d.ts +47 -3
  20. package/lib/locale/messages-en.js +52 -8
  21. package/lib/locale/messages-nb.d.ts +47 -3
  22. package/lib/locale/messages-nb.js +53 -9
  23. package/lib/locale/messages-nn.d.ts +47 -3
  24. package/lib/locale/messages-nn.js +52 -8
  25. package/lib/locale/messages-se.d.ts +47 -3
  26. package/lib/locale/messages-se.js +52 -8
  27. package/lib/locale/messages-sma.d.ts +47 -3
  28. package/lib/locale/messages-sma.js +52 -8
  29. package/package.json +11 -12
  30. package/src/Breadcrumb/BreadcrumbItem.tsx +1 -1
  31. package/src/Breadcrumb/HomeBreadcrumb.tsx +1 -1
  32. package/src/MyNdla/Resource/Folder.tsx +2 -2
  33. package/src/MyNdla/Resource/FolderInput.tsx +72 -57
  34. package/src/TreeStructure/TreeStructure.stories.tsx +1 -15
  35. package/src/index.ts +0 -2
  36. package/src/locale/messages-en.ts +50 -4
  37. package/src/locale/messages-nb.ts +51 -4
  38. package/src/locale/messages-nn.ts +50 -3
  39. package/src/locale/messages-se.ts +50 -3
  40. package/src/locale/messages-sma.ts +50 -3
  41. package/es/RadioButtonGroup/RadioButtonGroup.js +0 -118
  42. package/es/RadioButtonGroup/index.js +0 -10
  43. package/lib/RadioButtonGroup/RadioButtonGroup.d.ts +0 -37
  44. package/lib/RadioButtonGroup/RadioButtonGroup.js +0 -128
  45. package/lib/RadioButtonGroup/index.d.ts +0 -9
  46. package/lib/RadioButtonGroup/index.js +0 -17
  47. package/src/RadioButtonGroup/RadioButtonGroup.stories.tsx +0 -126
  48. package/src/RadioButtonGroup/RadioButtonGroup.tsx +0 -185
  49. package/src/RadioButtonGroup/index.ts +0 -11
@@ -1,185 +0,0 @@
1
- /**
2
- * Copyright (c) 2018-present, NDLA.
3
- *
4
- * This source code is licensed under the GPLv3 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
-
9
- import { useMemo } from 'react';
10
- import styled from '@emotion/styled';
11
- import { uuid as uuidFunc } from '@ndla/util';
12
- import { Text } from '@ndla/typography';
13
- import { spacing, fonts, colors, misc } from '@ndla/core';
14
- import { Indicator, Item, RadioGroupItemProps, RadioGroupProps, Root } from '@radix-ui/react-radio-group';
15
-
16
- interface Props {
17
- selected?: string;
18
- className?: string;
19
- options: {
20
- title: string;
21
- value: string;
22
- disabled?: boolean;
23
- }[];
24
- direction?: 'horizontal' | 'vertical';
25
- label?: string;
26
- uniqeIds?: boolean;
27
- onChange: (value: string) => void;
28
- }
29
-
30
- const GroupLabel = styled(Text)`
31
- font-family: ${fonts.sans};
32
- font-weight: ${fonts.weight.semibold};
33
- `;
34
-
35
- const RadioButtonGroupLabel = styled(Text)`
36
- color: ${colors.brand.primary};
37
- font-family: ${fonts.sans};
38
- &[data-disabled='true'] {
39
- color: ${colors.brand.light};
40
- }
41
- `;
42
-
43
- const RadioButtonWrapper = styled.div`
44
- display: flex;
45
- align-items: center;
46
- padding: 0px ${spacing.small};
47
- gap: ${spacing.small};
48
- &:focus-within {
49
- outline: 2px solid ${colors.brand.primary};
50
- border-radius: ${misc.borderRadius};
51
- }
52
- `;
53
-
54
- export const StyledRadioGroupItem = styled(Item)`
55
- all: unset;
56
- transition: 200ms all ease;
57
- box-shadow: 0 0 0 2px ${colors.brand.light};
58
- min-width: ${spacing.nsmall};
59
- min-height: ${spacing.nsmall};
60
- width: ${spacing.nsmall};
61
- height: ${spacing.nsmall};
62
- border-radius: 100%;
63
- &[data-state='checked'] {
64
- box-shadow: 0 0 0 2px ${colors.brand.primary};
65
- }
66
- `;
67
-
68
- const RadioButtonIndicator = styled(Indicator)`
69
- display: flex;
70
- align-items: center;
71
- justify-content: center;
72
- width: 100%;
73
- height: 100%;
74
-
75
- &::after {
76
- content: '';
77
- display: block;
78
- width: 0px;
79
- height: 0px;
80
- border-radius: 50%;
81
- background-color: ${colors.brand.light};
82
- transition: 200ms all ease;
83
- }
84
- &:hover,
85
- &:focus-visible,
86
- &[data-state='checked'] {
87
- &::after {
88
- width: ${spacing.small};
89
- height: ${spacing.small};
90
- }
91
- }
92
- &[data-disabled] {
93
- &::after {
94
- width: 0px;
95
- height: 0px;
96
- }
97
- }
98
-
99
- &[data-state='checked'] {
100
- &::after {
101
- background-color: ${colors.brand.primary};
102
- }
103
- }
104
- `;
105
-
106
- export const StyledRadioButtonGroupRoot = styled(Root)`
107
- padding: ${spacing.small} 0;
108
- gap: ${spacing.small};
109
- display: flex;
110
- font-family: ${fonts.sans};
111
- align-items: center;
112
- &[data-direction='vertical'] {
113
- flex-direction: column;
114
- align-items: unset;
115
- }
116
- `;
117
-
118
- interface ItemProps extends RadioGroupItemProps {}
119
-
120
- export const RadioGroupItem = ({ value, disabled, id, title, className }: ItemProps) => {
121
- return (
122
- <RadioButtonWrapper key={value} className={className}>
123
- <StyledRadioGroupItem disabled={disabled} value={value} id={id}>
124
- <RadioButtonIndicator forceMount />
125
- </StyledRadioGroupItem>
126
- <RadioButtonGroupLabel element="label" textStyle="content" margin="none" htmlFor={id} data-disabled={disabled}>
127
- {title}
128
- </RadioButtonGroupLabel>
129
- </RadioButtonWrapper>
130
- );
131
- };
132
-
133
- interface RootProps extends RadioGroupProps {
134
- direction?: 'horizontal' | 'vertical';
135
- }
136
-
137
- export const RadioButtonGroupRoot = ({ children, direction, ...rest }: RootProps) => {
138
- return (
139
- <StyledRadioButtonGroupRoot data-direction={direction} {...rest}>
140
- {children}
141
- </StyledRadioButtonGroupRoot>
142
- );
143
- };
144
-
145
- const RadioButtonGroup = ({
146
- selected,
147
- options,
148
- label,
149
- uniqeIds,
150
- onChange,
151
- direction = 'horizontal',
152
- className,
153
- }: Props) => {
154
- const uuid = useMemo(() => (uniqeIds ? uuidFunc() : undefined), [uniqeIds]);
155
-
156
- return (
157
- <RadioButtonGroupRoot
158
- data-direction={direction}
159
- value={selected}
160
- defaultValue={selected ?? options[0].value}
161
- className={className}
162
- onValueChange={onChange}
163
- >
164
- {label && (
165
- <GroupLabel element="span" textStyle="content">
166
- {label}
167
- </GroupLabel>
168
- )}
169
- {options.map((option) => {
170
- const id = uuid ? `${uuid}_${option.value}` : option.value;
171
- return (
172
- <RadioGroupItem
173
- key={option.value}
174
- disabled={option.disabled}
175
- value={option.value}
176
- id={id}
177
- title={option.title}
178
- />
179
- );
180
- })}
181
- </RadioButtonGroupRoot>
182
- );
183
- };
184
-
185
- export default RadioButtonGroup;
@@ -1,11 +0,0 @@
1
- /**
2
- * Copyright (c) 2018-present, NDLA.
3
- *
4
- * This source code is licensed under the GPLv3 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
-
9
- import RadioButtonGroup from './RadioButtonGroup';
10
-
11
- export default RadioButtonGroup;