@anker-in/campaign-ui 0.2.10-beta.20 → 0.2.10-beta.22

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.
Files changed (109) hide show
  1. package/dist/components/chat/action.d.ts +25 -0
  2. package/dist/components/chat/button.d.ts +3 -0
  3. package/dist/components/chat/chatContext.d.ts +101 -0
  4. package/dist/components/chat/index.d.ts +71 -0
  5. package/dist/components/chat/markdown.d.ts +5 -0
  6. package/dist/components/chat/messages.d.ts +3 -0
  7. package/dist/components/chat/props.d.ts +43 -0
  8. package/dist/components/chat/response.d.ts +4 -0
  9. package/dist/components/chat/suggestions.d.ts +3 -0
  10. package/dist/components/chat/utils.d.ts +3 -0
  11. package/dist/components/credits/context/const.d.ts +81 -0
  12. package/dist/components/credits/context/hooks/useActivities.d.ts +12 -0
  13. package/dist/components/credits/context/hooks/useAddressValidate.d.ts +34 -0
  14. package/dist/components/credits/context/hooks/useAlpcFetch.d.ts +23 -0
  15. package/dist/components/credits/context/hooks/useClickOutside.d.ts +3 -0
  16. package/dist/components/credits/context/hooks/useCopy.d.ts +5 -0
  17. package/dist/components/credits/context/hooks/useCountries.d.ts +8 -0
  18. package/dist/components/credits/context/hooks/useFirstPurchaseFinished.d.ts +1 -0
  19. package/dist/components/credits/context/hooks/useMyRewards.d.ts +14 -0
  20. package/dist/components/credits/context/hooks/useReceiptUploaded.d.ts +2 -0
  21. package/dist/components/credits/context/hooks/useRedeemAndBuy.d.ts +9 -0
  22. package/dist/components/credits/context/hooks/useRedeemCoupon.d.ts +17 -0
  23. package/dist/components/credits/context/hooks/useRedeemProduct.d.ts +16 -0
  24. package/dist/components/credits/context/hooks/useRedeemableList.d.ts +7 -0
  25. package/dist/components/credits/context/hooks/useSendEmailValidation.d.ts +1 -0
  26. package/dist/components/credits/context/hooks/useSubscribed.d.ts +1 -0
  27. package/dist/components/credits/context/hooks/useSubscriptions.d.ts +5 -0
  28. package/dist/components/credits/context/hooks/useUploadReceipt.d.ts +14 -0
  29. package/dist/components/credits/context/provider.d.ts +49 -0
  30. package/dist/components/credits/context/response.d.ts +63 -0
  31. package/dist/components/credits/context/utils.d.ts +25 -0
  32. package/dist/components/credits/creditsBanner/index.d.ts +23 -0
  33. package/dist/components/credits/creditsBenefits/benefitItem.d.ts +19 -0
  34. package/dist/components/credits/creditsBenefits/iconInfo.d.ts +2 -0
  35. package/dist/components/credits/creditsBenefits/index.d.ts +12 -0
  36. package/dist/components/credits/creditsCash/RedeemableItem.d.ts +15 -0
  37. package/dist/components/credits/creditsCash/index.d.ts +13 -0
  38. package/dist/components/credits/creditsCash/type.d.ts +47 -0
  39. package/dist/components/credits/creditsFaq/faqItem/FaqItem.d.ts +13 -0
  40. package/dist/components/credits/creditsFaq/index.d.ts +16 -0
  41. package/dist/components/credits/creditsInfoCard/index.d.ts +20 -0
  42. package/dist/components/credits/creditsRedeemList/AddressForm/CountrySelect.d.ts +14 -0
  43. package/dist/components/credits/creditsRedeemList/AddressForm/FormItem.d.ts +6 -0
  44. package/dist/components/credits/creditsRedeemList/AddressForm/Input.d.ts +13 -0
  45. package/dist/components/credits/creditsRedeemList/AddressForm/StateSelect.d.ts +15 -0
  46. package/dist/components/credits/creditsRedeemList/AddressForm/index.d.ts +2 -0
  47. package/dist/components/credits/creditsRedeemList/AddressForm/type.d.ts +26 -0
  48. package/dist/components/credits/creditsRedeemList/RedeemCouponModal.d.ts +9 -0
  49. package/dist/components/credits/creditsRedeemList/RedeemProductModal/Address.d.ts +20 -0
  50. package/dist/components/credits/creditsRedeemList/RedeemProductModal/Error.d.ts +8 -0
  51. package/dist/components/credits/creditsRedeemList/RedeemProductModal/Init.d.ts +11 -0
  52. package/dist/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.d.ts +8 -0
  53. package/dist/components/credits/creditsRedeemList/RedeemProductModal/Success.d.ts +13 -0
  54. package/dist/components/credits/creditsRedeemList/RedeemProductModal/index.d.ts +11 -0
  55. package/dist/components/credits/creditsRedeemList/RedeemableItem.d.ts +9 -0
  56. package/dist/components/credits/creditsRedeemList/index.d.ts +13 -0
  57. package/dist/components/credits/creditsRedeemList/type.d.ts +77 -0
  58. package/dist/components/credits/creditsWaysToGetCredits/index.d.ts +2 -0
  59. package/dist/components/credits/creditsWaysToGetCredits/type.d.ts +60 -0
  60. package/dist/components/credits/creditsWaysToGetCredits/useActions.d.ts +96 -0
  61. package/dist/components/credits/index.d.ts +10 -0
  62. package/dist/components/credits/modal/MyRewardsModal.d.ts +32 -0
  63. package/dist/components/credits/modal/activitiesModal.d.ts +32 -0
  64. package/dist/components/credits/modal/creditsUploadReceiptModal.d.ts +24 -0
  65. package/dist/components/credits/modal/loadingDots.d.ts +6 -0
  66. package/dist/components/credits/modal/modalContainer.d.ts +15 -0
  67. package/dist/components/credits/modal/rulesModal.d.ts +7 -0
  68. package/dist/components/credits/modal/tip.d.ts +5 -0
  69. package/dist/components/credits/type.d.ts +55 -0
  70. package/dist/components/index.d.ts +3 -0
  71. package/dist/debug-env.d.ts +7 -0
  72. package/dist/helpers/fetchResponse.d.ts +14 -0
  73. package/dist/helpers/fetcher.d.ts +2 -0
  74. package/dist/helpers/index.d.ts +2 -0
  75. package/dist/helpers/track.d.ts +19 -0
  76. package/dist/helpers/utils.d.ts +3 -0
  77. package/dist/index.d.mts +3 -3
  78. package/dist/index.d.ts +2 -494
  79. package/dist/index.js +1318 -4377
  80. package/dist/index.js.map +1 -1
  81. package/dist/index.mjs +1294 -4330
  82. package/dist/index.mjs.map +1 -1
  83. package/dist/stories/chat.stories.d.ts +7 -0
  84. package/package.json +14 -9
  85. package/src/components/credits/context/hooks/useActivities.ts +1 -1
  86. package/src/components/credits/context/hooks/useAddressValidate.ts +1 -1
  87. package/src/components/credits/context/hooks/useAlpcFetch.ts +1 -1
  88. package/src/components/credits/context/hooks/useCountries.ts +1 -1
  89. package/src/components/credits/context/hooks/useMyRewards.ts +1 -1
  90. package/src/components/credits/context/hooks/useRedeemAndBuy.ts +2 -2
  91. package/src/components/credits/context/hooks/useRedeemCoupon.ts +1 -1
  92. package/src/components/credits/context/hooks/useRedeemProduct.ts +1 -1
  93. package/src/components/credits/context/hooks/useRedeemableList.ts +1 -1
  94. package/src/components/credits/context/hooks/useSendEmailValidation.ts +1 -1
  95. package/src/components/credits/context/hooks/useSubscribed.ts +1 -1
  96. package/src/components/credits/context/hooks/useSubscriptions.ts +1 -1
  97. package/src/components/credits/creditsCash/index.tsx +2 -2
  98. package/src/components/credits/creditsCash/type.ts +1 -1
  99. package/src/components/credits/creditsRedeemList/AddressForm/index.tsx +1 -1
  100. package/src/components/credits/creditsRedeemList/RedeemCouponModal.tsx +1 -1
  101. package/src/components/credits/creditsRedeemList/RedeemProductModal/Address.tsx +1 -1
  102. package/src/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.tsx +1 -1
  103. package/src/components/credits/creditsRedeemList/RedeemProductModal/index.tsx +1 -1
  104. package/src/components/credits/creditsRedeemList/index.tsx +1 -1
  105. package/src/components/credits/creditsWaysToGetCredits/useActions.ts +1 -1
  106. package/src/components/credits/type.ts +1 -1
  107. package/src/index.ts +1 -1
  108. package/src/styles/global.css +15 -0
  109. package/style.css +1 -0
