@cooperco/cooper-component-library 0.1.91 → 0.1.93

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.
@@ -0,0 +1,85 @@
1
+ module.exports = {
2
+ // @ts-check
3
+ /** @type { import('contentful-migration').MigrationFunction } */
4
+ up: async function (migration, context) {
5
+ const environment = context?.makeRequest
6
+ ? null
7
+ : context?.environmentSingleton
8
+
9
+ let needsValidationUpdate = true
10
+ let needsControlUpdate = true
11
+
12
+ if (environment) {
13
+ try {
14
+ const contentType = await environment.getContentType('accordionItem')
15
+ const colorField = contentType.fields.find((f) => f.id === 'color')
16
+
17
+ if (colorField) {
18
+ // Check if validations have already been removed
19
+ const hasEnumValidation = colorField.validations?.some(
20
+ (v) => v.in && v.in.includes('Primary')
21
+ )
22
+ const hasDefaultValue = !!colorField.defaultValue
23
+ needsValidationUpdate =
24
+ hasEnumValidation || colorField.required || hasDefaultValue
25
+ }
26
+
27
+ const editorInterface =
28
+ await environment.getEditorInterfaceForContentType('accordionItem')
29
+ const colorControl = editorInterface.controls?.find(
30
+ (c) => c.fieldId === 'color'
31
+ )
32
+
33
+ if (
34
+ colorControl?.widgetNamespace === 'app' &&
35
+ colorControl?.widgetId === process.env.COLOR_PICKER_APP_ID
36
+ ) {
37
+ needsControlUpdate = false
38
+ }
39
+ } catch (e) {
40
+ // If we can't read the current state, apply all changes
41
+ }
42
+ }
43
+
44
+ const accordionItem = migration.editContentType('accordionItem')
45
+
46
+ if (needsValidationUpdate) {
47
+ accordionItem
48
+ .editField('color')
49
+ .validations([])
50
+ .required(false)
51
+ .defaultValue({ 'en-US': undefined })
52
+ }
53
+
54
+ if (needsControlUpdate) {
55
+ accordionItem.changeFieldControl(
56
+ 'color',
57
+ 'app',
58
+ process.env.COLOR_PICKER_APP_ID
59
+ )
60
+ }
61
+ },
62
+
63
+ // @ts-check
64
+ /** @type { import('contentful-migration').MigrationFunction } */
65
+ down: function (migration) {
66
+ const accordionItem = migration.editContentType('accordionItem')
67
+
68
+ // Restore the original enum validation and default
69
+ accordionItem
70
+ .editField('color')
71
+ .validations([
72
+ {
73
+ in: ['Primary', 'Secondary', 'Tertiary'],
74
+ },
75
+ ])
76
+ .required(true)
77
+ .defaultValue({ 'en-US': 'Primary' })
78
+
79
+ // Restore the dropdown control
80
+ accordionItem.changeFieldControl('color', 'builtin', 'dropdown', {
81
+ helpText:
82
+ 'These colors are determined by the background color of the tile, based on the design system.',
83
+ })
84
+ },
85
+ }
@@ -0,0 +1,21 @@
1
+ module.exports = {
2
+ // @ts-check
3
+ /** @type { import('contentful-migration').MigrationFunction } */
4
+ up: function (migration) {
5
+ const cta = migration.editContentType('cta')
6
+
7
+ cta.changeFieldControl('ctaAction', 'builtin', 'entryLinkEditor', {
8
+ helpText: 'If CTA Action is used, the Link will be ignored.',
9
+ })
10
+ },
11
+
12
+ // @ts-check
13
+ /** @type { import('contentful-migration').MigrationFunction } */
14
+ down: function (migration) {
15
+ const cta = migration.editContentType('cta')
16
+
17
+ cta.changeFieldControl('ctaAction', 'builtin', 'entry-link-list', {
18
+ helpText: 'If CTA Action is used, the Link will be ignored.',
19
+ })
20
+ },
21
+ }
@@ -0,0 +1,22 @@
1
+ module.exports = {
2
+ // @ts-check
3
+ /** @type { import('contentful-migration').MigrationFunction } */
4
+ up: function (migration) {
5
+ // --- tileContent: add help text to the image field ---
6
+ const tileContent = migration.editContentType('tileContent')
7
+ tileContent.changeFieldControl('image', 'builtin', 'entryLinkEditor', {
8
+ helpText:
9
+ 'For Tile type image stacked animated, please use a square image.',
10
+ })
11
+ },
12
+
13
+ // @ts-check
14
+ /** @type { import('contentful-migration').MigrationFunction } */
15
+ down: async function (migration) {
16
+ // --- tileContent: remove image field help text ---
17
+ const tileContent = migration.editContentType('tileContent')
18
+ tileContent.changeFieldControl('image', 'builtin', 'entryLinkEditor', {
19
+ helpText: '',
20
+ })
21
+ },
22
+ }
@@ -0,0 +1,85 @@
1
+ module.exports = {
2
+ // @ts-check
3
+ /** @type { import('contentful-migration').MigrationFunction } */
4
+ up: async function (migration, context) {
5
+ const environment = context?.makeRequest
6
+ ? null
7
+ : context?.environmentSingleton
8
+
9
+ let needsValidationUpdate = true
10
+ let needsControlUpdate = true
11
+
12
+ if (environment) {
13
+ try {
14
+ const contentType = await environment.getContentType('accordionItem')
15
+ const colorField = contentType.fields.find((f) => f.id === 'color')
16
+
17
+ if (colorField) {
18
+ // Check if validations have already been removed
19
+ const hasEnumValidation = colorField.validations?.some(
20
+ (v) => v.in && v.in.includes('Primary')
21
+ )
22
+ const hasDefaultValue = !!colorField.defaultValue
23
+ needsValidationUpdate =
24
+ hasEnumValidation || colorField.required || hasDefaultValue
25
+ }
26
+
27
+ const editorInterface =
28
+ await environment.getEditorInterfaceForContentType('accordionItem')
29
+ const colorControl = editorInterface.controls?.find(
30
+ (c) => c.fieldId === 'color'
31
+ )
32
+
33
+ if (
34
+ colorControl?.widgetNamespace === 'app' &&
35
+ colorControl?.widgetId === process.env.COLOR_PICKER_APP_ID
36
+ ) {
37
+ needsControlUpdate = false
38
+ }
39
+ } catch (e) {
40
+ // If we can't read the current state, apply all changes
41
+ }
42
+ }
43
+
44
+ const accordionItem = migration.editContentType('accordionItem')
45
+
46
+ if (needsValidationUpdate) {
47
+ accordionItem
48
+ .editField('color')
49
+ .validations([])
50
+ .required(false)
51
+ .defaultValue({ 'en-US': undefined })
52
+ }
53
+
54
+ if (needsControlUpdate) {
55
+ accordionItem.changeFieldControl(
56
+ 'color',
57
+ 'app',
58
+ process.env.COLOR_PICKER_APP_ID
59
+ )
60
+ }
61
+ },
62
+
63
+ // @ts-check
64
+ /** @type { import('contentful-migration').MigrationFunction } */
65
+ down: function (migration) {
66
+ const accordionItem = migration.editContentType('accordionItem')
67
+
68
+ // Restore the original enum validation and default
69
+ accordionItem
70
+ .editField('color')
71
+ .validations([
72
+ {
73
+ in: ['Primary', 'Secondary', 'Tertiary'],
74
+ },
75
+ ])
76
+ .required(true)
77
+ .defaultValue({ 'en-US': 'Primary' })
78
+
79
+ // Restore the dropdown control
80
+ accordionItem.changeFieldControl('color', 'builtin', 'dropdown', {
81
+ helpText:
82
+ 'These colors are determined by the background color of the tile, based on the design system.',
83
+ })
84
+ },
85
+ }
@@ -0,0 +1,21 @@
1
+ module.exports = {
2
+ // @ts-check
3
+ /** @type { import('contentful-migration').MigrationFunction } */
4
+ up: function (migration) {
5
+ const cta = migration.editContentType('cta')
6
+
7
+ cta.changeFieldControl('ctaAction', 'builtin', 'entryLinkEditor', {
8
+ helpText: 'If CTA Action is used, the Link will be ignored.',
9
+ })
10
+ },
11
+
12
+ // @ts-check
13
+ /** @type { import('contentful-migration').MigrationFunction } */
14
+ down: function (migration) {
15
+ const cta = migration.editContentType('cta')
16
+
17
+ cta.changeFieldControl('ctaAction', 'builtin', 'entry-link-list', {
18
+ helpText: 'If CTA Action is used, the Link will be ignored.',
19
+ })
20
+ },
21
+ }
@@ -0,0 +1,22 @@
1
+ module.exports = {
2
+ // @ts-check
3
+ /** @type { import('contentful-migration').MigrationFunction } */
4
+ up: function (migration) {
5
+ // --- tileContent: add help text to the image field ---
6
+ const tileContent = migration.editContentType('tileContent')
7
+ tileContent.changeFieldControl('image', 'builtin', 'entryLinkEditor', {
8
+ helpText:
9
+ 'For Tile type image stacked animated, please use a square image.',
10
+ })
11
+ },
12
+
13
+ // @ts-check
14
+ /** @type { import('contentful-migration').MigrationFunction } */
15
+ down: async function (migration) {
16
+ // --- tileContent: remove image field help text ---
17
+ const tileContent = migration.editContentType('tileContent')
18
+ tileContent.changeFieldControl('image', 'builtin', 'entryLinkEditor', {
19
+ helpText: '',
20
+ })
21
+ },
22
+ }
@@ -0,0 +1,85 @@
1
+ module.exports = {
2
+ // @ts-check
3
+ /** @type { import('contentful-migration').MigrationFunction } */
4
+ up: async function (migration, context) {
5
+ const environment = context?.makeRequest
6
+ ? null
7
+ : context?.environmentSingleton
8
+
9
+ let needsValidationUpdate = true
10
+ let needsControlUpdate = true
11
+
12
+ if (environment) {
13
+ try {
14
+ const contentType = await environment.getContentType('accordionItem')
15
+ const colorField = contentType.fields.find((f) => f.id === 'color')
16
+
17
+ if (colorField) {
18
+ // Check if validations have already been removed
19
+ const hasEnumValidation = colorField.validations?.some(
20
+ (v) => v.in && v.in.includes('Primary')
21
+ )
22
+ const hasDefaultValue = !!colorField.defaultValue
23
+ needsValidationUpdate =
24
+ hasEnumValidation || colorField.required || hasDefaultValue
25
+ }
26
+
27
+ const editorInterface =
28
+ await environment.getEditorInterfaceForContentType('accordionItem')
29
+ const colorControl = editorInterface.controls?.find(
30
+ (c) => c.fieldId === 'color'
31
+ )
32
+
33
+ if (
34
+ colorControl?.widgetNamespace === 'app' &&
35
+ colorControl?.widgetId === process.env.COLOR_PICKER_APP_ID
36
+ ) {
37
+ needsControlUpdate = false
38
+ }
39
+ } catch (e) {
40
+ // If we can't read the current state, apply all changes
41
+ }
42
+ }
43
+
44
+ const accordionItem = migration.editContentType('accordionItem')
45
+
46
+ if (needsValidationUpdate) {
47
+ accordionItem
48
+ .editField('color')
49
+ .validations([])
50
+ .required(false)
51
+ .defaultValue({ 'en-US': undefined })
52
+ }
53
+
54
+ if (needsControlUpdate) {
55
+ accordionItem.changeFieldControl(
56
+ 'color',
57
+ 'app',
58
+ process.env.COLOR_PICKER_APP_ID
59
+ )
60
+ }
61
+ },
62
+
63
+ // @ts-check
64
+ /** @type { import('contentful-migration').MigrationFunction } */
65
+ down: function (migration) {
66
+ const accordionItem = migration.editContentType('accordionItem')
67
+
68
+ // Restore the original enum validation and default
69
+ accordionItem
70
+ .editField('color')
71
+ .validations([
72
+ {
73
+ in: ['Primary', 'Secondary', 'Tertiary'],
74
+ },
75
+ ])
76
+ .required(true)
77
+ .defaultValue({ 'en-US': 'Primary' })
78
+
79
+ // Restore the dropdown control
80
+ accordionItem.changeFieldControl('color', 'builtin', 'dropdown', {
81
+ helpText:
82
+ 'These colors are determined by the background color of the tile, based on the design system.',
83
+ })
84
+ },
85
+ }
@@ -0,0 +1,21 @@
1
+ module.exports = {
2
+ // @ts-check
3
+ /** @type { import('contentful-migration').MigrationFunction } */
4
+ up: function (migration) {
5
+ const cta = migration.editContentType('cta')
6
+
7
+ cta.changeFieldControl('ctaAction', 'builtin', 'entryLinkEditor', {
8
+ helpText: 'If CTA Action is used, the Link will be ignored.',
9
+ })
10
+ },
11
+
12
+ // @ts-check
13
+ /** @type { import('contentful-migration').MigrationFunction } */
14
+ down: function (migration) {
15
+ const cta = migration.editContentType('cta')
16
+
17
+ cta.changeFieldControl('ctaAction', 'builtin', 'entry-link-list', {
18
+ helpText: 'If CTA Action is used, the Link will be ignored.',
19
+ })
20
+ },
21
+ }
@@ -0,0 +1,22 @@
1
+ module.exports = {
2
+ // @ts-check
3
+ /** @type { import('contentful-migration').MigrationFunction } */
4
+ up: function (migration) {
5
+ // --- tileContent: add help text to the image field ---
6
+ const tileContent = migration.editContentType('tileContent')
7
+ tileContent.changeFieldControl('image', 'builtin', 'entryLinkEditor', {
8
+ helpText:
9
+ 'For Tile type image stacked animated, please use a square image.',
10
+ })
11
+ },
12
+
13
+ // @ts-check
14
+ /** @type { import('contentful-migration').MigrationFunction } */
15
+ down: async function (migration) {
16
+ // --- tileContent: remove image field help text ---
17
+ const tileContent = migration.editContentType('tileContent')
18
+ tileContent.changeFieldControl('image', 'builtin', 'entryLinkEditor', {
19
+ helpText: '',
20
+ })
21
+ },
22
+ }
@@ -0,0 +1,85 @@
1
+ module.exports = {
2
+ // @ts-check
3
+ /** @type { import('contentful-migration').MigrationFunction } */
4
+ up: async function (migration, context) {
5
+ const environment = context?.makeRequest
6
+ ? null
7
+ : context?.environmentSingleton
8
+
9
+ let needsValidationUpdate = true
10
+ let needsControlUpdate = true
11
+
12
+ if (environment) {
13
+ try {
14
+ const contentType = await environment.getContentType('accordionItem')
15
+ const colorField = contentType.fields.find((f) => f.id === 'color')
16
+
17
+ if (colorField) {
18
+ // Check if validations have already been removed
19
+ const hasEnumValidation = colorField.validations?.some(
20
+ (v) => v.in && v.in.includes('Primary')
21
+ )
22
+ const hasDefaultValue = !!colorField.defaultValue
23
+ needsValidationUpdate =
24
+ hasEnumValidation || colorField.required || hasDefaultValue
25
+ }
26
+
27
+ const editorInterface =
28
+ await environment.getEditorInterfaceForContentType('accordionItem')
29
+ const colorControl = editorInterface.controls?.find(
30
+ (c) => c.fieldId === 'color'
31
+ )
32
+
33
+ if (
34
+ colorControl?.widgetNamespace === 'app' &&
35
+ colorControl?.widgetId === process.env.COLOR_PICKER_APP_ID
36
+ ) {
37
+ needsControlUpdate = false
38
+ }
39
+ } catch (e) {
40
+ // If we can't read the current state, apply all changes
41
+ }
42
+ }
43
+
44
+ const accordionItem = migration.editContentType('accordionItem')
45
+
46
+ if (needsValidationUpdate) {
47
+ accordionItem
48
+ .editField('color')
49
+ .validations([])
50
+ .required(false)
51
+ .defaultValue({ 'en-US': undefined })
52
+ }
53
+
54
+ if (needsControlUpdate) {
55
+ accordionItem.changeFieldControl(
56
+ 'color',
57
+ 'app',
58
+ process.env.COLOR_PICKER_APP_ID
59
+ )
60
+ }
61
+ },
62
+
63
+ // @ts-check
64
+ /** @type { import('contentful-migration').MigrationFunction } */
65
+ down: function (migration) {
66
+ const accordionItem = migration.editContentType('accordionItem')
67
+
68
+ // Restore the original enum validation and default
69
+ accordionItem
70
+ .editField('color')
71
+ .validations([
72
+ {
73
+ in: ['Primary', 'Secondary', 'Tertiary'],
74
+ },
75
+ ])
76
+ .required(true)
77
+ .defaultValue({ 'en-US': 'Primary' })
78
+
79
+ // Restore the dropdown control
80
+ accordionItem.changeFieldControl('color', 'builtin', 'dropdown', {
81
+ helpText:
82
+ 'These colors are determined by the background color of the tile, based on the design system.',
83
+ })
84
+ },
85
+ }
@@ -0,0 +1,21 @@
1
+ module.exports = {
2
+ // @ts-check
3
+ /** @type { import('contentful-migration').MigrationFunction } */
4
+ up: function (migration) {
5
+ const cta = migration.editContentType('cta')
6
+
7
+ cta.changeFieldControl('ctaAction', 'builtin', 'entryLinkEditor', {
8
+ helpText: 'If CTA Action is used, the Link will be ignored.',
9
+ })
10
+ },
11
+
12
+ // @ts-check
13
+ /** @type { import('contentful-migration').MigrationFunction } */
14
+ down: function (migration) {
15
+ const cta = migration.editContentType('cta')
16
+
17
+ cta.changeFieldControl('ctaAction', 'builtin', 'entry-link-list', {
18
+ helpText: 'If CTA Action is used, the Link will be ignored.',
19
+ })
20
+ },
21
+ }
@@ -0,0 +1,22 @@
1
+ module.exports = {
2
+ // @ts-check
3
+ /** @type { import('contentful-migration').MigrationFunction } */
4
+ up: function (migration) {
5
+ // --- tileContent: add help text to the image field ---
6
+ const tileContent = migration.editContentType('tileContent')
7
+ tileContent.changeFieldControl('image', 'builtin', 'entryLinkEditor', {
8
+ helpText:
9
+ 'For Tile type image stacked animated, please use a square image.',
10
+ })
11
+ },
12
+
13
+ // @ts-check
14
+ /** @type { import('contentful-migration').MigrationFunction } */
15
+ down: async function (migration) {
16
+ // --- tileContent: remove image field help text ---
17
+ const tileContent = migration.editContentType('tileContent')
18
+ tileContent.changeFieldControl('image', 'builtin', 'entryLinkEditor', {
19
+ helpText: '',
20
+ })
21
+ },
22
+ }