@colisweb/rescript-toolkit 2.67.1 → 2.68.1

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 (31) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/package.json +1 -1
  3. package/playground/PlaygroundComponents.res +10 -0
  4. package/playground/PlaygroundRouter.res +14 -6
  5. package/playground/components/Playground_Accordion.res +31 -0
  6. package/playground/components/Playground_Alert.res +25 -0
  7. package/playground/components/Playground_Button.res +75 -0
  8. package/playground/components/Playground_ButtonGroup.res +40 -0
  9. package/playground/components/Playground_Label.res +16 -0
  10. package/playground/components/Playground_Modal.res +53 -0
  11. package/playground/components/Playground_MultiSelect.res +91 -0
  12. package/playground/components/Playground_Notice.res +34 -0
  13. package/playground/components/Playground_Snackbar.res +43 -0
  14. package/playground/components/Playground_Spinner.res +48 -0
  15. package/playground/components/Playground_Switch.res +2 -2
  16. package/playground/custom.css +4 -1
  17. package/playground/docs/Setup.mdx +3 -10
  18. package/src/router/Toolkit__Router.res +2 -1
  19. package/src/ui/Toolkit__Ui_MultiSelect.res +21 -0
  20. package/src/ui/styles.css +6 -3
  21. package/vite.config.js +2 -1
  22. package/playground/stories/Toolkit__UI_AccordionStory.res +0 -34
  23. package/playground/stories/Toolkit__UI_AlertStory.res +0 -111
  24. package/playground/stories/Toolkit__UI_LabelStory.res +0 -39
  25. package/playground/stories/Toolkit__UI_ModalStory.res +0 -211
  26. package/playground/stories/Toolkit__UI_MultiSelectStory.res +0 -132
  27. package/playground/stories/Toolkit__UI_NoticeStory.res +0 -66
  28. package/playground/stories/Toolkit__UI_SnackbarStory.res +0 -209
  29. package/playground/stories/Toolkit__UI_SpinnerStory.res +0 -65
  30. package/playground/stories/Toolkit__Ui_ButtonGroupStory.res +0 -77
  31. package/playground/stories/Toolkit__Ui_ButtonStory.res +0 -324
package/src/ui/styles.css CHANGED
@@ -139,7 +139,6 @@ select:not([disabled]):not([tabindex="-1"]):focus,
139
139
  textarea:not([disabled]):not([tabindex="-1"]):focus,
140
140
  button:not([disabled]):not([tabindex="-1"]):focus,
141
141
  iframe:not([tabindex="-1"]):focus,
142
- [tabindex]:not([tabindex="-1"]):focus,
143
142
  [contentEditable="true"]:not([tabindex="-1"]):focus,
144
143
  .focus {
145
144
  outline: none !important;
@@ -164,7 +163,9 @@ iframe:not([tabindex="-1"]):focus,
164
163
  }
165
164
 
166
165
  .input-range
167
- .DayPicker-Day--selected:not(.DayPicker-Day--start):not(.DayPicker-Day--end):not(.DayPicker-Day--outside) {
166
+ .DayPicker-Day--selected:not(.DayPicker-Day--start):not(
167
+ .DayPicker-Day--end
168
+ ):not(.DayPicker-Day--outside) {
168
169
  background-color: #f0f8ff !important;
169
170
  color: #4a90e2;
170
171
  }
@@ -221,7 +222,9 @@ iframe:not([tabindex="-1"]):focus,
221
222
  }
222
223
 
223
224
  .Selectable
