startbit-timezone-select 0.0.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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Strapi plugin startbit-timezone-select
2
+
3
+ A quick description of startbit-timezone-select.
@@ -0,0 +1,110 @@
1
+ .toggle-slider .toggle-label {
2
+ margin-bottom: 5px;
3
+ }
4
+ .toggle-slider span:first-child {
5
+ align-items: center;
6
+ display: flex;
7
+ margin-right: 8px;
8
+ }
9
+ .toggle-slider span:last-child {
10
+ align-items: center;
11
+ display: flex;
12
+ margin-left: 8px;
13
+ }
14
+ .toggle-slider span.slider {
15
+ margin: 0px;
16
+ }
17
+ .toggle-slider .toggle-content {
18
+ display: flex;
19
+ }
20
+ .toggle-slider .switch {
21
+ position: relative;
22
+ display: inline-block;
23
+ width: 60px;
24
+ height: 34px;
25
+ }
26
+
27
+ .toggle-slider .switch input {
28
+ opacity: 0;
29
+ width: 0;
30
+ height: 0;
31
+ }
32
+
33
+ .toggle-slider .slider {
34
+ position: absolute;
35
+ cursor: pointer;
36
+ top: 0;
37
+ left: 0;
38
+ right: 0;
39
+ bottom: 0;
40
+ background-color: #ccc;
41
+ -webkit-transition: 0.4s;
42
+ transition: 0.4s;
43
+ }
44
+
45
+ .toggle-slider .slider:before {
46
+ position: absolute;
47
+ content: "";
48
+ height: 26px;
49
+ width: 26px;
50
+ left: 4px;
51
+ bottom: 4px;
52
+ background-color: white;
53
+ -webkit-transition: 0.4s;
54
+ transition: 0.4s;
55
+ }
56
+
57
+ .toggle-slider input:checked + .slider {
58
+ background-color: #171a1f;
59
+ }
60
+
61
+ .toggle-slider input:focus + .slider {
62
+ box-shadow: 0 0 1px #171a1f;
63
+ }
64
+
65
+ .toggle-slider input:checked + .slider:before {
66
+ -webkit-transform: translateX(26px);
67
+ -ms-transform: translateX(26px);
68
+ transform: translateX(26px);
69
+ }
70
+
71
+ /* Rounded sliders */
72
+ .toggle-slider .slider.round {
73
+ border-radius: 34px;
74
+ }
75
+
76
+ .toggle-slider .slider.round:before {
77
+ border-radius: 50%;
78
+ }
79
+
80
+ .table-container {
81
+ overflow-y: auto; /* Add vertical scrolling */
82
+ margin-top: 20px;
83
+ }
84
+
85
+ .sms-container {
86
+ display: noned;
87
+ }
88
+
89
+ .group-buttons .button {
90
+ padding: 7px 12px;
91
+ cursor: pointer;
92
+ }
93
+ .action-buttons {
94
+ display: block;
95
+ margin: 13px auto;
96
+ }
97
+
98
+ .group-buttons .button {
99
+ background: #ffff;
100
+ color: #000;
101
+ border: 1px solid #f2f2f2;
102
+ }
103
+
104
+ .group-buttons .button.active {
105
+ background: #565e6d;
106
+ color: #fff;
107
+ }
108
+ .sms-participants table input[type="checkbox"] {
109
+ cursor: pointer;
110
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ *
3
+ * Initializer
4
+ *
5
+ */
6
+
7
+ import { useEffect, useRef } from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import pluginId from '../../pluginId';
10
+
11
+ const Initializer = ({ setPlugin }) => {
12
+ const ref = useRef();
13
+ ref.current = setPlugin;
14
+
15
+ useEffect(() => {
16
+ ref.current(pluginId);
17
+ }, []);
18
+
19
+ return null;
20
+ };
21
+
22
+ Initializer.propTypes = {
23
+ setPlugin: PropTypes.func.isRequired,
24
+ };
25
+
26
+ export default Initializer;
@@ -0,0 +1,12 @@
1
+ /**
2
+ *
3
+ * PluginIcon
4
+ *
5
+ */
6
+
7
+ import React from 'react';
8
+ import { Clock } from '@strapi/icons';
9
+
10
+ const PluginIcon = () => <Clock />;
11
+
12
+ export default PluginIcon;
@@ -0,0 +1,12 @@
1
+ /**
2
+ *
3
+ * PluginIcon
4
+ *
5
+ */
6
+
7
+ import React from 'react';
8
+ import { Clock } from '@strapi/icons';
9
+
10
+ export const TimezoneIcon = () => <Clock />
11
+
12
+
@@ -0,0 +1,70 @@
1
+ import React, { useState, useEffect } from "react";
2
+ import { SingleSelect, SingleSelectOption, Typography } from "@strapi/design-system";
3
+ import { useIntl } from "react-intl";
4
+ import { useTimezoneSelect, allTimezones } from "react-timezone-select";
5
+
6
+ const TimeZone = ({ attribute, disabled, intlLabel, name, onChange, required, value }) => {
7
+ const { formatMessage } = useIntl();
8
+ const [hasError, setHasError] = useState(false);
9
+
10
+ const labelStyle = "original";
11
+ const displayValue = "UTC";
12
+ const timezones = {
13
+ ...allTimezones,
14
+ "Europe/Berlin": "Frankfurt",
15
+ };
16
+ const { options, parseTimezone } = useTimezoneSelect({
17
+ labelStyle,
18
+ timezones,
19
+ displayValue,
20
+ });
21
+
22
+ useEffect(() => {
23
+ if (required && (!value || value === "")) {
24
+ setHasError(true);
25
+ } else {
26
+ setHasError(false);
27
+ }
28
+ }, [value, required]);
29
+
30
+ const handleChange = (selectedOption) => {
31
+ // If required, check if the value is empty
32
+ if (required && !selectedOption) {
33
+ setHasError(true);
34
+ } else {
35
+ setHasError(false);
36
+ }
37
+
38
+ onChange({
39
+ target: { name, type: attribute.type, value: selectedOption },
40
+ });
41
+ };
42
+
43
+ return (
44
+ <div className="Timezone sc-bdvvtL sc-gsDKAQ bOQZK hFpgBC">
45
+ <Typography textColor="neutral800">
46
+ {formatMessage(intlLabel)}
47
+ </Typography>
48
+ <SingleSelect
49
+ name={name}
50
+ onChange={handleChange}
51
+ value={value || ""}
52
+ required={required}
53
+ disabled={disabled}
54
+ >
55
+ {/* Default option for placeholder */}
56
+ <SingleSelectOption value="" >
57
+ {formatMessage({ id: "select.any.timezone", defaultMessage: "Select any timezone" })}
58
+ </SingleSelectOption>
59
+ {options.map((timezone, index) => (
60
+ <SingleSelectOption key={index} value={timezone?.value}>{timezone?.label}</SingleSelectOption>
61
+ ))}
62
+ </SingleSelect>
63
+ {required && hasError && (
64
+ <p style={{ color: 'red' }}>This field is required.</p> // Display error message
65
+ )}
66
+ </div>
67
+ );
68
+ };
69
+
70
+ export default TimeZone;
@@ -0,0 +1,84 @@
1
+ import { prefixPluginTranslations } from '@strapi/helper-plugin';
2
+ import pluginPkg from '../../package.json';
3
+ import pluginId from './pluginId';
4
+ import Initializer from './components/Initializer';
5
+ import PluginIcon from './components/PluginIcon';
6
+ import {TimezoneIcon} from './components/PluginIcons';
7
+ //import "./components/CustomField.css"; // Import CSS file
8
+
9
+ const name = pluginPkg.strapi.name;
10
+
11
+ export default {
12
+ register(app) {
13
+ app.registerPlugin({
14
+ id: pluginId,
15
+ initializer: Initializer,
16
+ isReady: false,
17
+ name,
18
+ });
19
+ app.customFields.register([
20
+ {
21
+ name: "timeZone",
22
+ pluginId: pluginId,
23
+ type: "string", // Store the timezone value as a string
24
+ intlLabel: {
25
+ id: `${pluginId}.timeZone.name`,
26
+ defaultMessage: "Timezone",
27
+ },
28
+ intlDescription: {
29
+ id: `${pluginId}.timeZone.description`,
30
+ defaultMessage: "Dynamic TimeZone listing",
31
+ },
32
+ icon: PluginIcon,
33
+ components: {
34
+ Input: async () =>
35
+ import(/* webpackChunkName: "input-component" */ "./components/TimeZone"),
36
+ },
37
+ options: {
38
+ advanced: [
39
+ {
40
+ sectionTitle: {
41
+ id: 'global.advanced',
42
+ defaultMessage: 'Settings',
43
+ },
44
+ items: [
45
+ {
46
+ intlLabel: { id: 'global.required', defaultMessage: 'Required' },
47
+ name: 'required',
48
+ type: 'checkbox',
49
+ description: {
50
+ id: 'global.required.description',
51
+ defaultMessage: 'Make this field required',
52
+ },
53
+ },
54
+ ],
55
+ },
56
+ ],
57
+ },
58
+ }
59
+ ]);
60
+ },
61
+
62
+ bootstrap(app) {},
63
+ async registerTrads({ locales }) {
64
+ const importedTrads = await Promise.all(
65
+ locales.map((locale) => {
66
+ return import(`./translations/${locale}.json`)
67
+ .then(({ default: data }) => {
68
+ return {
69
+ data: prefixPluginTranslations(data, pluginId),
70
+ locale,
71
+ };
72
+ })
73
+ .catch(() => {
74
+ return {
75
+ data: {},
76
+ locale,
77
+ };
78
+ });
79
+ })
80
+ );
81
+
82
+ return Promise.resolve(importedTrads);
83
+ },
84
+ };
@@ -0,0 +1,25 @@
1
+ /**
2
+ *
3
+ * This component is the skeleton around the actual pages, and should only
4
+ * contain code that should be seen on all pages. (e.g. navigation bar)
5
+ *
6
+ */
7
+
8
+ import React from 'react';
9
+ import { Switch, Route } from 'react-router-dom';
10
+ import { AnErrorOccurred } from '@strapi/helper-plugin';
11
+ import pluginId from '../../pluginId';
12
+ import HomePage from '../HomePage';
13
+
14
+ const App = () => {
15
+ return (
16
+ <div>
17
+ <Switch>
18
+ <Route path={`/plugins/${pluginId}`} component={HomePage} exact />
19
+ <Route component={AnErrorOccurred} />
20
+ </Switch>
21
+ </div>
22
+ );
23
+ };
24
+
25
+ export default App;
@@ -0,0 +1,20 @@
1
+ /*
2
+ *
3
+ * HomePage
4
+ *
5
+ */
6
+
7
+ import React from 'react';
8
+ // import PropTypes from 'prop-types';
9
+ import pluginId from '../../pluginId';
10
+
11
+ const HomePage = () => {
12
+ return (
13
+ <div>
14
+ <h1>{pluginId}&apos;s HomePage</h1>
15
+ <p>Happy coding</p>
16
+ </div>
17
+ );
18
+ };
19
+
20
+ export default HomePage;
@@ -0,0 +1,5 @@
1
+ import pluginPkg from '../../package.json';
2
+
3
+ const pluginId = pluginPkg.name.replace(/^(@[^-,.][\w,-]+\/|strapi-)plugin-/i, '');
4
+
5
+ export default pluginId;
@@ -0,0 +1 @@
1
+ {}
@@ -0,0 +1 @@
1
+ {}
@@ -0,0 +1,5 @@
1
+ import pluginId from '../pluginId';
2
+
3
+ const getTrad = (id) => `${pluginId}.${id}`;
4
+
5
+ export default getTrad;
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "startbit-timezone-select",
3
+ "version": "0.0.0",
4
+ "description": "This is the description of the plugin.",
5
+ "strapi": {
6
+ "name": "startbit-timezone-select",
7
+ "description": "Description of Startbit Timezone Select plugin",
8
+ "kind": "plugin",
9
+ "displayName": "Startbit Timezone Select"
10
+ },
11
+ "dependencies": {
12
+ "@strapi/design-system": "^1.6.3",
13
+ "@strapi/helper-plugin": "^4.6.0",
14
+ "@strapi/icons": "^1.6.3",
15
+ "prop-types": "^15.7.2"
16
+ },
17
+ "devDependencies": {
18
+ "react": "^18.2.0",
19
+ "react-dom": "^18.2.0",
20
+ "react-router-dom": "^5.3.4",
21
+ "styled-components": "^5.3.6"
22
+ },
23
+ "peerDependencies": {
24
+ "react": "^17.0.0 || ^18.0.0",
25
+ "react-dom": "^17.0.0 || ^18.0.0",
26
+ "react-router-dom": "^5.2.0",
27
+ "styled-components": "^5.2.1",
28
+ "react-timezone-select": "^3.2.8"
29
+ },
30
+ "author": {
31
+ "name": "A Strapi developer"
32
+ },
33
+ "maintainers": [
34
+ {
35
+ "name": "A Strapi developer"
36
+ }
37
+ ],
38
+ "engines": {
39
+ "node": ">=18.0.0 <=20.x.x",
40
+ "npm": ">=6.0.0"
41
+ },
42
+ "license": "MIT"
43
+ }
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ module.exports = ({ strapi }) => {
4
+ // bootstrap phase
5
+ };
@@ -0,0 +1,6 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ default: {},
5
+ validator() {},
6
+ };
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ module.exports = {};
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ const myController = require('./my-controller');
4
+
5
+ module.exports = {
6
+ myController,
7
+ };
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ module.exports = ({ strapi }) => ({
4
+ index(ctx) {
5
+ ctx.body = strapi
6
+ .plugin('startbit-timezone-select')
7
+ .service('myService')
8
+ .getWelcomeMessage();
9
+ },
10
+ });
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ module.exports = ({ strapi }) => {
4
+ // destroy phase
5
+ };
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ const register = require('./register');
4
+ const bootstrap = require('./bootstrap');
5
+ const destroy = require('./destroy');
6
+ const config = require('./config');
7
+ const contentTypes = require('./content-types');
8
+ const controllers = require('./controllers');
9
+ const routes = require('./routes');
10
+ const middlewares = require('./middlewares');
11
+ const policies = require('./policies');
12
+ const services = require('./services');
13
+
14
+ module.exports = {
15
+ register,
16
+ bootstrap,
17
+ destroy,
18
+ config,
19
+ controllers,
20
+ routes,
21
+ services,
22
+ contentTypes,
23
+ policies,
24
+ middlewares,
25
+ };
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ module.exports = {};
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ module.exports = {};
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ module.exports = ({ strapi }) => {
4
+ // register phase
5
+ strapi.customFields.register([{
6
+ name: "timeZone",
7
+ plugin: "startbit-timezone-select",
8
+ type: "string",
9
+ }]);
10
+ };
@@ -0,0 +1,10 @@
1
+ module.exports = [
2
+ {
3
+ method: 'GET',
4
+ path: '/',
5
+ handler: 'myController.index',
6
+ config: {
7
+ policies: [],
8
+ },
9
+ },
10
+ ];
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ const myService = require('./my-service');
4
+
5
+ module.exports = {
6
+ myService,
7
+ };
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ module.exports = ({ strapi }) => ({
4
+ getWelcomeMessage() {
5
+ return 'Welcome to Strapi 🚀';
6
+ },
7
+ });
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ module.exports = require('./admin/src').default;
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ module.exports = require('./server');