@ilo-org/react 0.10.5 → 0.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 (195) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/lib/cjs/AccordionCtx-be704051.js +9 -0
  3. package/lib/cjs/{GlobalCtx-97e4b433.js → GlobalCtx-10114bdd.js} +2 -2
  4. package/lib/cjs/ListCtx-14aa546f.js +9 -0
  5. package/lib/cjs/TagCtx-690a1d54.js +7 -0
  6. package/lib/cjs/components/Accordion/Accordion.js +6 -6
  7. package/lib/cjs/components/Accordion/AccordionButton.js +5 -5
  8. package/lib/cjs/components/Accordion/AccordionItem.js +2 -2
  9. package/lib/cjs/components/Accordion/AccordionPanel.js +8 -8
  10. package/lib/cjs/components/Accordion/index.js +2 -2
  11. package/lib/cjs/components/Breadcrumb/Breadcrumb.js +5 -5
  12. package/lib/cjs/components/Breadcrumb/index.js +1 -1
  13. package/lib/cjs/components/Button/Button.js +1 -1
  14. package/lib/cjs/components/Button/index.js +1 -1
  15. package/lib/cjs/components/Callout/Callout.js +4 -4
  16. package/lib/cjs/components/Callout/index.js +1 -1
  17. package/lib/cjs/components/Card/Card.js +2 -2
  18. package/lib/cjs/components/Card/CardGroup.js +2 -2
  19. package/lib/cjs/components/Card/index.js +2 -2
  20. package/lib/cjs/components/Checkbox/Checkbox.js +5 -5
  21. package/lib/cjs/components/Checkbox/index.js +1 -1
  22. package/lib/cjs/components/Collapse/Collapse.js +1194 -44
  23. package/lib/cjs/components/Collapse/index.js +0 -1
  24. package/lib/cjs/components/ContextMenu/ContextMenu.js +1 -1
  25. package/lib/cjs/components/ContextMenu/index.js +1 -1
  26. package/lib/cjs/components/Credit/Credit.js +3 -3
  27. package/lib/cjs/components/Credit/index.js +1 -1
  28. package/lib/cjs/components/DatePicker/DatePicker.js +4 -4
  29. package/lib/cjs/components/DatePicker/index.js +1 -1
  30. package/lib/cjs/components/Dropdown/Dropdown.js +5 -5
  31. package/lib/cjs/components/Dropdown/index.js +1 -1
  32. package/lib/cjs/components/Empty/Empty.js +1 -1
  33. package/lib/cjs/components/Empty/index.js +1 -1
  34. package/lib/cjs/components/Fieldset/Fieldset.js +5 -5
  35. package/lib/cjs/components/Fieldset/index.js +1 -1
  36. package/lib/cjs/components/FileUpload/FileUpload.js +5 -5
  37. package/lib/cjs/components/FileUpload/index.js +1 -1
  38. package/lib/cjs/components/Footer/Footer.js +1 -1
  39. package/lib/cjs/components/Footer/index.js +1 -1
  40. package/lib/cjs/components/Form/Form.js +3 -3
  41. package/lib/cjs/components/Form/index.js +1 -1
  42. package/lib/cjs/components/FormControl/FormControl.js +7 -7
  43. package/lib/cjs/components/FormControl/index.js +1 -1
  44. package/lib/cjs/components/GlobalProvider/GlobalProvider.js +1 -1
  45. package/lib/cjs/components/GlobalProvider/index.js +1 -1
  46. package/lib/cjs/components/Heading/Heading.js +1 -1
  47. package/lib/cjs/components/Heading/index.js +1 -1
  48. package/lib/cjs/components/Hero/Hero.js +1 -1
  49. package/lib/cjs/components/Hero/HeroCard.js +1 -1
  50. package/lib/cjs/components/Hero/index.js +1 -1
  51. package/lib/cjs/components/Icon/Icon.js +3 -3
  52. package/lib/cjs/components/Icon/index.js +1 -1
  53. package/lib/cjs/components/Image/Image.js +1 -1
  54. package/lib/cjs/components/Image/index.js +1 -1
  55. package/lib/cjs/components/Input/Input.js +3 -3
  56. package/lib/cjs/components/Input/index.js +1 -1
  57. package/lib/cjs/components/Link/Link.js +1 -1
  58. package/lib/cjs/components/Link/index.js +1 -1
  59. package/lib/cjs/components/LinkList/LinkList.js +1 -1
  60. package/lib/cjs/components/LinkList/index.js +1 -1
  61. package/lib/cjs/components/List/List.js +4 -4
  62. package/lib/cjs/components/List/ListItem.js +2 -2
  63. package/lib/cjs/components/List/index.js +2 -2
  64. package/lib/cjs/components/Loading/Loading.js +1 -1
  65. package/lib/cjs/components/Loading/index.js +1 -1
  66. package/lib/cjs/components/LocalNav/LocalNav.js +4 -4
  67. package/lib/cjs/components/LocalNav/index.js +1 -1
  68. package/lib/cjs/components/Logo/Logo.js +15 -15
  69. package/lib/cjs/components/Logo/index.js +1 -1
  70. package/lib/cjs/components/LogoGrid/LogoGrid.js +1 -1
  71. package/lib/cjs/components/LogoGrid/index.js +1 -1
  72. package/lib/cjs/components/Navigation/Navigation.js +8 -6
  73. package/lib/cjs/components/Navigation/index.js +3 -1
  74. package/lib/cjs/components/Notification/Notification.js +3 -3
  75. package/lib/cjs/components/Notification/index.js +1 -1
  76. package/lib/cjs/components/NumberPicker/NumberPicker.js +4 -4
  77. package/lib/cjs/components/NumberPicker/index.js +1 -1
  78. package/lib/cjs/components/Pagination/Pagination.js +1 -1
  79. package/lib/cjs/components/Pagination/index.js +1 -1
  80. package/lib/cjs/components/Profile/Profile.js +1 -1
  81. package/lib/cjs/components/Profile/index.js +1 -1
  82. package/lib/cjs/components/Radio/Radio.js +5 -5
  83. package/lib/cjs/components/Radio/index.js +1 -1
  84. package/lib/cjs/components/ReadMore/ReadMore.js +4 -4
  85. package/lib/cjs/components/ReadMore/index.js +1 -1
  86. package/lib/cjs/components/RichText/RichText.js +1 -1
  87. package/lib/cjs/components/RichText/index.js +1 -1
  88. package/lib/cjs/components/SearchField/SearchField.js +16 -6
  89. package/lib/cjs/components/SearchField/index.js +4 -2
  90. package/lib/cjs/components/SocialMedia/SocialMedia.js +1 -1
  91. package/lib/cjs/components/SocialMedia/index.js +1 -1
  92. package/lib/cjs/components/TableOfContents/TableOfContents.js +1 -1
  93. package/lib/cjs/components/TableOfContents/index.js +1 -1
  94. package/lib/cjs/components/Tabs/Tabs.args.js +156 -0
  95. package/lib/cjs/components/Tabs/Tabs.js +24 -0
  96. package/lib/cjs/components/Tabs/index.js +15 -0
  97. package/lib/cjs/components/Tag/Tag.js +4 -4
  98. package/lib/cjs/components/Tag/TagSet.js +6 -6
  99. package/lib/cjs/components/Tag/index.js +2 -2
  100. package/lib/cjs/components/TextInput/TextInput.js +4 -4
  101. package/lib/cjs/components/TextInput/index.js +1 -1
  102. package/lib/cjs/components/Textarea/Textarea.js +4 -4
  103. package/lib/cjs/components/Textarea/index.js +1 -1
  104. package/lib/cjs/components/Toggle/Toggle.js +4 -4
  105. package/lib/cjs/components/Toggle/index.js +1 -1
  106. package/lib/cjs/components/Tooltip/Tooltip.js +5 -5
  107. package/lib/cjs/components/Tooltip/index.js +1 -1
  108. package/lib/cjs/components/Video/Video.js +11 -12
  109. package/lib/cjs/components/Video/VideoPlayer.js +55 -13
  110. package/lib/cjs/components/Video/index.js +6 -8
  111. package/lib/cjs/components/index.js +9 -8
  112. package/lib/cjs/hooks/index.js +1 -1
  113. package/lib/cjs/hooks/useGlobalSettings.js +3 -3
  114. package/lib/cjs/hooks/usePrevious.js +3 -3
  115. package/lib/cjs/hooks/useVideoPlayer.js +7 -7
  116. package/lib/cjs/index.js +9 -8
  117. package/lib/esm/components/Collapse/Collapse.js +1156 -6
  118. package/lib/esm/components/Collapse/index.js +0 -1
  119. package/lib/esm/components/FileUpload/FileUpload.js +3 -3
  120. package/lib/esm/components/Input/Input.js +2 -2
  121. package/lib/esm/components/Navigation/Navigation.js +2 -0
  122. package/lib/esm/components/Navigation/index.js +2 -0
  123. package/lib/esm/components/NumberPicker/NumberPicker.js +3 -3
  124. package/lib/esm/components/Radio/Radio.js +3 -3
  125. package/lib/esm/components/SearchField/SearchField.js +15 -5
  126. package/lib/esm/components/SearchField/index.js +3 -1
  127. package/lib/esm/components/Tabs/Tabs.args.js +154 -0
  128. package/lib/esm/components/Tabs/Tabs.js +22 -0
  129. package/lib/esm/components/Tabs/index.js +9 -0
  130. package/lib/esm/components/TextInput/TextInput.js +3 -3
  131. package/lib/esm/components/Textarea/Textarea.js +3 -3
  132. package/lib/esm/components/Video/Video.js +10 -11
  133. package/lib/esm/components/Video/VideoPlayer.js +57 -11
  134. package/lib/esm/components/Video/index.js +5 -7
  135. package/lib/esm/components/index.js +4 -4
  136. package/lib/esm/index.js +4 -4
  137. package/lib/types/react/src/components/Input/Input.props.d.ts +1 -0
  138. package/lib/types/react/src/components/Tabs/Tabs.args.d.ts +10 -0
  139. package/lib/types/react/src/components/Tabs/Tabs.d.ts +4 -0
  140. package/lib/types/react/src/components/Tabs/Tabs.props.d.ts +12 -0
  141. package/lib/types/react/src/components/Tabs/index.d.ts +1 -0
  142. package/lib/types/react/src/components/Video/Video.d.ts +2 -2
  143. package/lib/types/react/src/components/Video/Video.props.d.ts +5 -43
  144. package/lib/types/react/src/components/Video/VideoPlayer.d.ts +3 -3
  145. package/lib/types/react/src/components/Video/VideoPlayer.props.d.ts +6 -31
  146. package/lib/types/react/src/components/index.d.ts +1 -0
  147. package/package.json +6 -4
  148. package/src/components/Input/Input.props.ts +2 -0
  149. package/src/components/Input/Input.tsx +2 -0
  150. package/src/components/SearchField/SearchField.args.ts +5 -0
  151. package/src/components/SearchField/SearchField.tsx +38 -16
  152. package/src/components/Tabs/Tabs.args.tsx +201 -0
  153. package/src/components/Tabs/Tabs.props.ts +13 -0
  154. package/src/components/Tabs/Tabs.tsx +60 -0
  155. package/src/components/Tabs/index.ts +1 -0
  156. package/src/components/Video/Video.args.ts +18 -24
  157. package/src/components/Video/Video.props.ts +5 -47
  158. package/src/components/Video/Video.tsx +24 -19
  159. package/src/components/Video/VideoPlayer.props.ts +7 -38
  160. package/src/components/Video/VideoPlayer.tsx +67 -322
  161. package/src/components/index.ts +1 -0
  162. package/src/declarations.d.ts +22 -0
  163. package/lib/cjs/AccordionCtx-fe08ff45.js +0 -9
  164. package/lib/cjs/DailyMotion-17b56ecb.js +0 -259
  165. package/lib/cjs/Facebook-0c8d86ee.js +0 -239
  166. package/lib/cjs/FilePlayer-01d6dc08.js +0 -596
  167. package/lib/cjs/Kaltura-40e8e581.js +0 -235
  168. package/lib/cjs/ListCtx-7db7fe04.js +0 -9
  169. package/lib/cjs/Mixcloud-e23f49d6.js +0 -222
  170. package/lib/cjs/Preview-8e490f54.js +0 -227
  171. package/lib/cjs/SoundCloud-2500b6cb.js +0 -249
  172. package/lib/cjs/Streamable-00723065.js +0 -234
  173. package/lib/cjs/TagCtx-929c7753.js +0 -7
  174. package/lib/cjs/Twitch-2c5c5733.js +0 -244
  175. package/lib/cjs/VideoPlayer-5f0a64c6.js +0 -2067
  176. package/lib/cjs/Vidyard-d36d6c45.js +0 -237
  177. package/lib/cjs/Vimeo-d311e3b8.js +0 -285
  178. package/lib/cjs/Wistia-318b4e43.js +0 -288
  179. package/lib/cjs/YouTube-a3796a55.js +0 -377
  180. package/lib/cjs/index-0af02e81.js +0 -1154
  181. package/lib/esm/DailyMotion-989c2db3.js +0 -257
  182. package/lib/esm/Facebook-04e9cc59.js +0 -237
  183. package/lib/esm/FilePlayer-0789336d.js +0 -594
  184. package/lib/esm/Kaltura-a9ed37a9.js +0 -233
  185. package/lib/esm/Mixcloud-5a3b4353.js +0 -220
  186. package/lib/esm/Preview-7ca1835e.js +0 -225
  187. package/lib/esm/SoundCloud-47bccd79.js +0 -247
  188. package/lib/esm/Streamable-ee762126.js +0 -232
  189. package/lib/esm/Twitch-3cd4b54b.js +0 -242
  190. package/lib/esm/VideoPlayer-96c2b20c.js +0 -2062
  191. package/lib/esm/Vidyard-258ab0ef.js +0 -235
  192. package/lib/esm/Vimeo-4b29b580.js +0 -283
  193. package/lib/esm/Wistia-3cbce669.js +0 -286
  194. package/lib/esm/YouTube-db52da1c.js +0 -375
  195. package/lib/esm/index-623ce3f5.js +0 -1152
