@akinon/pz-basket-gift-pack 1.48.0 → 1.50.0-rc.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @akinon/pz-basket-gift-pack
2
2
 
3
+ ## 1.50.0-rc.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 50b90692: ZERO-2767: update plugin readme files
8
+ - 18e8197: ZERO-2782: Add modal support for basket gift pack
9
+ - 64699d3: ZERO-2761: Fix invalid import for plugin module
10
+
11
+ ## 1.49.0
12
+
3
13
  ## 1.48.0
4
14
 
5
15
  ## 1.47.0
package/README.md CHANGED
@@ -1,35 +1,31 @@
1
- # pz-basket-gift-pack
1
+ # @akinon/pz-basket-gift-pack
2
2
 
3
3
  ### Install the npm package
4
4
 
5
5
  ```bash
6
6
  # For latest version
7
- yarn add ​git+ssh://git@bitbucket.org:akinonteam/pz-basket-gift-pack.git
7
+ yarn add @akinon/pz-basket-gift-pack
8
8
 
9
- # For specific version
10
- yarn add ​git+ssh://git@bitbucket.org:akinonteam/pz-basket-gift-pack.git#0e7cde5
11
- ```
12
-
13
- ### Next Config Configuration
14
-
15
- ##### apps/web/next.config.js**
16
-
17
- ```javascript
18
- const withTM = require("next-transpile-modules")(["pz-basket-gift-pack"]);
9
+ # Preferred installation method
10
+ npx @akinon/projectzero@latest --plugins
19
11
  ```
20
12
 
21
13
  ### Example Usage
22
- ##### File Path: src/views/basket/basket-item.tsx
23
14
 
15
+ ##### File Path: src/views/basket/basket-item.tsx
24
16
 
25
17
  ```javascript
26
18
  import { BasketGiftPackage } from 'pz-basket-gift-pack';
27
19
 
28
- <BasketGiftPackage basketItem={basketItem}/>
20
+ <BasketGiftPackage basketItem={basketItem} />;
29
21
  ```
30
22
 
31
23
  ### Props
32
24
 
33
- | Properties | Type | Description |
34
- | ---------- | -------- | -------------------- |
35
- | basketItem | `object` | Product information. |
25
+ | Properties | Type | Description |
26
+ | --- | --- | --- |
27
+ | basketItem | `object` | Product information. |
28
+ | useModal | `boolean` | This prop determines whether the gift pack form will be displayed inside a modal. When set to true, the form will open inside a modal. |
29
+ | modalClassName | `string` | This prop is used to customize the overall style of the modal. |
30
+ | modalTitle | `string` | This prop sets the title of the modal. |
31
+ | modalContentClassName | `string` | This prop is used to customize the style of the modal content. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/pz-basket-gift-pack",
3
- "version": "1.48.0",
3
+ "version": "1.50.0-rc.0",
4
4
  "license": "MIT",
5
5
  "main": "src/index.tsx",