@@ -0,0 +1,7 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { Chat } from '../components/index';
3
+ import '../styles/chat.css';
4
+ type Story = StoryObj<typeof meta>;
5
+ declare const meta: Meta<typeof Chat>;
6
+ export default meta;
7
+ export declare const Default: Story;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anker-in/campaign-ui",
3
- "version": "0.2.10-beta.20",
3
+ "version": "0.2.10-beta.22",
4
4
  "description": "Campaign UI components and utilities for Anker projects",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -46,7 +46,10 @@
46
46
  "@testing-library/react": "^14.3.1",
47
47
  "@types/jest": "^29.5.12",
48
48
  "@types/node": "^20",
49
+ "@types/react": "^18.3.3",
50
+ "@types/react-dom": "^18.3.0",
49
51
  "babel-jest": "^29.7.0",
52
+ "esbuild": "^0.19.0",
50
53
  "eslint-plugin-react-hooks": "^4.6.2",
51
54
  "eslint-plugin-require-extensions": "^0.1.3",
52
55
  "jest": "^29.7.0",
@@ -55,15 +58,12 @@
55
58
  "react-test-renderer": "^18.3.1",
56
59
  "stylelint": "^16.6.0",
57
60
  "tsup": "^8.4.0",
58
- "typescript": "^5.0.0",
59
- "@anker-in/cart": "1.0.0-beta.2",
60
- "@anker-in/shared": "1.0.0-beta.2",
61
- "@anker-in/shopify": "0.0.0-beta.6"
61
+ "typescript": "^5.0.0"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "react": "^18.3.1",
65
65
  "react-dom": "^18.3.1",