@@ -0,0 +1,10 @@
1
+ import { TabsProps } from "./Tabs.props";
2
+ /**
3
+ * Sample prop definitions for Button's enumerable properties (imported in stories and tests).
4
+ */
5
+ declare const TabsArgs: {
6
+ tabs: TabsProps;
7
+ withIcon: TabsProps;
8
+ fiveItems: TabsProps;
9
+ };
10
+ export default TabsArgs;
@@ -0,0 +1,4 @@
1
+ import { FC } from "react";
2
+ import { TabsProps } from "./Tabs.props";
3
+ declare const Tabs: FC<TabsProps>;
4
+ export default Tabs;
@@ -0,0 +1,12 @@
1
+ import { IconProps } from "../Icon/Icon.props";
2
+ export interface TabsProps {
3
+ /**
4
+ * Specify the items inside a tab
5
+ */
6
+ items: Required<Array<TabItem>>;
7
+ }
8
+ export interface TabItem {
9
+ icon?: IconProps;
10
+ label: Required<string>;
11
+ content: Required<any>;
12
+ }
@@ -0,0 +1 @@
1
+ export { default as Tabs } from "./Tabs";
@@ -1,4 +1,4 @@
1
- import { FC } from "react";
2
1
  import { VideoProps } from "./Video.props";
