@tribepad/themis 1.0.5 → 1.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.
Files changed (50) hide show
  1. package/dist/elements/MatrixGrid/MatrixGrid.d.ts +31 -0
  2. package/dist/elements/MatrixGrid/MatrixGrid.d.ts.map +1 -0
  3. package/dist/elements/MatrixGrid/MatrixGrid.styles.d.ts +48 -0
  4. package/dist/elements/MatrixGrid/MatrixGrid.styles.d.ts.map +1 -0
  5. package/dist/elements/MatrixGrid/MatrixGrid.types.d.ts +75 -0
  6. package/dist/elements/MatrixGrid/MatrixGrid.types.d.ts.map +1 -0
  7. package/dist/elements/MatrixGrid/index.d.ts +5 -0
  8. package/dist/elements/MatrixGrid/index.d.ts.map +1 -0
  9. package/dist/elements/MatrixGrid/index.js +3 -0
  10. package/dist/elements/MatrixGrid/index.js.map +1 -0
  11. package/dist/elements/MatrixGrid/index.mjs +3 -0
  12. package/dist/elements/MatrixGrid/index.mjs.map +1 -0
  13. package/dist/elements/RatingScale/RatingScale.d.ts +32 -0
  14. package/dist/elements/RatingScale/RatingScale.d.ts.map +1 -0
  15. package/dist/elements/RatingScale/RatingScale.styles.d.ts +52 -0
  16. package/dist/elements/RatingScale/RatingScale.styles.d.ts.map +1 -0
  17. package/dist/elements/RatingScale/RatingScale.types.d.ts +73 -0
  18. package/dist/elements/RatingScale/RatingScale.types.d.ts.map +1 -0
  19. package/dist/elements/RatingScale/index.d.ts +5 -0
  20. package/dist/elements/RatingScale/index.d.ts.map +1 -0
  21. package/dist/elements/RatingScale/index.js +3 -0
  22. package/dist/elements/RatingScale/index.js.map +1 -0
  23. package/dist/elements/RatingScale/index.mjs +3 -0
  24. package/dist/elements/RatingScale/index.mjs.map +1 -0
  25. package/dist/elements/SituationalJudgement/SituationalJudgement.d.ts +36 -0
  26. package/dist/elements/SituationalJudgement/SituationalJudgement.d.ts.map +1 -0
  27. package/dist/elements/SituationalJudgement/SituationalJudgement.styles.d.ts +19 -0
  28. package/dist/elements/SituationalJudgement/SituationalJudgement.styles.d.ts.map +1 -0
  29. package/dist/elements/SituationalJudgement/SituationalJudgement.types.d.ts +67 -0
  30. package/dist/elements/SituationalJudgement/SituationalJudgement.types.d.ts.map +1 -0
  31. package/dist/elements/SituationalJudgement/index.d.ts +5 -0
  32. package/dist/elements/SituationalJudgement/index.d.ts.map +1 -0
  33. package/dist/elements/SituationalJudgement/index.js +3 -0
  34. package/dist/elements/SituationalJudgement/index.js.map +1 -0
  35. package/dist/elements/SituationalJudgement/index.mjs +3 -0
  36. package/dist/elements/SituationalJudgement/index.mjs.map +1 -0
  37. package/dist/elements/index.d.ts +6 -0
  38. package/dist/elements/index.d.ts.map +1 -1
  39. package/dist/elements/index.js +1 -1
  40. package/dist/elements/index.js.map +1 -1
  41. package/dist/elements/index.mjs +1 -1
  42. package/dist/elements/index.mjs.map +1 -1
  43. package/dist/index.js +2 -2
  44. package/dist/index.js.map +1 -1
  45. package/dist/index.mjs +2 -2
  46. package/dist/index.mjs.map +1 -1
  47. package/package.json +1 -1
  48. package/src/elements/MatrixGrid/MatrixGrid.stories.tsx +292 -0
  49. package/src/elements/RatingScale/RatingScale.stories.tsx +379 -0
  50. package/src/elements/SituationalJudgement/SituationalJudgement.stories.tsx +305 -0
