tee3apps-cms-sdk-react 0.0.9 → 0.0.10

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,170 @@
1
+ .terms-and-condition {
2
+ margin-bottom: 1.5rem;
3
+ }
4
+
5
+ .terms-and-condition__container {
6
+ display: flex;
7
+ align-items: flex-start;
8
+ gap: 0.75rem;
9
+ }
10
+
11
+ .terms-and-condition__checkbox-wrapper {
12
+ display: flex;
13
+ align-items: center;
14
+ height: 1.25rem;
15
+ margin-top: 0.125rem;
16
+ }
17
+
18
+ .terms-and-condition__checkbox {
19
+ width: 1rem;
20
+ height: 1rem;
21
+ border: 1px solid #d1d5db; /* gray-300 */
22
+ border-radius: 0.25rem;
23
+ accent-color: #2563eb; /* blue-600 */
24
+ cursor: pointer;
25
+ }
26
+
27
+ .terms-and-condition__content {
28
+ flex: 1;
29
+ }
30
+
31
+ .terms-and-condition__label {
32
+ font-size: 0.875rem;
33
+ font-weight: 400;
34
+ color: #374151; /* gray-700 */
35
+ display: block;
36
+ line-height: 1.5;
37
+ }
38
+
39
+ .terms-and-condition__terms-link {
40
+ color: #2563eb; /* blue-600 */
41
+ text-decoration: underline;
42
+ cursor: pointer;
43
+ transition: color 0.2s;
44
+ }
45
+
46
+ .terms-and-condition__terms-link:hover {
47
+ color: #1d4ed8; /* blue-700 */
48
+ }
49
+
50
+ .terms-and-condition__terms-link p {
51
+ margin: 0;
52
+ display: inline;
53
+ }
54
+
55
+ .terms-and-condition__required {
56
+ color: #ef4444; /* red-500 */
57
+ margin-left: 0.25rem;
58
+ }
59
+
60
+ .terms-and-condition__helper-text {
61
+ margin-top: 0.25rem;
62
+ font-size: 0.75rem;
63
+ color: #6b7280; /* gray-500 */
64
+ }
65
+
66
+ /* Modal Styles */
67
+ .terms-and-condition__modal-overlay {
68
+ position: fixed;
69
+ top: 0;
70
+ left: 0;
71
+ right: 0;
72
+ bottom: 0;
73
+ background-color: rgba(0, 0, 0, 0.5);
74
+ display: flex;
75
+ align-items: center;
76
+ justify-content: center;
77
+ z-index: 1000;
78
+ padding: 1rem;
79
+ }
80
+
81
+ .terms-and-condition__modal {
82
+ background-color: #ffffff;
83
+ border-radius: 0.5rem;
84
+ box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
85
+ max-width: 600px;
86
+ width: 100%;
87
+ max-height: 80vh;
88
+ display: flex;
89
+ flex-direction: column;
90
+ overflow: hidden;
91
+ }
92
+
93
+ .terms-and-condition__modal-header {
94
+ display: flex;
95
+ align-items: center;
96
+ justify-content: space-between;
97
+ padding: 1.25rem 1.5rem;
98
+ border-bottom: 1px solid #e5e7eb; /* gray-200 */
99
+ }
100
+
101
+ .terms-and-condition__modal-title {
102
+ font-size: 1.25rem;
103
+ font-weight: 600;
104
+ color: #111827; /* gray-900 */
105
+ margin: 0;
106
+ }
107
+
108
+ .terms-and-condition__modal-close {
109
+ background: none;
110
+ border: none;
111
+ cursor: pointer;
112
+ padding: 0.25rem;
113
+ color: #6b7280; /* gray-500 */
114
+ transition: color 0.2s;
115
+ display: flex;
116
+ align-items: center;
117
+ justify-content: center;
118
+ }
119
+
120
+ .terms-and-condition__modal-close:hover {
121
+ color: #374151; /* gray-700 */
122
+ }
123
+
124
+ .terms-and-condition__modal-body {
125
+ padding: 1.5rem;
126
+ overflow-y: auto;
127
+ flex: 1;
128
+ }
129
+
130
+ .terms-and-condition__modal-content {
131
+ font-size: 0.875rem;
132
+ color: #374151; /* gray-700 */
133
+ line-height: 1.6;
134
+ }
135
+
136
+ .terms-and-condition__modal-content p {
137
+ margin: 0 0 1rem 0;
138
+ }
139
+
140
+ .terms-and-condition__modal-content p:last-child {
141
+ margin-bottom: 0;
142
+ }
143
+
144
+ .terms-and-condition__modal-footer {
145
+ padding: 1rem 1.5rem;
146
+ border-top: 1px solid #e5e7eb; /* gray-200 */
147
+ display: flex;
148
+ justify-content: flex-end;
149
+ }
150
+
151
+ .terms-and-condition__modal-button {
152
+ background-color: #2563eb; /* blue-600 */
153
+ color: #ffffff;
154
+ border: none;
155
+ border-radius: 0.375rem;
156
+ padding: 0.5rem 1rem;
157
+ font-size: 0.875rem;
158
+ font-weight: 500;
159
+ cursor: pointer;
160
+ transition: background-color 0.2s;
161
+ }
162
+
163
+ .terms-and-condition__modal-button:hover {
164
+ background-color: #1d4ed8; /* blue-700 */
165
+ }
166
+
167
+ .terms-and-condition__modal-button:active {
168
+ background-color: #1e40af; /* blue-800 */
169
+ }
170
+
@@ -0,0 +1,130 @@
1
+ import React, { useState } from 'react';
2
+ import type { ComponentProps } from '../types';
3
+ import './Styles/TermsAndCondition.css';
4
+
5
+ interface TermsAndConditionProps {
6
+ props: ComponentProps & {
7
+ conditionText?: { all?: string };
8
+ termsText?: { all?: string };
9
+ isRequired?: boolean;
10
+ checked?: boolean;
11
+ };
12
+ value?: boolean;
13
+ onChange?: (code: string, value: boolean) => void;
14
+ }
15
+
16
+ const TermsAndCondition: React.FC<TermsAndConditionProps> = ({
17
+ props,
18
+ value = false,
19
+ onChange
20
+ }) => {
21
+ const [isModalOpen, setIsModalOpen] = useState(false);
22
+
23
+ const handleCheckboxChange = (e: React.ChangeEvent<HTMLInputElement>) => {
24
+ if (onChange) {
25
+ const code = props.code || `termsandcondition_${props.name?.all || 'field'}`;
26
+ onChange(code, e.target.checked);
27
+ }
28
+ };
29
+
30
+ const handleTermsClick = (e: React.MouseEvent) => {
31
+ e.preventDefault();
32
+ setIsModalOpen(true);
33
+ };
34
+
35
+ const closeModal = () => {
36
+ setIsModalOpen(false);
37
+ };
38
+
39
+ const handleModalBackdropClick = (e: React.MouseEvent<HTMLDivElement>) => {
40
+ if (e.target === e.currentTarget) {
41
+ closeModal();
42
+ }
43
+ };
44
+
45
+ const termsText = props.termsText?.all || '';
46
+ const conditionText = props.conditionText?.all || '';
47
+ const isRequired = props.isRequired || props.required || false;
48
+ // Use value if it's defined (even if false), otherwise fall back to props.checked, then false
49
+ const checked = value !== undefined && value !== null ? value : (props.checked ?? false);
50
+
51
+ // Parse HTML content safely
52
+ const createMarkup = (html: string) => {
53
+ return { __html: html };
54
+ };
55
+
56
+ return (
57
+ <div className="terms-and-condition">
58
+ <div className="terms-and-condition__container">
59
+ <div className="terms-and-condition__checkbox-wrapper">
60
+ <input
61
+ type="checkbox"
62
+ checked={checked}
63
+ onChange={handleCheckboxChange}
64
+ className="terms-and-condition__checkbox"
65
+ required={isRequired}
66
+ />
67
+ </div>
68
+ <div className="terms-and-condition__content">
69
+ <label className="terms-and-condition__label">
70
+ {termsText && (
71
+ <span
72
+ className="terms-and-condition__terms-link"
73
+ onClick={handleTermsClick}
74
+ dangerouslySetInnerHTML={createMarkup(termsText)}
75
+ />
76
+ )}
77
+ {isRequired && <span className="terms-and-condition__required">*</span>}
78
+ </label>
79
+
80
+ {props.helperText && (
81
+ <p className="terms-and-condition__helper-text">{props.helperText}</p>
82
+ )}
83
+ </div>
84
+ </div>
85
+
86
+ {/* Modal for Conditions */}
87
+ {isModalOpen && (
88
+ <div
89
+ className="terms-and-condition__modal-overlay"
90
+ onClick={handleModalBackdropClick}
91
+ >
92
+ <div className="terms-and-condition__modal">
93
+ <div className="terms-and-condition__modal-header">
94
+ <h2 className="terms-and-condition__modal-title">Terms and Conditions</h2>
95
+ <button
96
+ className="terms-and-condition__modal-close"
97
+ onClick={closeModal}
98
+ aria-label="Close"
99
+ >
100
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
101
+ <line x1="18" y1="6" x2="6" y2="18"></line>
102
+ <line x1="6" y1="6" x2="18" y2="18"></line>
103
+ </svg>
104
+ </button>
105
+ </div>
106
+ <div className="terms-and-condition__modal-body">
107
+ {conditionText && (
108
+ <div
109
+ className="terms-and-condition__modal-content"
110
+ dangerouslySetInnerHTML={createMarkup(conditionText)}
111
+ />
112
+ )}
113
+ </div>
114
+ <div className="terms-and-condition__modal-footer">
115
+ <button
116
+ className="terms-and-condition__modal-button"
117
+ onClick={closeModal}
118
+ >
119
+ Close
120
+ </button>
121
+ </div>
122
+ </div>
123
+ </div>
124
+ )}
125
+ </div>
126
+ );
127
+ };
128
+
129
+ export default TermsAndCondition;
130
+
package/src/types.ts CHANGED
@@ -154,6 +154,13 @@ export type ComponentProps = {
154
154
  disabled?: boolean;
155
155
  bgColor?: string;
156
156
  radius?: string;
157
+ // TermsAndCondition component props
158
+ conditionText?: { all?: string };
159
+ termsText?: { all?: string };
160
+ isRequired?: boolean;
161
+ checked?: boolean;
162
+ // Button component props
163
+ buttonType?: 'submit' | 'reset' | 'cancel';
157
164
  };
158
165
 
159
166
  export type Component = {