3
- declare const Video: FC<VideoProps>;
2
+ import { VideoPlayerRef } from "./VideoPlayer.props";
3
+ declare const Video: import("react").ForwardRefExoticComponent<VideoProps & import("react").RefAttributes<VideoPlayerRef>>;
4
4
  export default Video;
@@ -1,51 +1,18 @@
1
- import { TracksConfig } from "./VideoPlayer.props";
1
+ import { VideoPlayerControls } from "./VideoPlayer.props";
2
2
  export interface Poster {
3
- url: {
4
- src: string;
5
- }[];
3
+ src: string;
6
4
  alt: string;
7
5
  }
8
- interface VideoPlayerControls {
9
- /**
10
- * Specify the label for the fullscreen button
11
- */
12
- fullscreen?: Required<string>;
13
- /**
14
- * Specify the label for the play button
15
- */
16
- play?: Required<string>;
17
- /**
18
- * Specify the label for the pause button
19
- */
20
- pause?: Required<string>;
21
- /**
22
- * Specify the label for the volume button
23
- */
24
- volume?: Required<string>;
25
- }
26
- interface Video {
6
+ export interface VideoProps {
7
+ src: string;
27
8
  /**
28
9
  * Specify the strings to be used as labels for the video controls
29
10
  */
30
- controls?: Required<VideoPlayerControls | false>;
31
- /**
32
- * if self-hosted, specify the url of this video
33
- */
34
- src?: string | null;
35
- /**
36
- * if there are closed-caption tracks,
37
- */
38
- tracks?: TracksConfig[];
11
+ controls?: VideoPlayerControls;
39
12
  /**
40
13
  * if YouTube, set to true
41
14
  */
42
15
  youtube?: boolean;
43
- }
44
- export interface VideoProps {
45
- /**
46
- * Specify the alt for the image
47
- */
48
- alt: string;
49
16
  /**
50
17
  * Specify the caption for the image/video
51
18
  */
@@ -58,9 +25,4 @@ export interface VideoProps {
58
25
  * Specify the image src for the image
59
26
  */
60
27
  poster?: Poster;
61
- /**
62
- * Specify whether there is a video being shown
63
- */
64
- video: Video;
65
28
  }
66
- export {};
@@ -1,4 +1,4 @@
1
- import { FC } from "react";
2
- import { VideoPlayerProps } from "./VideoPlayer.props";
3
- declare const VideoPlayer: FC<VideoPlayerProps>;
1
+ import "videojs-youtube";
2
+ import { VideoPlayerProps, VideoPlayerRef } from "./VideoPlayer.props";
3
+ declare const VideoPlayer: import("react").ForwardRefExoticComponent<VideoPlayerProps & import("react").RefAttributes<VideoPlayerRef>>;
4
4
  export default VideoPlayer;
@@ -1,4 +1,8 @@
1
1
  import { Poster } from "./Video.props";
2
+ import videojs from "video.js";
3
+ export interface VideoPlayerRef {
4
+ player: videojs.Player | undefined;
5
+ }
2
6
  export interface VideoPlayerControls {
3
7
  /**
4
8
  * Specify the label for the fullscreen button
@@ -17,25 +21,8 @@ export interface VideoPlayerControls {
17
21
  */
18
22
  volume: string;
19
23
  }
20
- export interface TracksConfig {
21
- /**
22
- * is this the default track?
23
- */
24
- default?: boolean;
25
- /**
26
- * What kind of track is it?
27
- */
28
- kind?: string;
29
- /**
30
- * url for the track
31
- */
32
- src?: string;
33
- /**
34
- * language of the track
35
- */
36
- srcLang?: string;
37
- }
38
24
  export interface VideoPlayerProps {
25
+ src: string;
39
26
  /**
40
27
  * Specify an optional className to be added to your Media.
41
28
  */
@@ -43,23 +30,11 @@ export interface VideoPlayerProps {
43
30
  /**
44
31
  * Specify the strings to be used as labels for the video controls
45
32
  */
46
- controls?: Required<VideoPlayerControls | false>;
47
- /**
48
- * Specify whether a video is to be shown
49
- */
50
- hasvideo?: Required<boolean>;
33
+ controls?: VideoPlayerControls;
51
34
  /**
52
35
  * poster image for video
53
36
  */
54
37
  poster?: Poster;
55
- /**
56
- * if self-hosted, specify the url of this video
57
- */
58
- src?: string | null;
59
- /**
60
- * if there are closed-caption tracks,
61
- */
62
- tracks?: Required<Array<TracksConfig>> | null;
63
38
  /**
64
39
  * if YouTube, set to true
65
40
  */
@@ -38,3 +38,4 @@ export { LocalNav } from "./LocalNav";
38
38
  export { Navigation } from "./Navigation";
39
39
  export { Card, CardGroup } from "./Card";
40
40
  export { Breadcrumb } from "./Breadcrumb";
41
+ export { Tabs } from "./Tabs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ilo-org/react",
3
- "version": "0.10.5",
3
+ "version": "0.11.0",
4
4
  "description": "React components for the ILO's Design System",
5
5
  "keywords": [
6
6
  "ui_patterns",
@@ -72,13 +72,14 @@
72
72
  "classnames": "^2.3.1",
73
73
  "dom-helpers": "^5.2.1",
74
74
  "nanoid": "^3.3.6",
75
- "react-player": "2.10.1",
76
75
  "react-transition-group": "^4.4.1",
76
+ "video.js": "^7.21.2",
77
+ "videojs-youtube": "^3.0.1",
77
78
  "@ilo-org/brand-assets": "0.4.0",
78
79
  "@ilo-org/fonts": "0.1.2",
79
80
  "@ilo-org/icons-react": "0.0.21",
80
- "@ilo-org/styles": "0.13.3",
81
- "@ilo-org/themes": "0.7.1",
81
+ "@ilo-org/styles": "0.14.1",
82
+ "@ilo-org/themes": "0.7.2",
82
83
  "@ilo-org/utils": "0.0.11"
83
84
  },
84
85
  "devDependencies": {
@@ -107,6 +108,7 @@
107
108
  "@types/node": "^17.0.45",
108
109
  "@types/react": "^17.0.11",
109
110
  "@types/react-dom": "^17.0.20",
111
+ "@types/video.js": "7",
110
112
  "http-server": "^14.1.0",
111
113
  "identity-obj-proxy": "^3.0.0",
112
114
  "jest-environment-jsdom": "27.5.1",
@@ -60,4 +60,6 @@ export interface InputProps {
60
60
  * The input's type.
61
61
  */
62
62
  type: TextInputTypes;
63
+
64
+ value: string;
63
65
  }
@@ -16,6 +16,7 @@ const Input: FC<InputProps> = ({
16
16
  placeholder,
17
17
  required,
18
18
  tooltip,
19
+ value,
19
20
  type = "text",
20
21
  }) => {
21
22
  const { prefix } = useGlobalSettings();
@@ -53,6 +54,7 @@ const Input: FC<InputProps> = ({
53
54
  placeholder={placeholder}
54
55
  required={required as any}
55
56
  type={type}
57
+ value={value}
56
58
  className={InputClasses}
57
59
  />
58
60
  </FormElement>
@@ -8,6 +8,7 @@ const searchfield: SearchFieldProps = {
8
8
  name: "search",
9
9
  placeholder: "Search Field",
10
10
  type: "search",
11
+ value: "",
11
12
  },
12
13
  };
13
14
 
@@ -20,6 +21,7 @@ const searchfielderror: SearchFieldProps = {
20
21
  name: "search",
21
22
  placeholder: "Search Field",
22
23
  type: "search",
24
+ value: "",
23
25
  },
24
26
  };
25
27
 
@@ -31,6 +33,7 @@ const searchfielddisabled: SearchFieldProps = {
31
33
  name: "search",
32
34
  placeholder: "Search Field",
33
35
  type: "search",
36
+ value: "",
34
37
  },
35
38
  };
36
39
 
@@ -41,6 +44,7 @@ const searchfieldlabel: SearchFieldProps = {
41
44
  name: "search",
42
45
  placeholder: "Search Field",
43
46
  type: "search",
47
+ value: "",
44
48
  },
45
49
  };
46
50
 
@@ -51,6 +55,7 @@ const searchfieldhelper: SearchFieldProps = {
51
55
  name: "search",
52
56
  placeholder: "Search Field",
53
57
  type: "search",
58
+ value: "",
54
59
  },
55
60
  };
56
61
 
@@ -1,8 +1,9 @@
1
- import { FC } from "react";
1
+ import { FC, useState } from "react";
2
2
  import classNames from "classnames";
3
3
  import useGlobalSettings from "../../hooks/useGlobalSettings";
4
4
  import { SearchFieldProps } from "./SearchField.props";
5
5
  import { Input } from "../Input";
6
+ import { Icon } from "../Icon";
6
7
 
7
8
  const SearchField: FC<SearchFieldProps> = ({
8
9
  action,
@@ -10,24 +11,39 @@ const SearchField: FC<SearchFieldProps> = ({
10
11
  className,
11
12
  input,
12
13
  }) => {
14
+ const [searchValue, setSearchValue] = useState("");
15
+
13
16
  const { prefix } = useGlobalSettings();
14
17
  const baseClass = `${prefix}--searchfield`;
15
18
  const buttonClass = `${baseClass}--button`;
19
+ const clearButtonClass = `${baseClass}--clear-button ${
20
+ searchValue.trim() !== "" && "show"
21
+ }`;
22
+ const fieldSetClass = `${prefix}--fieldset`;
16
23
 
17
24
  const SearchFieldClasses = classNames(className, {
18
25
  [baseClass]: true,
19
26
  [`haslabel`]: input?.label,
20
27
  });
21
28
 
22
- /**
23
- * On click, if there is a callback, call it
24
- */
25
29
  const handleClick: React.MouseEventHandler<HTMLInputElement> = (e) => {
26
30
  if (callback) {
27
31
  callback(e);
28
32
  }
29
33
  };
30
34
 
35
+ // handle click for clear button in search
36
+ const handleClearButtonClick: React.MouseEventHandler<
37
+ HTMLInputElement
38
+ > = () => {
39
+ setSearchValue("");
40
+ };
41
+
42
+ // Update search value on input
43
+ const onKeyPress: React.ChangeEventHandler<HTMLInputElement> = (e) => {
44
+ setSearchValue(e.target.value);
45
+ };
46
+
31
47
  const inputHasType = !!input?.type;
32
48
 
33
49
  if (!inputHasType) {
@@ -36,18 +52,24 @@ const SearchField: FC<SearchFieldProps> = ({
36
52
 
37
53
  return inputHasType ? (
38
54
  <form className={SearchFieldClasses} action={action}>
39
- <Input
40
- id={input?.id}
41
- name={input?.name}
42
- disabled={input?.disabled}
43
- callback={input?.callback}
44
- error={input?.error}
45
- helper={input?.helper}
46
- label={input?.label}
47
- placeholder={input?.placeholder}
48
- type={input?.type}
49
- className={`${prefix}--input`}
50
- />
55
+ <div className={fieldSetClass}>
56
+ <Input
57
+ id={input?.id}
58
+ name={input?.name}
59
+ disabled={input?.disabled}
60
+ callback={onKeyPress}
61
+ error={input?.error}
62
+ helper={input?.helper}
63
+ label={input?.label}
64
+ placeholder={input?.placeholder}
65
+ type={input?.type}
66
+ value={searchValue}
67
+ className={`${prefix}--input`}
68
+ />
69
+ <span onClick={handleClearButtonClick} className={clearButtonClass}>
70
+ <Icon name="close" hidden={true} />
71
+ </span>
72
+ </div>
51
73
  <input
52
74
  className={buttonClass}
53
75
  disabled={input?.disabled}
@@ -0,0 +1,201 @@
1
+ import { RichText } from "../RichText";
2
+ import { Image } from "../Image";
3
+ import { TabsProps } from "./Tabs.props";
4
+
5
+ const tabs: TabsProps = {
6
+ items: [
7
+ {
8
+ label:
9
+ "Tab Label With A Really Really Lenghty Title Even Though We Do Not Recommend Such A Lengthy Title",
10
+ content: (
11
+ <Image
12
+ alt="My alt text"
13
+ caption="Women construction workers in Nepal build roads and bridges as part of a National Rural Transport Programme co-sponsored by the ILO."
14
+ credit="© Marcel Crozet/ILO"
15
+ url={[
16
+ { breakpoint: 0, src: "/small.jpg" },
17
+ { breakpoint: 800, src: "/medium.jpg" },
18
+ { breakpoint: 1200, src: "/large.jpg" },
19
+ { breakpoint: 1440, src: "/large.jpg" },
20
+ ]}
21
+ />
22
+ ),
23
+ },
24
+ {
25
+ label: "Tab Label 2",
26
+ content: (
27
+ <RichText content="<h2>International Labour Organization</h2> <p>The <b>International Labour Organization</b> (<b>ILO</b>) is a <a href='https://www.un.org'>United Nations</a> agency whose mandate is to advance social and economic justice by setting international labour standards. Founded in October 1919 under the League of Nations, it is the first and oldest specialised agency of the UN. The ILO has 187 member states: 186 out of 193 UN member states plus the Cook Islands.</p> <p>Whereas also the failure of any nation to adopt humane conditions of labour is an obstacle in the way of other nations which desire to improve the conditions in their own countries.</p> <figure><img alt='placeholder image' class='right' src='/ilo-headquarters.jpg'><figcaption>The ILO's headquarters in Geneva, Switzerland. ©Steiner SA</figcaption></figure> <h3>ILO Constitution</h3> <p>The driving forces for the ILO's creation arose from security, humanitarian, political and economic considerations.</p> <blockquote> <p>The fundamental ideas that forged the ILO one hundred and three years ago still underpin the global pledge to leave no one behind.</p> <cite>ILO Director-General Gilbert F. Houngbo</cite> </blockquote> Reflecting these ideas, the Preamble of the ILO Constitution states:</p> <ol> <li>Whereas universal and lasting peace can be established only if it is based upon social justice;</li> <li>And whereas conditions of labour exist involving such injustice, hardship and privation to large numbers of people as to produce unrest so great that the peace and harmony of the world are imperilled; and an improvement of those conditions is urgently required;</li> <li>Whereas also the failure of any nation to adopt humane conditions of labour is an obstacle in the way of other nations which desire to improve the conditions in their own countries.</li> </ol>" />
28
+ ),
29
+ },
30
+ ],
31
+ };
32
+
33
+ const withIcon: TabsProps = {
34
+ items: [
35
+ {
36
+ icon: {
37
+ hidden: false,
38
+ name: "info",
39
+ },
40
+ label:
41
+ "Tab Label With A Really Really Lenghty Title Even Though We Do Not Recommend Such A Lengthy Title",
42
+ content: (
43
+ <Image
44
+ alt="My alt text"
45
+ caption="Women construction workers in Nepal build roads and bridges as part of a National Rural Transport Programme co-sponsored by the ILO."
46
+ credit="© Marcel Crozet/ILO"
47
+ url={[
48
+ { breakpoint: 0, src: "/small.jpg" },
49
+ { breakpoint: 800, src: "/medium.jpg" },
50
+ { breakpoint: 1200, src: "/large.jpg" },
51
+ { breakpoint: 1440, src: "/large.jpg" },
52
+ ]}
53
+ />
54
+ ),
55
+ },
56
+ {
57
+ icon: {
58
+ hidden: false,
59
+ name: "info",
60
+ },
61
+ label: "Tab Label 2",
62
+ content: (
63
+ <RichText content="<h2>International Labour Organization</h2> <p>The <b>International Labour Organization</b> (<b>ILO</b>) is a <a href='https://www.un.org'>United Nations</a> agency whose mandate is to advance social and economic justice by setting international labour standards. Founded in October 1919 under the League of Nations, it is the first and oldest specialised agency of the UN. The ILO has 187 member states: 186 out of 193 UN member states plus the Cook Islands.</p> <p>Whereas also the failure of any nation to adopt humane conditions of labour is an obstacle in the way of other nations which desire to improve the conditions in their own countries.</p> <figure><img alt='placeholder image' class='right' src='/ilo-headquarters.jpg'><figcaption>The ILO's headquarters in Geneva, Switzerland. ©Steiner SA</figcaption></figure> <h3>ILO Constitution</h3> <p>The driving forces for the ILO's creation arose from security, humanitarian, political and economic considerations.</p> <blockquote> <p>The fundamental ideas that forged the ILO one hundred and three years ago still underpin the global pledge to leave no one behind.</p> <cite>ILO Director-General Gilbert F. Houngbo</cite> </blockquote> Reflecting these ideas, the Preamble of the ILO Constitution states:</p> <ol> <li>Whereas universal and lasting peace can be established only if it is based upon social justice;</li> <li>And whereas conditions of labour exist involving such injustice, hardship and privation to large numbers of people as to produce unrest so great that the peace and harmony of the world are imperilled; and an improvement of those conditions is urgently required;</li> <li>Whereas also the failure of any nation to adopt humane conditions of labour is an obstacle in the way of other nations which desire to improve the conditions in their own countries.</li> </ol>" />
64
+ ),
65
+ },
66
+ ],
67
+ };
68
+
69
+ const fiveItems: TabsProps = {
70
+ items: [
71
+ {
72
+ label: "Tab One",
73
+ content: (
74
+ <RichText content="<h2>International Labour Organization</h2> <p>The <b>International Labour Organization</b> (<b>ILO</b>) is a <a href='https://www.un.org'>United Nations</a> agency whose mandate is to advance social and economic justice by setting international labour standards. Founded in October 1919 under the League of Nations, it is the first and oldest specialised agency of the UN. The ILO has 187 member states: 186 out of 193 UN member states plus the Cook Islands.</p> <p>Whereas also the failure of any nation to adopt humane conditions of labour is an obstacle in the way of other nations which desire to improve the conditions in their own countries.</p> <figure><img alt='placeholder image' class='right' src='/ilo-headquarters.jpg'><figcaption>The ILO's headquarters in Geneva, Switzerland. ©Steiner SA</figcaption></figure> <h3>ILO Constitution</h3> <p>The driving forces for the ILO's creation arose from security, humanitarian, political and economic considerations.</p> <blockquote> <p>The fundamental ideas that forged the ILO one hundred and three years ago still underpin the global pledge to leave no one behind.</p> <cite>ILO Director-General Gilbert F. Houngbo</cite> </blockquote> Reflecting these ideas, the Preamble of the ILO Constitution states:</p> <ol> <li>Whereas universal and lasting peace can be established only if it is based upon social justice;</li> <li>And whereas conditions of labour exist involving such injustice, hardship and privation to large numbers of people as to produce unrest so great that the peace and harmony of the world are imperilled; and an improvement of those conditions is urgently required;</li> <li>Whereas also the failure of any nation to adopt humane conditions of labour is an obstacle in the way of other nations which desire to improve the conditions in their own countries.</li> </ol>" />
75
+ ),
76
+ },
77
+ {
78
+ label: "Tab Two",
79
+ content: (
80
+ <Image
81
+ alt="My alt text"
82
+ caption="Women construction workers in Nepal build roads and bridges as part of a National Rural Transport Programme co-sponsored by the ILO."
83
+ credit="© Marcel Crozet/ILO"
84
+ url={[
85
+ {
86
+ breakpoint: 0,
87
+ src: "https://place-hold.it/400x300?text=Tab Two Image",
88
+ },
89
+ {
90
+ breakpoint: 800,
91
+ src: "https://place-hold.it/800x600?text=Tab Two Image",
92
+ },
93
+ {
94
+ breakpoint: 1200,
95
+ src: "https://place-hold.it/1200x900?text=Tab Two Image",
96
+ },
97
+ {
98
+ breakpoint: 1440,
99
+ src: "https://place-hold.it/1600x1200?text=Tab Two Image",
100
+ },
101
+ ]}
102
+ />
103
+ ),
104
+ },
105
+ {
106
+ label: "Tab Three",
107
+ content: (
108
+ <Image
109
+ alt="My alt text"
110
+ caption="Women construction workers in Nepal build roads and bridges as part of a National Rural Transport Programme co-sponsored by the ILO."
111
+ credit="© Marcel Crozet/ILO"
112
+ url={[
113
+ {
114
+ breakpoint: 0,
115
+ src: "https://place-hold.it/400x300?text=Tab Three Image",
116
+ },
117
+ {
118
+ breakpoint: 800,
119
+ src: "https://place-hold.it/800x600?text=Tab Three Image",
120
+ },
121
+ {
122
+ breakpoint: 1200,
123
+ src: "https://place-hold.it/1200x900?text=Tab Three Image",
124
+ },
125
+ {
126
+ breakpoint: 1440,
127
+ src: "https://place-hold.it/1600x1200?text=Tab Three Image",
128
+ },
129
+ ]}
130
+ />
131
+ ),
132
+ },
133
+ {
134
+ label: "Tab Four Has A Really Lenghthy Title Which Might Get Truncated",
135
+ content: (
136
+ <Image
137
+ alt="My alt text"
138
+ caption="Women construction workers in Nepal build roads and bridges as part of a National Rural Transport Programme co-sponsored by the ILO."
139
+ credit="© Marcel Crozet/ILO"
140
+ url={[
141
+ {
142
+ breakpoint: 0,
143
+ src: "https://place-hold.it/400x300?text=Tab Four Image",
144
+ },
145
+ {
146
+ breakpoint: 800,
147
+ src: "https://place-hold.it/800x600?text=Tab Four Image",
148
+ },
149
+ {
150
+ breakpoint: 1200,
151
+ src: "https://place-hold.it/1200x900?text=Tab Four Image",
152
+ },
153
+ {
154
+ breakpoint: 1440,
155
+ src: "https://place-hold.it/1600x1200?text=Tab Four Image",
156
+ },
157
+ ]}
158
+ />
159
+ ),
160
+ },
161
+ {
162
+ label: "Tab Five",
163
+ content: (
164
+ <Image
165
+ alt="My alt text"
166
+ caption="Women construction workers in Nepal build roads and bridges as part of a National Rural Transport Programme co-sponsored by the ILO."
167
+ credit="© Marcel Crozet/ILO"
168
+ url={[
169
+ {
170
+ breakpoint: 0,
171
+ src: "https://place-hold.it/400x300?text=Tab Five Image",
172
+ },
173
+ {
174
+ breakpoint: 800,
175
+ src: "https://place-hold.it/800x600?text=Tab Five Image",
176
+ },
177
+ {
178
+ breakpoint: 1200,
179
+ src: "https://place-hold.it/1200x900?text=Tab Five Image",
180
+ },
181
+ {
182
+ breakpoint: 1440,
183
+ src: "https://place-hold.it/1600x1200?text=Tab Five Image",
184
+ },
185
+ ]}
186
+ />
187
+ ),
188
+ },
189
+ ],
190
+ };
191
+
192
+ /**
193
+ * Sample prop definitions for Button's enumerable properties (imported in stories and tests).
194
+ */
195
+ const TabsArgs = {
196
+ tabs,
197
+ withIcon,
198
+ fiveItems,
199
+ };
200
+
201
+ export default TabsArgs;
@@ -0,0 +1,13 @@
1
+ import { IconProps } from "../Icon/Icon.props";
2
+ export interface TabsProps {
3
+ /**
4
+ * Specify the items inside a tab
5
+ */
6
+ items: Required<Array<TabItem>>;
7
+ }
8
+
9
+ export interface TabItem {
10
+ icon?: IconProps;
11
+ label: Required<string>;
12
+ content: Required<any>;
13
+ }
@@ -0,0 +1,60 @@
1
+ import { FC, SetStateAction, useState } from "react";
2
+ import useGlobalSettings from "../../hooks/useGlobalSettings";
3
+ import classnames from "classnames";
4
+ import { TabsProps } from "./Tabs.props";
5
+ import { Icon } from "../Icon";
6
+
7
+ const Tabs: FC<TabsProps> = ({ items }) => {
8
+ const [activeTab, setActiveTab] = useState(0);
9
+
10
+ const handleTabClick = (
11
+ index: SetStateAction<number>,
12
+ e: React.MouseEvent<HTMLElement>
13
+ ) => {
14
+ setActiveTab(index);
15
+ e.preventDefault();
16
+ };
17
+
18
+ const { prefix } = useGlobalSettings();
19
+
20
+ const baseClass = `${prefix}--tabs`;
21
+ const tabsClasses = classnames(baseClass);
22
+
23
+ return (
24
+ <div className={`${tabsClasses} tabs--js`}>
25
+ <ul className={`${baseClass}--selection`} role="tablist">
26
+ {items.map((tab, index) => (
27
+ <li
28
+ key={`#tab--${index}`}
29
+ role="tab"
30
+ className={`${baseClass}--selection--item ${
31
+ activeTab === index ? "active" : ""
32
+ }`}
33
+ onClick={(e) => handleTabClick(index, e)}
34
+ >
35
+ <a
36
+ href={`#tab--${index}`}
37
+ className={`${baseClass}--selection--button${
38
+ tab.icon ? " icon" : ""
39
+ }`}
40
+ role="tab"
41
+ aria-controls={`tab--${index}`}
42
+ aria-selected={index === activeTab ? true : false}
43
+ title={tab.label}
44
+ >
45
+ <span className={`${baseClass}--selection--label`}>
46
+ {tab.label}
47
+ </span>
48
+ {tab.icon && (
49
+ <Icon name={tab.icon.name} hidden={tab.icon.hidden} />
50
+ )}
51
+ </a>
52
+ </li>
53
+ ))}
54
+ </ul>
55
+ <div className={`${baseClass}--content`}>{items[activeTab].content}</div>
56
+ </div>
57
+ );
58
+ };
59
+
60
+ export default Tabs;
@@ -0,0 +1 @@
1
+ export { default as Tabs } from "./Tabs";