66
- "@anker-in/lib": "1.0.0-beta.6"
66
+ "@anker-in/lib": "0.0.0-beta.1"
67
67
  },
68
68
  "dependencies": {
69
69
  "@copilotkit/react-core": "1.1.2",
@@ -88,7 +88,9 @@
88
88
  "react-codepen-embed": "^1.1.0",
89
89
  "swiper": "^11.1.3",
90
90
  "tailwind-merge": "^2.3.0",
91
- "tailwindcss": "^3.4.3"
91
+ "tailwindcss": "^3.4.3",
92
+ "@anker-in/headless-ui": "1.0.19",
93
+ "@anker-in/lib": "0.0.0-beta.2"
92
94
  },
93
95
  "publishConfig": {
94
96
  "access": "public",
@@ -100,8 +102,11 @@
100
102
  "scripts": {
101
103
  "dev": "pnpm run dev:css & tsup --watch",
102
104
  "dev:css": "postcss src/styles/global.css -o style.css --watch",
103
- "build": "pnpm run build:css & tsup",
104
- "build:css": "postcss src/styles/chat.css -o style.css",
105
+ "build": "pnpm run build:css & pnpm run build:js:esm & pnpm run build:js:cjs & pnpm run build:types",
106
+ "build:css": "postcss src/styles/global.css -o style.css",
107
+ "build:js:cjs": "node esbuild-cjs.mjs",
108
+ "build:js:esm": "node esbuild-esm.mjs",
109
+ "build:types": "tsc --outdir dist",
105
110
  "lint": "eslint \"src/**/*.ts*\"",
106
111
  "test": "echo run @anker-in/campaign-ui tests",
107
112
  "type-check": "tsc --noEmit",
@@ -3,7 +3,7 @@ import { useCallback, useEffect, useState } from 'react'
3
3
  import { useAlpcMutation } from './useAlpcFetch'
4
4
  import type { CreditLogResponse } from '../response'
5
5
  import { useCreditsContext } from '../provider'
6
- import { useHeadlessContext } from '@anker-in/shared'
6
+ import { useHeadlessContext } from '@anker-in/lib'
7
7
 
8
8
  function useActivities({ page, pageSize, options = {} }: { page: number; pageSize: number; options?: any }) {
9
9
  const { profile, isLoadingProfile } = useCreditsContext()
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useMemo, useState } from 'react'
2
2
  import { emailValidate } from '../utils'
3
- import { useHeadlessContext } from '@anker-in/shared'
3
+ import { useHeadlessContext } from '@anker-in/lib'
4
4
 
5
5
  type ValidatorCallback = (value: string, params?: Record<string, any>) => boolean
6
6
 
@@ -1,7 +1,7 @@
1
1
  import Cookies from 'js-cookie'
2
2
  import { useCallback, useRef, useState } from 'react'
3
3
  import useSWR, { type SWRConfiguration } from 'swr'
4
- import { useHeadlessContext } from '@anker-in/shared'
4
+ import { useHeadlessContext } from '@anker-in/lib'
5
5
 
6
6
  import { getAlpcPath } from '../utils'
7
7
  import { useCreditsContext } from '../provider'
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useState } from 'react'
2
2
 
3
- import { useHeadlessContext } from '@anker-in/shared'
3
+ import { useHeadlessContext } from '@anker-in/lib'
4
4
  import { type ShippingCountry, type ShippingZone } from '../../type'
5
5
 
6
6
  function useCountries({ shopifyStoreDomain }: { shopifyStoreDomain: string }) {
@@ -4,7 +4,7 @@ import { ALPC_COUNTRY_MAP, AlpcConsumeType } from '../const'
4
4
  import { useAlpcMutation } from './useAlpcFetch'
5
5
  import type { RedeemLogResponse } from '../response'
6
6
  import { useCreditsContext } from '../provider'
7
- import { useHeadlessContext } from '@anker-in/shared'
7
+ import { useHeadlessContext } from '@anker-in/lib'
8
8
 
9
9
  function useMyRewards({
10
10
  page,
@@ -1,8 +1,8 @@
1
1
  import useSWRMutation, { SWRMutationConfiguration } from 'swr/mutation'
2
2
  import { useRedeemCoupon } from './useRedeemCoupon'
3
- import type { ProductVariant } from '@anker-in/shopify'
3
+ import type { ProductVariant } from '@anker-in/lib'
4
4
  import { useCreditsContext } from '../provider'
5
- import { useBuyNow } from '@anker-in/cart'
5
+ import { useBuyNow } from '@anker-in/lib'
6
6
 
7
7
  export const useRedeemAndBuy = (
8
8
  _: any,
@@ -1,6 +1,6 @@
1
1
  import { ALPC_COUNTRY_MAP } from '../const'
2
2
  import { useAlpcMutation, type UseMutationConfig } from './useAlpcFetch'
3
- import { useHeadlessContext } from '@anker-in/shared'
3
+ import { useHeadlessContext } from '@anker-in/lib'
4
4
 
5
5
  type RedeemCouponResponse = {
6
6
  code: number
@@ -1,6 +1,6 @@
1
1
  import { ALPC_COUNTRY_MAP } from '../const'
2
2
  import { useAlpcMutation, type UseMutationConfig } from './useAlpcFetch'
3
- import { useHeadlessContext } from '@anker-in/shared'
3
+ import { useHeadlessContext } from '@anker-in/lib'
4
4
 
5
5
  type RedeemProductResponse = {
6
6
  code: number
@@ -4,7 +4,7 @@ import { useAlpcMutation } from './useAlpcFetch'
4
4
  import { ALPC_COUNTRY_MAP } from '../const'
5
5
  import { useCreditsContext } from '../provider'
6
6
  import type { ConsumeCreditRuleResponse } from '../response'
7
- import { useHeadlessContext } from '@anker-in/shared'
7
+ import { useHeadlessContext } from '@anker-in/lib'
8
8
 
9
9
  function useRedeemableList() {
10
10
  let locale = '' as string
@@ -1,7 +1,7 @@
1
1
  import fetcher from '../../../../helpers/fetcher'
2
2
  import useSWRMutation from 'swr/mutation'
3
3
  import { useCreditsContext } from '../provider'
4
- import { useHeadlessContext } from '@anker-in/shared'
4
+ import { useHeadlessContext } from '@anker-in/lib'
5
5
 
6
6
  export function useSendEmailValidation() {
7
7
  const { profile } = useCreditsContext()
@@ -4,7 +4,7 @@ import { TaskSubType } from '../const'
4
4
  import useActivities from './useActivities'
5
5
  import useSubscriptions from './useSubscriptions'
6
6
  import { useCreditsContext } from '../provider'
7
- import { useHeadlessContext } from '@anker-in/shared'
7
+ import { useHeadlessContext } from '@anker-in/lib'
8
8
 
9
9
  export const useSubscribed = () => {
10
10
  const { profile } = useCreditsContext()
@@ -1,7 +1,7 @@
1
1
  import { useCallback, useEffect, useRef, useState } from 'react'
2
2
  import type { Subscription } from '../../type'
3
3
  import fetcher from '../../../../helpers/fetcher'
4
- import { useHeadlessContext } from '@anker-in/shared'
4
+ import { useHeadlessContext } from '@anker-in/lib'
5
5
 
6
6
  function useSubscriptions(email?: string) {
7
7
  const loading = useRef(false)
@@ -5,9 +5,9 @@ import RedeemableItem from './RedeemableItem'
5
5
  import useRedeemableList from '../context/hooks/useRedeemableList'
6
6
  import { cn } from '../../../helpers'
7
7
  import RulesModal from '../modal/rulesModal'
8
- import { useProductsByHandles } from '@anker-in/shopify'
8
+ import { useProductsByHandles } from '@anker-in/lib'
9
9
  import { CreditsCashCopy, RedeemItem } from './type'
10
- import { Product } from '@anker-in/shopify'
10
+ import { Product } from '@anker-in/lib'
11
11
 
12
12
  export const CreditsCash = ({
13
13
  copy,
@@ -1,4 +1,4 @@
1
- import { ProductVariant, Product } from '@anker-in/shopify'
1
+ import { ProductVariant, Product } from '@anker-in/lib'
2
2
  import { AlpcConsumeType } from '../context/const'
3
3
 
4
4
  type RedeemableItemConfig = {
@@ -7,7 +7,7 @@ import { Input } from './Input'
7
7
  import { StateSelect } from './StateSelect'
8
8
  import { ALPC_COUNTRY_MAP } from '../../context/const'
9
9
  import { useCreditsContext } from '../../context/provider'
10
- import { useHeadlessContext } from '@anker-in/shared'
10
+ import { useHeadlessContext } from '@anker-in/lib'
11
11
  import { AddressFormProps } from './type'
12
12
 
13
13
  export const AddressForm = ({ countries, countriesLoading, form, validate, errors, onChange }: AddressFormProps) => {
@@ -9,7 +9,7 @@ import { AlpcErrorCode } from '../context/const'
9
9
  import { CreditsModalContainer } from '../modal/modalContainer'
10
10
  import { numberFormat } from '../context/utils'
11
11
  import type { RedeemableItem as RedeemableItemType } from '../type'
12
- import { useHeadlessContext } from '@anker-in/shared'
12
+ import { useHeadlessContext } from '@anker-in/lib'
13
13
  import { CreditsRedeemListCopy } from './type'
14
14
 
15
15
  function RedeemCouponModal({
@@ -1,7 +1,7 @@
1
1
  import { Button, Text } from '@anker-in/headless-ui'
2
2
  import classNames from 'classnames'
3
3
  import { AddressForm } from '../AddressForm'
4
- import { useHeadlessContext } from '@anker-in/shared'
4
+ import { useHeadlessContext } from '@anker-in/lib'
5
5
  import type { RedeemableItem as RedeemableItemType } from '../../type'
6
6
  import { CreditsRedeemListCopy } from '../type'
7
7
  import { ProductInfo } from './ProductInfo'
@@ -2,7 +2,7 @@ import { Picture } from '@anker-in/headless-ui'
2
2
  import { formatPrice } from '../../context/utils'
3
3
  import type { RedeemableItem as RedeemableItemType } from '../../type'
4
4
  import { CreditsRedeemListCopy } from '../type'
5
- import { useHeadlessContext } from '@anker-in/shared'
5
+ import { useHeadlessContext } from '@anker-in/lib'
6
6
 
7
7
  type ProductInfoProps = {
8
8
  item: RedeemableItemType
@@ -8,7 +8,7 @@ import { useRedeemProduct } from '../../context/hooks/useRedeemProduct'
8
8
  import type { ModalContainerProps } from '../../modal/modalContainer'
9
9
  import { CreditsModalContainer } from '../../modal/modalContainer'
10
10
  import type { RedeemableItem as RedeemableItemType } from '../../type'
11
- import { useHeadlessContext } from '@anker-in/shared'
11
+ import { useHeadlessContext } from '@anker-in/lib'
12
12
  import { CreditsRedeemListCopy } from '../type'
13
13
  import { Error } from './Error'
14
14
  import { Success } from './Success'
@@ -7,7 +7,7 @@ import RedeemProductModal from './RedeemProductModal'
7
7
  import { useCreditsContext } from '../context/provider'
8
8
  import useRedeemableList from '../context/hooks/useRedeemableList'
9
9
  import { AlpcConsumeType, AlpcErrorCode } from '../context/const'
10
- import { useProductsByHandles } from '@anker-in/shopify'
10
+ import { useProductsByHandles } from '@anker-in/lib'
11
11
  import type { RedeemableItem as RedeemableItemType } from '../type'
12
12
  import { RedeemableItem } from './RedeemableItem'
13
13
  import RulesModal from '../modal/rulesModal'
@@ -5,7 +5,7 @@ import useReceiptUploaded from '../context/hooks/useReceiptUploaded'
5
5
  import { useFirstPurchaseFinished } from '../context/hooks/useFirstPurchaseFinished'
6
6
  import { useSubscribed } from '../context/hooks/useSubscribed'
7
7
  import type { CreditsWaysToGetCreditsProps } from './type'
8
- import { useHeadlessContext } from '@anker-in/shared'
8
+ import { useHeadlessContext } from '@anker-in/lib'
9
9
  import { gaTrack } from '../../../helpers/track'
10
10
 
11
11
  export const useActions = ({
@@ -1,4 +1,4 @@
1
- import type { Product, ProductVariant } from '@anker-in/shopify'
1
+ import type { Product, ProductVariant } from '@anker-in/lib'
2
2
  import type { AlpcConsumeType, ConsumeType } from './context/const'
3
3
 
4
4
  export interface Subscription {
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from './components/index'
2
2
 
3
3
  // 导出 Shopify 相关模块
4
- export * from '@anker-in/shopify'
4
+ export * from '@anker-in/lib'
@@ -0,0 +1,15 @@
1
+ @import "./css/colors.css";
2
+ @import "./css/popup.css";
3
+ @import "./css/sidebar.css";
4
+ @import "./css/button.css";
5
+ @import "./css/header.css";
6
+ @import "./css/input.css";
7
+ @import "./css/messages.css";
8
+ @import "./css/window.css";
9
+ @import "./css/animations.css";
10
+ @import "./css/response.css";
11
+ @import "./css/markdown.css";
12
+ @import "./css/suggestions.css";
13
+ @import "./css/panel.css";
14
+ @import "./css/console.css";
15
+
package/style.css CHANGED
@@ -12,3 +12,4 @@
12
12
  @import "./css/suggestions.css";
13
13
  @import "./css/panel.css";
14
14
  @import "./css/console.css";
15
+