@@ -0,0 +1,305 @@
1
+ import { useState } from 'react';
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
+ import { SituationalJudgement } from './SituationalJudgement';
4
+
5
+ const SAMPLE_RESPONSES = [
6
+ { value: 'a', text: 'Speak to the colleague privately about the issue.', ordinal: 0 },
7
+ { value: 'b', text: 'Report the situation to your manager immediately.', ordinal: 1 },
8
+ { value: 'c', text: 'Ignore the situation and focus on your own work.', ordinal: 2 },
9
+ { value: 'd', text: 'Discuss the matter in the next team meeting.', ordinal: 3 },
10
+ ];
11
+
12
+ const SAMPLE_SCENARIO = '<p>You observe a colleague making a <strong>significant error</strong> on an important client report. The report is due to be submitted tomorrow morning. Your colleague seems unaware of the mistake.</p>';
13
+
14
+ const meta = {
15
+ title: 'Elements/SituationalJudgement',
16
+ component: SituationalJudgement,
17
+ parameters: {
18
+ layout: 'centered',
19
+ docs: {
20
+ description: {
21
+ component:
22
+ 'Assessment component presenting a scenario with 3-6 response options. Composes existing RadioGroup + Radio for responses and Accordion for collapsible scenarios. Includes built-in HTML sanitiser for XSS protection.',
23
+ },
24
+ },
25
+ },
26
+ tags: ['autodocs'],
27
+ argTypes: {
28
+ size: {
29
+ control: 'select',
30
+ options: ['sm', 'default', 'lg'],
31
+ description: 'Component size',
32
+ table: { defaultValue: { summary: 'default' } },
33
+ },
34
+ collapsibleScenario: { control: 'boolean' },
35
+ isDisabled: { control: 'boolean' },
36
+ isReadOnly: { control: 'boolean' },
37
+ isRequired: { control: 'boolean' },
38
+ isInvalid: { control: 'boolean' },
39
+ label: { control: 'text' },
40
+ description: { control: 'text' },
41
+ errorMessage: { control: 'text' },
42
+ },
43
+ } satisfies Meta<typeof SituationalJudgement>;
44
+
45
+ export default meta;
46
+ type Story = StoryObj<typeof meta>;
47
+
48
+ // =============================================================================
49
+ // Default
50
+ // =============================================================================
51
+
52
+ export const Default: Story = {
53
+ args: {
54
+ label: 'Question 1',
55
+ scenarioText: SAMPLE_SCENARIO,
56
+ responses: SAMPLE_RESPONSES,
57
+ },
58
+ decorators: [(Story) => <div className="w-[600px]"><Story /></div>],
59
+ };
60
+
61
+ // =============================================================================
62
+ // Collapsible Scenario
63
+ // =============================================================================
64
+
65
+ export const CollapsibleScenario: Story = {
66
+ args: {
67
+ label: 'Question 2',
68
+ scenarioText: SAMPLE_SCENARIO,
69
+ responses: SAMPLE_RESPONSES,
70
+ collapsibleScenario: true,
71
+ },
72
+ decorators: [(Story) => <div className="w-[600px]"><Story /></div>],
73
+ parameters: {
74
+ docs: {
75
+ description: {
76
+ story: 'Scenario panel can be collapsed to save space. Uses the existing Accordion component.',
77
+ },
78
+ },
79
+ },
80
+ };
81
+
82
+ // =============================================================================
83
+ // States
84
+ // =============================================================================
85
+
86
+ export const Required: Story = {
87
+ args: {
88
+ label: 'Question 3',
89
+ scenarioText: SAMPLE_SCENARIO,
90
+ responses: SAMPLE_RESPONSES,
91
+ isRequired: true,
92
+ },
93
+ decorators: [(Story) => <div className="w-[600px]"><Story /></div>],
94
+ };
95
+
96
+ export const Invalid: Story = {
97
+ args: {
98
+ label: 'Question 4',
99
+ scenarioText: SAMPLE_SCENARIO,
100
+ responses: SAMPLE_RESPONSES,
101
+ isInvalid: true,
102
+ errorMessage: 'Please select a response before continuing.',
103
+ },
104
+ decorators: [(Story) => <div className="w-[600px]"><Story /></div>],
105
+ };
106
+
107
+ export const Disabled: Story = {
108
+ args: {
109
+ label: 'Question 5',
110
+ scenarioText: SAMPLE_SCENARIO,
111
+ responses: SAMPLE_RESPONSES,
112
+ value: 'a',
113
+ isDisabled: true,
114
+ },
115
+ decorators: [(Story) => <div className="w-[600px]"><Story /></div>],
116
+ };
117
+
118
+ export const ReadOnly: Story = {
119
+ args: {
120
+ label: 'Question 6 (Submitted)',
121
+ scenarioText: SAMPLE_SCENARIO,
122
+ responses: SAMPLE_RESPONSES,
123
+ value: 'b',
124
+ isReadOnly: true,
125
+ },
126
+ decorators: [(Story) => <div className="w-[600px]"><Story /></div>],
127
+ };
128
+
129
+ // =============================================================================
130
+ // With Description
131
+ // =============================================================================
132
+
133
+ export const WithDescription: Story = {
134
+ args: {
135
+ label: 'Question 7',
136
+ description: 'Choose the most effective response to the scenario below.',
137
+ scenarioText: SAMPLE_SCENARIO,
138
+ responses: SAMPLE_RESPONSES,
139
+ },
140
+ decorators: [(Story) => <div className="w-[600px]"><Story /></div>],
141
+ };
142
+
143
+ // =============================================================================
144
+ // Sizes
145
+ // =============================================================================
146
+
147
+ export const SmallSize: Story = {
148
+ args: {
149
+ label: 'Small',
150
+ scenarioText: '<p>A brief scenario.</p>',
151
+ responses: SAMPLE_RESPONSES.slice(0, 3),
152
+ size: 'sm',
153
+ },
154
+ decorators: [(Story) => <div className="w-[600px]"><Story /></div>],
155
+ };
156
+
157
+ export const LargeSize: Story = {
158
+ args: {
159
+ label: 'Large',
160
+ scenarioText: '<p>A brief scenario.</p>',
161
+ responses: SAMPLE_RESPONSES.slice(0, 3),
162
+ size: 'lg',
163
+ },
164
+ decorators: [(Story) => <div className="w-[600px]"><Story /></div>],
165
+ };
166
+
167
+ // =============================================================================
168
+ // Controlled
169
+ // =============================================================================
170
+
171
+ export const ControlledExample: Story = {
172
+ render: () => {
173
+ const [value, setValue] = useState<string | null>(null);
174
+ return (
175
+ <div className="w-[600px]">
176
+ <SituationalJudgement
177
+ label="Question 8"
178
+ scenarioText={SAMPLE_SCENARIO}
179
+ responses={SAMPLE_RESPONSES}
180
+ value={value}
181
+ onChange={setValue}
182
+ />
183
+ <p className="mt-3 text-sm text-[var(--muted-foreground)]">
184
+ Selected: {value ?? 'None'}
185
+ </p>
186
+ </div>
187
+ );
188
+ },
189
+ };
190
+
191
+ // =============================================================================
192
+ // Six Responses
193
+ // =============================================================================
194
+
195
+ export const SixResponses: Story = {
196
+ args: {
197
+ label: 'Question 9',
198
+ scenarioText: '<p>A complex workplace scenario with multiple viable approaches.</p>',
199
+ responses: [
200
+ { value: 'a', text: 'Address the issue directly with the person involved.', ordinal: 0 },
201
+ { value: 'b', text: 'Consult with HR before taking any action.', ordinal: 1 },
202
+ { value: 'c', text: 'Document the incident and report to management.', ordinal: 2 },
203
+ { value: 'd', text: 'Seek advice from a trusted colleague.', ordinal: 3 },
204
+ { value: 'e', text: 'Wait to see if the situation resolves itself.', ordinal: 4 },
205
+ { value: 'f', text: 'Escalate immediately to senior leadership.', ordinal: 5 },
206
+ ],
207
+ },
208
+ decorators: [(Story) => <div className="w-[600px]"><Story /></div>],
209
+ parameters: {
210
+ docs: {
211
+ description: { story: 'Maximum of 6 response options.' },
212
+ },
213
+ },
214
+ };
215
+
216
+ // =============================================================================
217
+ // Rich Scenario HTML
218
+ // =============================================================================
219
+
220
+ export const RichScenarioHTML: Story = {
221
+ args: {
222
+ label: 'Question 10',
223
+ scenarioText: `
224
+ <p>During a team project, you discover that:</p>
225
+ <ul>
226
+ <li>A team member has been <strong>consistently missing deadlines</strong></li>
227
+ <li>Their work quality has <em>noticeably declined</em></li>
228
+ <li>Other team members are having to <strong>cover their tasks</strong></li>
229
+ </ul>
230
+ <p>The project deadline is in <strong>two weeks</strong> and the team is already behind schedule.</p>
231
+ `,
232
+ responses: [
233
+ { value: 'a', text: 'Have a private, supportive conversation with the team member.', ordinal: 0 },
234
+ { value: 'b', text: 'Redistribute the workload among remaining team members.', ordinal: 1 },
235
+ { value: 'c', text: 'Escalate to the project manager with documented concerns.', ordinal: 2 },
236
+ ],
237
+ collapsibleScenario: true,
238
+ },
239
+ decorators: [(Story) => <div className="w-[600px]"><Story /></div>],
240
+ parameters: {
241
+ docs: {
242
+ description: {
243
+ story: 'Scenario HTML supports formatting: bold, italic, lists, paragraphs. Dangerous HTML (scripts, iframes) is automatically sanitised.',
244
+ },
245
+ },
246
+ },
247
+ };
248
+
249
+ // =============================================================================
250
+ // Assessment Form
251
+ // =============================================================================
252
+
253
+ export const AssessmentForm: Story = {
254
+ render: () => {
255
+ const [answers, setAnswers] = useState<Record<string, string | null>>({
256
+ q1: null,
257
+ q2: null,
258
+ });
259
+ return (
260
+ <div className="w-[600px] rounded-lg border border-[var(--border)] bg-[var(--content-background)] p-6">
261
+ <h2 className="mb-6 text-xl font-bold text-[var(--content-foreground)]">
262
+ Situational Judgement Assessment
263
+ </h2>
264
+ <div className="flex flex-col gap-8">
265
+ <SituationalJudgement
266
+ label="Question 1 of 2"
267
+ description="Select the most appropriate response."
268
+ scenarioText="<p>A customer calls to complain about a <strong>delayed delivery</strong>. They are upset and demanding an immediate resolution.</p>"
269
+ responses={[
270
+ { value: 'a', text: 'Apologise sincerely and offer a refund or replacement.', ordinal: 0 },
271
+ { value: 'b', text: 'Explain the delivery policy and ask them to wait.', ordinal: 1 },
272
+ { value: 'c', text: 'Transfer the call to a supervisor.', ordinal: 2 },
273
+ ]}
274
+ value={answers.q1}
275
+ onChange={(v) => setAnswers((a) => ({ ...a, q1: v }))}
276
+ isRequired
277
+ />
278
+ <hr className="border-[var(--border)]" />
279
+ <SituationalJudgement
280
+ label="Question 2 of 2"
281
+ description="Select the most appropriate response."
282
+ scenarioText="<p>You notice a <em>security vulnerability</em> in the company's customer-facing application during routine testing.</p>"
283
+ responses={[
284
+ { value: 'a', text: 'Report it immediately to the security team.', ordinal: 0 },
285
+ { value: 'b', text: 'Try to fix it yourself before reporting.', ordinal: 1 },
286
+ { value: 'c', text: 'Document it and include in the next sprint.', ordinal: 2 },
287
+ { value: 'd', text: 'Verify the severity and then escalate accordingly.', ordinal: 3 },
288
+ ]}
289
+ value={answers.q2}
290
+ onChange={(v) => setAnswers((a) => ({ ...a, q2: v }))}
291
+ isRequired
292
+ collapsibleScenario
293
+ />
294
+ </div>
295
+ </div>
296
+ );
297
+ },
298
+ parameters: {
299
+ docs: {
300
+ description: {
301
+ story: 'Full assessment form with multiple SJT questions.',
302
+ },
303
+ },
304
+ },
305
+ };