@dismissible/react-client 0.3.1 → 0.3.2-canary.2.38782c4

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 CHANGED
@@ -1,6 +1,8 @@
1
1
  # @dismissible/react-client
2
2
 
3
- A React component library for creating dismissible UI elements with persistent state management.
3
+ A React component library for creating dismissible UI elements with persistent state management.
4
+
5
+ Use this in combination with [dismissible.io](https://dismissible.io). Get your free account now!
4
6
 
5
7
  🌐 **[dismissible.io](https://dismissible.io)** | 💰 **[View Pricing](https://dismissible.io/pricing)** | 📖 **[Documentation](https://docs.dismissible.io)**
6
8
 
@@ -369,32 +371,6 @@ function Dashboard() {
369
371
  }
370
372
  ```
371
373
 
372
- ### Conditional Dismissible Content
373
-
374
- ```tsx
375
- import { Dismissible } from '@dismissible/react-client';
376
-
377
- function ConditionalBanner({ user }) {
378
- // Only show to new users
379
- if (user.isReturning) {
380
- return null;
381
- }
382
-
383
- return (
384
- <Dismissible id={`onboarding-${user.id}`}>
385
- <div className="onboarding-tips">
386
- <h3>Getting Started</h3>
387
- <ul>
388
- <li>Complete your profile</li>
389
- <li>Connect with friends</li>
390
- <li>Explore our features</li>
391
- </ul>
392
- </div>
393
- </Dismissible>
394
- );
395
- }
396
- ```
397
-
398
374
  ### User-Specific vs Anonymous Dismissible Items
399
375
 
400
376
  The behavior changes based on whether JWT authentication is configured:
@@ -422,18 +398,6 @@ function AuthenticatedApp() {
422
398
  </DismissibleProvider>
423
399
  );
424
400
  }
425
-
426
- // Without JWT - dismissible state is account-level (anonymous)
427
- function AnonymousApp() {
428
- return (
429
- <div>
430
- {/* These will be dismissed for all users of this account */}
431
- <Dismissible id="general-announcement">
432
- <div>Site maintenance scheduled</div>
433
- </Dismissible>
434
- </div>
435
- );
436
- }
437
401
  ```
438
402
 
439
403
  ### Error Handling with ignoreErrors
@@ -455,18 +419,6 @@ function RobustBanner() {
455
419
  </Dismissible>
456
420
  );
457
421
  }
458
-
459
- // Default behavior - hide content on errors
460
- function StandardBanner() {
461
- return (
462
- <Dismissible id="promo-banner">
463
- <div className="promo">
464
- <h3>Special Offer!</h3>
465
- <p>Get 50% off your first order</p>
466
- </div>
467
- </Dismissible>
468
- );
469
- }
470
422
  ```
471
423
 
472
424
  ### Async JWT Authentication Examples
@@ -630,79 +582,6 @@ const AuthProvider: React.FC<DismissibleProviderProps> = ({ children, jwt }) =>
630
582
  };
631
583
  ```
632
584
 
633
- ## Development
634
-
635
- ### Prerequisites
636
-
637
- - Node.js 18+
638
- - npm or yarn
639
-
640
- ### Setup
641
-
642
- ```bash
643
- # Clone the repository
644
- git clone https://github.com/your-org/dismissible.git
645
- cd dismissible/react-client
646
-
647
- # Install dependencies
648
- npm install
649
-
650
- # Start development server
651
- npm run dev
652
- ```
653
-
654
- ### Available Scripts
655
-
656
- - `npm run dev` - Start development server with Vite
657
- - `npm run build` - Build the library for production
658
- - `npm run test` - Run tests with Vitest
659
- - `npm run test:watch` - Run tests in watch mode
660
- - `npm run lint` - Run ESLint
661
- - `npm run format` - Format code with Prettier
662
- - `npm run storybook` - Start Storybook development server
663
- - `npm run build-storybook` - Build Storybook for production
664
-
665
- ### Testing
666
-
667
- ```bash
668
- # Run all tests
669
- npm run test
670
-
671
- # Run tests in watch mode
672
- npm run test:watch
673
-
674
- # Run tests with coverage
675
- npm run test -- --coverage
676
- ```
677
-
678
- ### Storybook
679
-
680
- The library includes Storybook for component development and documentation:
681
-
682
- ```bash
683
- npm run storybook
684
- ```
685
-
686
- ## Contributing
687
-
688
- We welcome contributions! Please see our [Contributing Guide](../CONTRIBUTING.md) for details.
689
-
690
- ### Development Workflow
691
-
692
- 1. Fork the repository
693
- 2. Create a feature branch: `git checkout -b feature/my-new-feature`
694
- 3. Make your changes
695
- 4. Add tests for new functionality
696
- 5. Run tests: `npm run test`
697
- 6. Run linting: `npm run lint`
698
- 7. Commit your changes: `git commit -am 'Add new feature'`
699
- 8. Push to the branch: `git push origin feature/my-new-feature`
700
- 9. Submit a pull request
701
-
702
- ## License
703
-
704
- MIT © [Dismissible](https://github.com/joshystuart)
705
-
706
585
  ## Support
707
586
 
708
587
  - 📖 [Documentation](https://docs.dismissible.io)
@@ -5,6 +5,7 @@ import { DismissibleContextValue } from '../types/dismissible.types';
5
5
  export declare const DismissibleContext: import('react').Context<DismissibleContextValue | null>;
6
6
  /**
7
7
  * Hook to consume the DismissibleContext
8
- * @returns The context value or null if not within a provider
8
+ * @throws Error if used outside of a DismissibleProvider
9
+ * @returns The context value
9
10
  */
10
- export declare const useDismissibleContext: () => DismissibleContextValue | null;
11
+ export declare const useDismissibleContext: () => DismissibleContextValue;
@@ -6,12 +6,13 @@ import { DismissibleProviderProps } from '../types/dismissible.types';
6
6
  * @example
7
7
  * ```tsx
8
8
  * // With static JWT
9
- * <DismissibleProvider jwt="eyJhbGciOiJ..." baseUrl="https://api.dismissible.io">
9
+ * <DismissibleProvider userId="user-123" jwt="eyJhbGciOiJ..." baseUrl="https://api.dismissible.io">
10
10
  * <App />
11
11
  * </DismissibleProvider>
12
12
  *
13
13
  * // With synchronous JWT function
14
14
  * <DismissibleProvider
15
+ * userId="user-123"
15
16
  * jwt={() => getAccessToken()}
16
17
  * baseUrl="https://api.dismissible.io"
17
18
  * >
@@ -20,6 +21,7 @@ import { DismissibleProviderProps } from '../types/dismissible.types';
20
21
  *
21
22
  * // With asynchronous JWT function
22
23
  * <DismissibleProvider
24
+ * userId="user-123"
23
25
  * jwt={async () => await fetchAccessToken()}
24
26
  * baseUrl="https://api.dismissible.io"
25
27
  * >