@akinon/pz-basket-gift-pack 1.50.0-rc.1 → 1.51.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,14 +1,8 @@
1
1
  # @akinon/pz-basket-gift-pack
2
2
 
3
- ## 1.50.0-rc.1
3
+ ## 1.51.0
4
4
 
5
- ## 1.50.0-rc.0
6
-
7
- ### Minor Changes
8
-
9
- - 50b90692: ZERO-2767: update plugin readme files
10
- - 18e8197: ZERO-2782: Add modal support for basket gift pack
11
- - 64699d3: ZERO-2761: Fix invalid import for plugin module
5
+ ## 1.50.0
12
6
 
13
7
  ## 1.49.0
14
8
 
package/README.md CHANGED
@@ -1,31 +1,35 @@
1
- # @akinon/pz-basket-gift-pack
1
+ # 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 @akinon/pz-basket-gift-pack
7
+ yarn add ​git+ssh://git@bitbucket.org:akinonteam/pz-basket-gift-pack.git
8
8
 
9
- # Preferred installation method
10
- npx @akinon/projectzero@latest --plugins
9
+ # For specific version
10
+ yarn add ​git+ssh://git@bitbucket.org:akinonteam/pz-basket-gift-pack.git#0e7cde5
11
11
  ```
12
12
 
13
- ### Example Usage
13
+ ### Next Config Configuration
14
+
15
+ ##### apps/web/next.config.js**
14
16
 
17
+ ```javascript
18
+ const withTM = require("next-transpile-modules")(["pz-basket-gift-pack"]);
19
+ ```
20
+
21
+ ### Example Usage
15
22
  ##### File Path: src/views/basket/basket-item.tsx
16
23
 
24
+
17
25
  ```javascript
18
26
  import { BasketGiftPackage } from 'pz-basket-gift-pack';
19
27
 
20
- <BasketGiftPackage basketItem={basketItem} />;
28
+ <BasketGiftPackage basketItem={basketItem}/>
21
29
  ```
22
30
 
23
31
  ### Props
24
32
 
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. |
33
+ | Properties | Type | Description |
34
+ | ---------- | -------- | -------------------- |
35
+ | basketItem | `object` | Product information. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/pz-basket-gift-pack",
3
- "version": "1.50.0-rc.1",
3
+ "version": "1.51.0",
4
4
  "license": "MIT",
5
5
  "main": "src/index.tsx",
6
6
  "peerDependencies": {
package/src/index.tsx CHANGED
@@ -8,7 +8,8 @@ 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, Icon, Modal } from '@akinon/next/components';
11
+ import { Button } from '@akinon/next/components/button';
12
+ import { Icon } from '@akinon/next/components/icon';
12
13
  import { BasketItem as BasketItemType } from '@akinon/next/types';
13
14
 
14
15
  interface GiftPackForm {
@@ -17,10 +18,6 @@ interface GiftPackForm {
17
18
 
18
19
  interface Props {
19
20
  basketItem: BasketItemType;
20
- useModal?: boolean;
21
- modalTitle?: string;
22
- modalClassName?: string;
23
- modalContentClassName?: string;
24
21
  translations?: {
25
22
  placeholderInput?: string;
26
23
  warningMessage?: string;
@@ -41,11 +38,7 @@ interface Props {
41
38
  export const BasketGiftPack = ({
42
39
  basketItem,
43
40
  translations,
44
- className,
45
- useModal = false,
46
- modalTitle = 'Gift Note',
47
- modalClassName,
48
- modalContentClassName
41
+ className
49
42
  }: Props) => {
50
43
  const defaultTranslations = {
51
44
  placeholderInput:
@@ -137,61 +130,6 @@ export const BasketGiftPack = ({
137
130
  }
138
131
  };
139
132
 
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
-
195
133
  useEffect(() => {
196
134
  for (const [key, value] of Object.entries(basketItem.attributes)) {
197
135
  if (value === '') {
@@ -282,32 +220,64 @@ export const BasketGiftPack = ({
282
220
  {_translations.removeGiftPack}
283
221
  </Button>
284
222
  </div>
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
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>
292
256
  )}
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}
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>
300
278
  </div>
301
- </Modal>
302
- ) : (
303
- <div
304
- className={clsx('mt-4', {
305
- hidden: !hasNote.state
306
- })}
307
- >
308
- {formContent}
309
- </div>
310
- )}
279
+ </form>
280
+ </div>
311
281
  </div>
312
282
  );
313
283
  };