6
6
  "peerDependencies": {
package/src/index.tsx CHANGED
@@ -8,8 +8,7 @@ import { useForm, SubmitHandler } from 'react-hook-form';
8
8
  import { yupResolver } from '@hookform/resolvers/yup';
9
9
  import * as yup from 'yup';
10
10
  import { useEffect, useState } from 'react';
11
- import { Button } from '@akinon/next/components/button';
12
- import { Icon } from '@akinon/next/components/icon';
11
+ import { Button, Icon, Modal } from '@akinon/next/components';
13
12
  import { BasketItem as BasketItemType } from '@akinon/next/types';
14
13
 
15
14
  interface GiftPackForm {
@@ -18,6 +17,10 @@ interface GiftPackForm {
18
17
 
19
18
  interface Props {
20
19
  basketItem: BasketItemType;
20
+ useModal?: boolean;
21
+ modalTitle?: string;
22
+ modalClassName?: string;
23
+ modalContentClassName?: string;
21
24
  translations?: {
22
25
  placeholderInput?: string;
23
26
  warningMessage?: string;
@@ -38,7 +41,11 @@ interface Props {
38
41
  export const BasketGiftPack = ({
39
42
  basketItem,
40
43
  translations,
41
- className
44
+ className,
45
+ useModal = false,
46
+ modalTitle = 'Gift Note',
47
+ modalClassName,
48
+ modalContentClassName
42
49
  }: Props) => {
43
50
  const defaultTranslations = {
44
51
  placeholderInput:
@@ -130,6 +137,61 @@ export const BasketGiftPack = ({
130
137
  }
131
138
  };
132
139
 
140
+ const formContent = (
141
+ <form onSubmit={handleSubmit(onSubmit)}>
142
+ {!useModal && (
143
+ <div className="flex justify-between mb-3">
144
+ <span className="text-[0.75rem] font-bold">
145
+ {_translations.addGiftNote}
146
+ </span>
147
+ <Button
148
+ appearance="ghost"
149
+ className="text-[#000000] cursor-pointer border-0 px-0 py-0 text-[0.75rem] select-none underline h-auto hover:bg-transparent hover:text-[#000000]"
150
+ onClick={(e) => {
151
+ e.preventDefault();
152
+ setHasNote((prevstate) => ({ ...prevstate, state: false }));
153
+ }}
154
+ >
155
+ {_translations.close}
156
+ </Button>
157
+ </div>
158
+ )}
159
+ <textarea
160
+ className="w-full border border-solid border-[#4a4f53] p-4 placeholder:text-[0.75rem] placeholder:text-[#c8c9c8] outline-none text-[0.75rem]"
161
+ rows={7}
162
+ name="message"
163
+ value={note !== defaultMessage ? note : ' '}
164
+ placeholder={_translations.placeholderInput}
165
+ {...register('message')}
166
+ />
167
+ {errors.message && (
168
+ <span className="text-sm text-[#d72a04]">{errors.message.message}</span>
169
+ )}
170
+ <div className="flex justify-between items-center mt-2">
171
+ <span
172
+ className={clsx(
173
+ 'text-[0.75rem] ',
174
+ textAreaCount > 160 ? 'text-[#e85150]' : 'text-[#82a27c]'
175
+ )}
176
+ >
177
+ {textAreaCount}/160 {_translations.charactersLength}
178
+ </span>
179
+ <div className="flex items-center gap-3">
180
+ <Button
181
+ appearance="ghost"
182
+ className="text-[#000000] cursor-pointer border-0 px-0 py-0 text-[0.75rem] select-none underline h-auto hover:bg-transparent hover:text-[#000000]"
183
+ onClick={removeNote}
184
+ >
185
+ {_translations.removeNote}
186
+ </Button>
187
+ <Button type="submit" className="w-28 h-7 font-medium uppercase">
188
+ {_translations.save}
189
+ </Button>
190
+ </div>
191
+ </div>
192
+ </form>
193
+ );
194
+
133
195
  useEffect(() => {
134
196
  for (const [key, value] of Object.entries(basketItem.attributes)) {
135
197
  if (value === '') {
@@ -220,64 +282,32 @@ export const BasketGiftPack = ({
220
282
  {_translations.removeGiftPack}
221
283
  </Button>
222
284
  </div>
223
- <div
224
- className={clsx('mt-4', {
225
- hidden: !hasNote.state
226
- })}
227
- >
228
- <form onSubmit={handleSubmit(onSubmit)}>
229
- <div className="flex justify-between mb-3">
230
- <span className="text-[0.75rem] font-bold">
231
- {_translations.addGiftNote}
232
- </span>
233
- <Button
234
- appearance="ghost"
235
- className="text-[#000000] cursor-pointer border-0 px-0 py-0 text-[0.75rem] select-none underline h-auto hover:bg-transparent hover:text-[#000000]"
236
- onClick={(e) => {
237
- e.preventDefault();
238
- setHasNote((prevstate) => ({ ...prevstate, state: false }));
239
- }}
240
- >
241
- {_translations.close}
242
- </Button>
243
- </div>
244
- <textarea
245
- className="w-full border border-solid border-[#4a4f53] p-4 placeholder:text-[0.75rem] placeholder:text-[#c8c9c8] outline-none text-[0.75rem]"
246
- rows={7}
247
- name="message"
248
- value={note !== defaultMessage ? note : ' '}
249
- placeholder={_translations.placeholderInput}
250
- {...register('message')}
251
- />
252
- {errors.message && (
253
- <span className="text-sm text-[#d72a04]">
254
- {errors.message.message}
255
- </span>
285
+ {useModal ? (
286
+ <Modal
287
+ portalId="basket-gift-pack-modal"
288
+ title={modalTitle}
289
+ className={twMerge(
290
+ 'w-full sm:w-[28rem] max-h-[90vh] overflow-y-auto',
291
+ modalClassName
256
292
  )}
257
- <div className="flex justify-between items-center mt-2">
258
- <span
259
- className={clsx(
260
- 'text-[0.75rem] ',
261
- textAreaCount > 160 ? 'text-[#e85150]' : 'text-[#82a27c]'
262
- )}
263
- >
264
- {textAreaCount}/160 {_translations.charactersLength}
265
- </span>
266
- <div className="flex items-center gap-3">
267
- <Button
268
- appearance="ghost"
269
- className="text-[#000000] cursor-pointer border-0 px-0 py-0 text-[0.75rem] select-none underline h-auto hover:bg-transparent hover:text-[#000000]"
270
- onClick={removeNote}
271
- >
272
- {_translations.removeNote}
273
- </Button>
274
- <Button type="submit" className="w-28 h-7 font-medium uppercase">
275
- {_translations.save}
276
- </Button>
277
- </div>
293
+ open={hasNote.state}
294
+ setOpen={(state) =>
295
+ setHasNote((prevstate) => ({ ...prevstate, state }))
296
+ }
297
+ >
298
+ <div className={twMerge('px-6 py-4', modalContentClassName)}>
299
+ {formContent}
278
300
  </div>
279
- </form>
280
- </div>
301
+ </Modal>
302
+ ) : (
303
+ <div
304
+ className={clsx('mt-4', {
305
+ hidden: !hasNote.state
306
+ })}
307
+ >
308
+ {formContent}
309
+ </div>
310
+ )}
281
311
  </div>
282
312
  );
283
313
  };