224
- .DayPicker-Day--selected:not(.DayPicker-Day--start):not(.DayPicker-Day--end):not(.DayPicker-Day--outside) {
225
+ .DayPicker-Day--selected:not(.DayPicker-Day--start):not(
226
+ .DayPicker-Day--end
227
+ ):not(.DayPicker-Day--outside) {
225
228
  background-color: #f0f8ff !important;
226
229
  color: #4a90e2;
227
230
  }
package/vite.config.js CHANGED
@@ -13,7 +13,7 @@ const appDirectory = fs.realpathSync(process.cwd());
13
13
  const isProduction = process.env.NODE_ENV === "production";
14
14
 
15
15
  export default defineConfig({
16
- base: isProduction ? "/colisweb-open-source/rescript-toolkit/" : "",
16
+ base: isProduction ? "/colisweb-open-source/rescript-toolkit/" : "/",
17
17
  build: {
18
18
  sourcemap: true,
19
19
  },
@@ -26,6 +26,7 @@ export default defineConfig({
26
26
  h1: "text-4xl",
27
27
  h2: "text-3xl",
28
28
  h3: "text-2xl",
29
+ h4: "text-xl",
29
30
  "h1,h2,h3,h4": "font-display font-bold underline mb-1",
30
31
  p: "mb-1",
31
32
  pre: "bg-white p-2 rounded-lg border my-4 block",
@@ -1,34 +0,0 @@
1
- open Storybook.Story
2
- open Storybook
3
-
4
- open ReachUi
5
-
6
- let _module = %raw("module")
7
-
8
- module Example = {
9
- @react.component
10
- let make = () =>
11
- <div>
12
- <Accordion>
13
- <AccordionItem>
14
- {"title"->React.string}
15
- <AccordionButton>
16
- <span className="cw-accordion-icon"> <BsReactIcons.MdKeyboardArrowRight /> </span>
17
- </AccordionButton>
18
- <AccordionPanel> {"content"->React.string} </AccordionPanel>
19
- </AccordionItem>
20
- <AccordionItem>
21
- <AccordionButton className="flex items-center">
22
- {"title"->React.string}
23
- <span className="cw-accordion-icon"> <BsReactIcons.MdKeyboardArrowRight /> </span>
24
- </AccordionButton>
25
- <AccordionPanel> {"content"->React.string} </AccordionPanel>
26
- </AccordionItem>
27
- </Accordion>
28
- </div>
29
- }
30
-
31
- storiesOf("Components/Accordion", _module)
32
- ->addDecorator(Knobs.withKnobs)
33
- ->add("default", () => <Example />)
34
- ->ignore
@@ -1,111 +0,0 @@
1
- open Storybook
2
- open Toolkit__Ui
3
-
4
- @module("!!raw-loader!../../../src/ui/Toolkit__Ui_Alert.resi")
5
- external source: 'a = "default"
6
-
7
- let default = CSF.make(~title="Components/Alert", ())
8
-
9
- let success = () =>
10
- <Alert title={"Title"->React.string} description={"Description"->React.string} status=#success />
11
-
12
- success->CSF.addMeta(
13
- ~name="success",
14
- ~parameters={
15
- "docs": {
16
- "page": () => <>
17
- <CodeBlock> source </CodeBlock>
18
- <Docs.Source
19
- language="rescript"
20
- code=j`
21
- <Alert
22
- title={"Title"->React.string}
23
- description={"Description"->React.string}
24
- status=#success
25
- />;
26
- `
27
- />
28
- <Docs.Story id="components-alert--success" />
29
- </>,
30
- },
31
- },
32
- (),
33
- )
34
-
35
- let error = () =>
36
- <Alert title={"Title"->React.string} description={"Description"->React.string} status=#error />
37
-
38
- error->CSF.addMeta(
39
- ~name="error",
40
- ~parameters={
41
- "docs": {
42
- "page": () => <>
43
- <CodeBlock> source </CodeBlock>
44
- <Docs.Source
45
- language="rescript"
46
- code=j`
47
- <Alert
48
- title={"Title"->React.string}
49
- description={"Description"->React.string}
50
- status=#error
51
- />;
52
- `
53
- />
54
- <Docs.Story id="components-alert--error" />
55
- </>,
56
- },
57
- },
58
- (),
59
- )
60
-
61
- let warning = () =>
62
- <Alert title={"Title"->React.string} description={"Description"->React.string} status=#warning />
63
-
64
- warning->CSF.addMeta(
65
- ~name="warning",
66
- ~parameters={
67
- "docs": {
68
- "page": () => <>
69
- <CodeBlock> source </CodeBlock>
70
- <Docs.Source
71
- language="rescript"
72
- code=j`
73
- <Alert
74
- title={"Title"->React.string}
75
- description={"Description"->React.string}
76
- status=#warning
77
- />;
78
- `
79
- />
80
- <Docs.Story id="components-alert--warning" />
81
- </>,
82
- },
83
- },
84
- (),
85
- )
86
-
87
- let info = () =>
88
- <Alert title={"Title"->React.string} description={"Description"->React.string} status=#info />
89
-
90
- info->CSF.addMeta(
91
- ~name="info",
92
- ~parameters={
93
- "docs": {
94
- "page": () => <>
95
- <CodeBlock> source </CodeBlock>
96
- <Docs.Source
97
- language="rescript"
98
- code=j`
99
- <Alert
100
- title={"Title"->React.string}
101
- description={"Description"->React.string}
102
- status=#info
103
- />;
104
- `
105
- />
106
- <Docs.Story id="components-alert--info" />
107
- </>,
108
- },
109
- },
110
- (),
111
- )
@@ -1,39 +0,0 @@
1
- open Storybook
2
- open Toolkit__Ui
3
-
4
- @module("!!raw-loader!../../../src/ui/Toolkit__Ui_Label.resi")
5
- external source: 'a = "default"
6
-
7
- let default = CSF.make(~title="Form/Label", ())
8
-
9
- let sample = () =>
10
- <div>
11
- <Label htmlFor="test"> {"Label"->React.string} </Label>
12
- <Label htmlFor="test" optionalMessage={"Optional"->React.string}>
13
- {"Label"->React.string}
14
- </Label>
15
- </div>
16
-
17
- sample->CSF.addMeta(
18
- ~name="sample",
19
- ~parameters={
20
- "docs": {
21
- "page": () => <>
22
- <CodeBlock> source </CodeBlock>
23
- <Docs.Source
24
- language="rescript"
25
- code=j`
26
- <div>
27
- <Label htmlFor="test"> "Label"->React.string </Label>
28
- <Label htmlFor="test" optionalMessage={"Optional"->React.string}>
29
- "Label"->React.string
30
- </Label>
31
- </div>
32
- `
33
- />
34
- <Docs.Story id="form-label--sample" />
35
- </>,
36
- },
37
- },
38
- (),
39
- )
@@ -1,211 +0,0 @@
1
- open Storybook
2
- open Toolkit__Ui
3
-
4
- @module("!!raw-loader!../../../src/ui/Toolkit__Ui_Modal.resi")
5
- external source: 'a = "default"
6
-
7
- let default = CSF.make(~title="Components/Modal", ())
8
-
9
- let defaultExample = () => {
10
- let modalSize = [("lg", #lg), ("md", #md), ("sm", #sm), ("xs", #xs)]
11
-
12
- let (isVisible, setVisibility) = React.useState(() => false)
13
- let (size, setSize) = React.useState(() => #md)
14
-
15
- <div>
16
- <div className="mb-4">
17
- <label htmlFor="size"> {"Size :"->React.string} </label>
18
- <select
19
- id="size"
20
- onChange={event => {
21
- let value = (event->ReactEvent.Form.target)["value"]
22
-
23
- setSize(_ => value)
24
- }}>
25
- {modalSize
26
- ->Array.map(((label, value)) =>
27
- <option value={value->Obj.magic} selected={value == size}> {label->React.string} </option>
28
- )
29
- ->React.array}
30
- </select>
31
- </div>
32
- <Button onClick={_ => setVisibility(_ => true)}> {"Show modal"->React.string} </Button>
33
- <Modal
34
- isVisible
35
- title={"title"->React.string}
36
- body={"Body"->React.string}
37
- hide={() => setVisibility(_ => false)}
38
- size
39
- />
40
- </div>
41
- }
42
-
43
- defaultExample->CSF.addMeta(
44
- ~name="default",
45
- ~parameters={
46
- "docs": {
47
- "page": () => <>
48
- <CodeBlock> source </CodeBlock>
49
- <Docs.Source
50
- language="rescript"
51
- code=j`
52
- let (isVisible, setVisibility) = React.useState(() => false);
53
-
54
- <>
55
- <button onClick={_ => setVisibility(_ => true)}>
56
- "Show modal"->React.string
57
- </button>
58
- <Modal
59
- isVisible
60
- title={"title"->React.string}
61
- body={"Body"->React.string}
62
- hide={() => setVisibility(_ => false)}
63
- />
64
- </>;
65
- `
66
- />
67
- <Docs.Story id="components-modal--default" />
68
- </>,
69
- },
70
- },
71
- (),
72
- )
73
-
74
- let coloredExample = () => {
75
- let modalSize = [("lg", #lg), ("md", #md), ("sm", #sm), ("xs", #xs)]
76
-
77
- let modalColor: array<(string, Modal.color)> = [
78
- ("primary", #primary),
79
- ("success", #success),
80
- ("danger", #danger),
81
- ("neutral", #neutral),
82
- ]
83
-
84
- let (isVisible, setVisibility) = React.useState(() => false)
85
- let (size, setSize) = React.useState(() => #md)
86
- let (color, setColor) = React.useState(() => #primary)
87
-
88
- <div>
89
- <div>
90
- <label htmlFor="size"> {"Size :"->React.string} </label>
91
- <select
92
- id="size"
93
- onChange={event => {
94
- let value = (event->ReactEvent.Form.target)["value"]
95
-
96
- setSize(_ => value)
97
- }}>
98
- {modalSize
99
- ->Array.map(((label, value)) =>
100
- <option value={value->Obj.magic} selected={value == size}> {label->React.string} </option>
101
- )
102
- ->React.array}
103
- </select>
104
- </div>
105
- <div>
106
- <label htmlFor="color"> {"color :"->React.string} </label>
107
- <select
108
- onChange={event => {
109
- let value = (event->ReactEvent.Form.target)["value"]
110
-
111
- setColor(_ => value)
112
- }}>
113
- {modalColor
114
- ->Array.map(((label, value)) =>
115
- <option value={value->Obj.magic} selected={value == color}>
116
- {label->React.string}
117
- </option>
118
- )
119
- ->React.array}
120
- </select>
121
- </div>
122
- <Button onClick={_ => setVisibility(_ => true)}> {"Show modal"->React.string} </Button>
123
- <Modal
124
- isVisible
125
- title={"title"->React.string}
126
- body={"Body"->React.string}
127
- hide={() => setVisibility(_ => false)}
128
- size
129
- type_=#colored(color)
130
- />
131
- </div>
132
- }
133
-
134
- coloredExample->CSF.addMeta(
135
- ~name="colored",
136
- ~parameters={
137
- "docs": {
138
- "page": () => <>
139
- <CodeBlock> source </CodeBlock>
140
- <Docs.Source
141
- language="rescript"
142
- code=j`
143
- let modalSize = [|("lg", #lg), ("md", #md), ("sm", #sm), ("xs", #xs)|];
144
-
145
- let modalColor: array((string, Modal.color)) = [|
146
- ("primary", #primary),
147
- ("success", #success),
148
- ("danger", #danger),
149
- ("neutral", #neutral),
150
- |];
151
-
152
- let (isVisible, setVisibility) = React.useState(() => false);
153
- let (size, setSize) = React.useState(() => #md);
154
- let (color, setColor) = React.useState(() => #primary);
155
-
156
- <div>
157
- <div>
158
- <label htmlFor="size"> "Size :"->React.string </label>
159
- <select
160
- id="size"
161
- onChange={event => {
162
- let value = event->ReactEvent.Form.target##value;
163
-
164
- setSize(_ => value);
165
- }}>
166
- {modalSize
167
- ->Array.map(((label, value)) => {
168
- <option value={value->Obj.magic} selected={value == size}>
169
- label->React.string
170
- </option>
171
- })
172
- ->React.array}
173
- </select>
174
- </div>
175
- <div>
176
- <label htmlFor="color"> "color :"->React.string </label>
177
- <select
178
- onChange={event => {
179
- let value = event->ReactEvent.Form.target##value;
180
-
181
- setColor(_ => value);
182
- }}>
183
- {modalColor
184
- ->Array.map(((label, value)) => {
185
- <option value={value->Obj.magic} selected={value == color}>
186
- label->React.string
187
- </option>
188
- })
189
- ->React.array}
190
- </select>
191
- </div>
192
- <Button onClick={_ => setVisibility(_ => true)}>
193
- "Show modal"->React.string
194
- </Button>
195
- <Modal
196
- isVisible
197
- title={"title"->React.string}
198
- body={"Body"->React.string}
199
- hide={() => setVisibility(_ => false)}
200
- size
201
- type_={#colored(color)}
202
- />
203
- </div>;
204
- `
205
- />
206
- <Docs.Story id="components-modal--colored" />
207
- </>,
208
- },
209
- },
210
- (),
211
- )
@@ -1,132 +0,0 @@
1
- open Storybook
2
-
3
- @module("!!raw-loader!../../../src/ui/Toolkit__Ui_MultiSelect.resi")
4
- external source: 'a = "default"
5
-
6
- let default = CSF.make(~title="Components/MultiSelect", ())
7
-
8
- let example = () => {
9
- let options1: array<Toolkit__Ui_MultiSelect.item> = [
10
- {
11
- itemLabel: <p className="flex flex-row text-danger-500">
12
- <BsReactIcons.FaAngleDown /> {"test"->React.string}
13
- </p>,
14
- label: "Test",
15
- value: "test",
16
- },
17
- {
18
- itemLabel: <p> {"test2"->React.string} </p>,
19
- label: "Test2",
20
- value: "test2",
21
- },
22
- {
23
- itemLabel: <p> {"test3"->React.string} </p>,
24
- label: "Test3",
25
- value: "test3",
26
- },
27
- {
28
- itemLabel: <p> {"test4"->React.string} </p>,
29
- label: "Test4",
30
- value: "test4",
31
- },
32
- ]
33
- let options2: array<Toolkit__Ui_MultiSelect.item> = [
34
- {
35
- itemLabel: <p> {"test4"->React.string} </p>,
36
- label: "Test4",
37
- value: "test4",
38
- },
39
- ]
40
-
41
- let tmp = Toolkit__Hooks.useDisclosure()
42
-
43
- let options = tmp.isOpen ? options2 : options1
44
-
45
- <div>
46
- <Toolkit__Ui_Button onClick={_ => tmp.toggle()}>
47
- {"Change options"->React.string}
48
- </Toolkit__Ui_Button>
49
- <div className="h-10" />
50
- <Toolkit__Ui_MultiSelect
51
- searchPlaceholder="Filter"
52
- buttonClassName={"w-48"}
53
- dropdownClassName="w-60"
54
- placeholder={<span> {"Select me"->React.string} </span>}
55
- onChange={Js.log}
56
- options
57
- />
58
- <div className="mt-8" />
59
- <Toolkit__Ui_MultiSelect
60
- searchPlaceholder="Filter"
61
- buttonClassName={"w-48"}
62
- dropdownClassName="w-60"
63
- defaultValue={options}
64
- placeholder={<span> {"Select me"->React.string} </span>}
65
- onChange={Js.log}
66
- options
67
- />
68
- </div>
69
- }
70
-
71
- example->CSF.addMeta(
72
- ~name="example",
73
- ~parameters={
74
- "docs": {
75
- "page": () => <>
76
- <CodeBlock> source </CodeBlock>
77
- <Docs.Source
78
- language="rescript"
79
- code=j`
80
- let options: array<Toolkit__Ui_MultiSelect.item> = [
81
- {
82
- itemLabel: <p className="flex flex-row text-danger-500">
83
- <BsReactIcons.FaAngleDown /> {"test"->React.string}
84
- </p>,
85
- label: "Test",
86
- value: "test",
87
- },
88
- {
89
- itemLabel: <p> {"test2"->React.string} </p>,
90
- label: "Test2",
91
- value: "test2",
92
- },
93
- {
94
- itemLabel: <p> {"test3"->React.string} </p>,
95
- label: "Test3",
96
- value: "test3",
97
- },
98
- {
99
- itemLabel: <p> {"test4"->React.string} </p>,
100
- label: "Test4",
101
- value: "test4",
102
- },
103
- ]
104
-
105
- <div>
106
- <Toolkit__Ui_MultiSelect
107
- searchPlaceholder="Filter"
108
- buttonClassName={"w-48"}
109
- dropdownClassName="w-60"
110
- placeholder={<span> {"Select me"->React.string} </span>}
111
- onChange={Js.log}
112
- options
113
- />
114
- <div className="mt-8" />
115
- <Toolkit__Ui_MultiSelect
116
- searchPlaceholder="Filter"
117
- buttonClassName={"w-48"}
118
- dropdownClassName="w-60"
119
- defaultValue={[options[0]->Option.getUnsafe]}
120
- placeholder={<span> {"Select me"->React.string} </span>}
121
- onChange={Js.log}
122
- options
123
- />
124
- </div>
125
- `
126
- />
127
- <Docs.Story id="components-multiselect--example" />
128
- </>,
129
- },
130
- },
131
- (),
132
- )
@@ -1,66 +0,0 @@
1
- open Storybook
2
- open Toolkit__Ui
3
-
4
- @module("!!raw-loader!../../../src/ui/Toolkit__Ui_Notice.resi")
5
- external source: 'a = "default"
6
-
7
- let default = CSF.make(~title="Components/Notice", ())
8
-
9
- let example = () => {
10
- let pRef = React.useRef(Js.Nullable.null)
11
- let noticeRef2 = React.useRef(Js.Nullable.null)
12
- let (noticeVisible1, setNoticeVisible1) = React.useState(() => false)
13
- let (noticeVisible2, setNoticeVisible2) = React.useState(() => false)
14
-
15
- <div>
16
- <div className="flex flex-row items-center">
17
- <Button onClick={_ => setNoticeVisible1(v => !v)}> {"Toggle notice 1"->React.string} </Button>
18
- <Button onClick={_ => setNoticeVisible2(v => !v)}> {"Toggle notice 2"->React.string} </Button>
19
- </div>
20
- <p className="text-center" ref={ReactDOM.Ref.domRef(pRef)}> {"example"->React.string} </p>
21
- <div ref={ReactDOM.Ref.domRef(noticeRef2)} className="w-40 h-40 bg-danger-300 ml-20 mt-20" />
22
- <Notice visible=noticeVisible1 baseElementRef=pRef className="bg-info-700 p-2 rounded">
23
- <p className="text-white"> {"Some text there"->React.string} </p>
24
- </Notice>
25
- <Notice visible=noticeVisible2 baseElementRef=noticeRef2 className="bg-info-700 p-2 rounded">
26
- <p className="text-white"> {"Some text there"->React.string} </p>
27
- </Notice>
28
- </div>
29
- }
30
-
31
- example->CSF.addMeta(
32
- ~name="example",
33
- ~parameters={
34
- "docs": {
35
- "page": () => <>
36
- <CodeBlock> source </CodeBlock>
37
- <Docs.Source
38
- language="rescript"
39
- code=j`
40
- let pRef = React.useRef(Js.Nullable.null)
41
- let noticeRef2 = React.useRef(Js.Nullable.null)
42
- let (noticeVisible1, setNoticeVisible1) = React.useState(() => false)
43
- let (noticeVisible2, setNoticeVisible2) = React.useState(() => false)
44
-
45
- <div>
46
- <div className="flex flex-row items-center">
47
- <Button onClick={_ => setNoticeVisible1(v => !v)}> {"Toggle notice 1"->React.string} </Button>
48
- <Button onClick={_ => setNoticeVisible2(v => !v)}> {"Toggle notice 2"->React.string} </Button>
49
- </div>
50
- <p className="text-center" ref={ReactDOM.Ref.domRef(pRef)}> {"example"->React.string} </p>
51
- <div ref={ReactDOM.Ref.domRef(noticeRef2)} className="w-40 h-40 bg-danger-300 ml-20 mt-20" />
52
- <Notice visible=noticeVisible1 baseElementRef=pRef className="bg-info-700 p-2 rounded">
53
- <p className="text-white"> {"Some text there"->React.string} </p>
54
- </Notice>
55
- <Notice visible=noticeVisible2 baseElementRef=noticeRef2 className="bg-info-700 p-2 rounded">
56
- <p className="text-white"> {"Some text there"->React.string} </p>
57
- </Notice>
58
- </div>
59
- `
60
- />
61
- <Docs.Story id="components-notice--example" />
62
- </>,
63
- },
64
- },
65
- (),
66
- )