@01-edu/shared 1.1.9 → 1.2.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.
package/attrs-defs.js CHANGED
@@ -3607,13 +3607,11 @@ attrs.text = {
3607
3607
  types.timelineChunk = TypeObject({
3608
3608
  label: 'Month guideline',
3609
3609
  type: {
3610
- month: Literal(120, {
3610
+ month: Literal(1, {
3611
3611
  label: 'Month',
3612
3612
  editable: true,
3613
3613
  required: true,
3614
3614
  primary: true,
3615
- // to put 120 first in options - could also be [120, ...arrayOf(119, 1)]
3616
- options: arrayOf(120, 1).reverse(),
3617
3615
  check: (month, object) => {
3618
3616
  checkIntegerInBetween(month, 1, 120)
3619
3617
 
@@ -3628,29 +3626,31 @@ types.timelineChunk = TypeObject({
3628
3626
  },
3629
3627
  }),
3630
3628
  minLevel: Literal(0, {
3631
- label: 'Minimum level to be considered on track',
3629
+ label: 'Minimum level',
3630
+ instruction: 'Minimum level to be considered on time',
3632
3631
  editable: true,
3633
3632
  required: true,
3634
- options: arrayOf(MAX_LEVEL, 0),
3635
3633
  check: level => checkIntegerInBetween(level, 0, MAX_LEVEL),
3636
3634
  }),
3637
3635
  expectedLevel: Literal(0, {
3638
3636
  label: 'Expected level',
3639
3637
  editable: true,
3640
3638
  required: true,
3641
- options: arrayOf(MAX_LEVEL, 0),
3639
+ instruction: 'Recommended level the user should achieve',
3642
3640
  check: level => checkIntegerInBetween(level, 0, MAX_LEVEL),
3643
3641
  }),
3644
3642
  checkpointLevel: Literal(0, {
3645
3643
  label: 'Expected checkpoint level',
3646
3644
  editable: true,
3647
3645
  required: true,
3648
- options: arrayOf(100, 0),
3646
+ instruction: 'Recommended checkpoint level the user should achieve',
3649
3647
  check: level => checkIntegerInBetween(level, 0, 100),
3650
3648
  }),
3651
3649
  rank: Literal('', {
3652
3650
  label: 'Expected rank',
3653
3651
  editable: true,
3652
+ instruction: 'Recommended rank the user should achieve',
3653
+ options: object => object.attrs.ranksDefinitions?.map(item => item.name),
3654
3654
  check: (rank, object) => {
3655
3655
  if (!object.attrs.ranksDefinitions?.length) {
3656
3656
  throw Error(
@@ -3671,7 +3671,8 @@ types.timelineChunk = TypeObject({
3671
3671
  },
3672
3672
  }),
3673
3673
  skills: TypeObject({
3674
- label: 'List of developed skills',
3674
+ label: 'Expected skills',
3675
+ instruction: 'Recommended skills the user should get',
3675
3676
  editable: true,
3676
3677
  required: true,
3677
3678
  value: {},
@@ -3691,12 +3692,16 @@ types.timelineChunk = TypeObject({
3691
3692
  }),
3692
3693
  notes: Literal('', {
3693
3694
  label: 'Other qualitative notes',
3695
+ instruction:
3696
+ 'Write any other notes or expectations the user should aim for',
3694
3697
  editable: true,
3695
3698
  }),
3696
3699
  },
3697
3700
  })
3698
3701
  const sharedTimeline = {
3699
- label: 'Timeline per month for a curriculum',
3702
+ label: 'Timeline of the curriculum',
3703
+ instruction:
3704
+ 'Create a timeline with monthly expectations for users to better track their progression over time',
3700
3705
  value: (...args) => [
3701
3706
  mapValues(types.timelineChunk.type, subDef =>
3702
3707
  getDefaultValue(subDef, ...args),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@01-edu/shared",
3
- "version": "1.1.9",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "scripts": {
package/toolbox.js CHANGED
@@ -64,6 +64,12 @@ export const handleKeyDownEvent = args => {
64
64
  }
65
65
  }
66
66
 
67
+ export const swap = (arr, i, j) => {
68
+ const newArr = [...arr] // don’t mutate the original
69
+ ;[newArr[i], newArr[j]] = [newArr[j], newArr[i]]
70
+ return newArr
71
+ }
72
+
67
73
  export const last = array => array[array.length - 1]
68
74
 
69
75
  export const upperFirst = str =>
@@ -190,6 +196,7 @@ export const formatedDuration = (seconds, { noSeconds } = {}) => {
190
196
 
191
197
  const toDate = date => (date instanceof Date ? date : new Date(date))
192
198
  export const toDateFormat = (d, isISO = true) => {
199
+ if (dateIsPermanent(d)) return '∞'
193
200
  const date = toDate(d)
194
201
  const month = (date.getMonth() + 1).toString().padStart(2, '0')
195
202
  const day = date.getDate().toString().padStart(2, '0')